Microchip® Advanced Software Framework

common/services/ioport/unit_tests/unit_tests.c File Reference

Unit tests for MegaRF IOPORT service.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include <conf_test.h>

Functions

int main (void)
 Run IOPORT unit tests. More...
 
static void run_ioport_pin_test (const struct test_case *test)
 Test IOPORT pin level is getting changed. More...
 
static void run_ioport_port_test (const struct test_case *test)
 Test IOPORT port level is getting changed. More...
 

int main ( void  )

Run IOPORT unit tests.

Main function.

Initializes the clock system, board and serial output, then sets up the IOPORT Service unit test suite and runs it.

The SAM3X_EK, SAM3X Arduino board and SAM4C_EK use two bytes length internal address EEPROM.

References usart_rs232_options::baudrate, board_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, NULL, run_ioport_pin_test(), run_ioport_port_test(), stdio_serial_init(), sysclk_init(), test_suite_run(), and usart_serial_options.

static void run_ioport_pin_test ( const struct test_case test)
static

Test IOPORT pin level is getting changed.

This function set the direction of CONF_OUT_PIN to output mode with pull-up enabled and read the status of pin using CONF_IN_PIN which is configured in input mode.

The pin CONF_OUT_PIN and CONF_IN_PIN are shorted using a jumper.

Parameters
testCurrent test case.

References CONF_OUT_PIN, delay_ms, IOPORT_DIR_INPUT, IOPORT_DIR_OUTPUT, ioport_get_pin_level(), IOPORT_MODE_PULLUP, IOPORT_PIN_LEVEL_HIGH, IOPORT_PIN_LEVEL_LOW, ioport_set_pin_dir(), ioport_set_pin_level(), ioport_set_pin_mode(), ioport_toggle_pin_level(), and test_assert_true.

Referenced by main().

static void run_ioport_port_test ( const struct test_case test)
static

Test IOPORT port level is getting changed.

This function set the direction of CONF_PORT_OUT_PIN_MASK to output mode with pull-up enabled and read the status of pin using CONF_PORT_IN_PIN_MASK which is configured in input mode. The pin CONF_PORT_OUT_PIN_MASK and CONF_PORT_IN_PIN_MASK are shorted using a jumper.

Parameters
testCurrent test case.

References delay_ms, IOPORT_DIR_INPUT, IOPORT_DIR_OUTPUT, ioport_get_port_level(), IOPORT_MODE_PULLUP, IOPORT_PIN_LEVEL_HIGH, IOPORT_PIN_LEVEL_LOW, ioport_set_port_dir(), ioport_set_port_level(), ioport_set_port_mode(), ioport_toggle_port_level(), and test_assert_true.

Referenced by main().