SAM External Interrupt Unit test.
Copyright (c) 2013-2020 Microchip Technology Inc. and its subsidiaries.
Functions | |
static void | cdc_uart_init (void) |
Initialize the USART for unit test. More... | |
static void | cleanup_extint_callback_mode_test (const struct test_case *test) |
Cleanup function for callback mode test. More... | |
static void | cleanup_extint_polled_mode_test (const struct test_case *test) |
Cleanup function for polled mode test. More... | |
static void | extint_user_callback (void) |
External interrupt callback function. More... | |
int | main (void) |
Run External Interrupt unit tests. More... | |
static void | run_extint_callback_mode_test (const struct test_case *test) |
Test for external interrupt detection using callback. More... | |
static void | run_extint_polled_mode_test (const struct test_case *test) |
Test for external interrupt detection by polling. More... | |
static void | setup_extint_callback_mode_test (const struct test_case *test) |
Setup function for callback mode test. More... | |
static void | setup_extint_polled_mode_test (const struct test_case *test) |
Setup function for polled mode test. More... | |
Variables | |
struct usart_module | cdc_uart_module |
struct extint_chan_conf | eic_conf |
volatile bool | interrupt_flag = false |
struct port_config | pin_conf |
volatile bool | result = false |
|
static |
Initialize the USART for unit test.
Initializes the SERCOM USART (SERCOM4) used for sending the unit test status to the computer via the EDBG CDC gateway.
References usart_config::baudrate, cdc_uart_module, usart_config::mux_setting, usart_config::pinmux_pad0, usart_config::pinmux_pad1, usart_config::pinmux_pad2, usart_config::pinmux_pad3, usart_enable(), and usart_get_config_defaults().
Referenced by main().
|
static |
Cleanup function for callback mode test.
This function disables the callback & external interrupt channel.
test | Current test case. |
References extint_chan_conf::detection_criteria, eic_conf, EXTINT_CALLBACK_TYPE_DETECT, extint_chan_disable_callback(), extint_chan_set_config(), EXTINT_DETECT_NONE, extint_unregister_callback(), and extint_user_callback().
Referenced by main().
|
static |
Cleanup function for polled mode test.
This function disables the external interrupt channel.
test | Current test case. |
References extint_chan_conf::detection_criteria, eic_conf, extint_chan_set_config(), and EXTINT_DETECT_NONE.
Referenced by main().
|
static |
External interrupt callback function.
Called by external interrupt driver on interrupt detection.
References interrupt_flag.
Referenced by cleanup_extint_callback_mode_test(), and setup_extint_callback_mode_test().
int main | ( | void | ) |
Run External Interrupt unit tests.
Initializes the system and serial output, then sets up the External Interrupt unit test suite and runs it.
References cdc_uart_init(), cleanup_extint_callback_mode_test(), cleanup_extint_polled_mode_test(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, delay_init(), run_extint_callback_mode_test(), run_extint_polled_mode_test(), setup_extint_callback_mode_test(), setup_extint_polled_mode_test(), system_init(), and test_suite_run().
|
static |
Test for external interrupt detection using callback.
This test changes the logic level of PB05 from high to low so that the external interrupt channel detects the edge and calls the callback function.
Detection is tested for both rising and falling edges.
test | Current test case. |
References extint_chan_conf::detection_criteria, eic_conf, extint_chan_set_config(), EXTINT_DETECT_RISING, interrupt_flag, port_pin_set_output_level(), and test_assert_true.
Referenced by main().
|
static |
Test for external interrupt detection by polling.
This test changes the logic level of PB05 from high to low so that the external interrupt channel detects the edge.
Detection is tested for both rising and falling edges.
test | Current test case. |
References delay_ms, extint_chan_conf::detection_criteria, eic_conf, extint_chan_clear_detected(), extint_chan_is_detected(), extint_chan_set_config(), EXTINT_DETECT_RISING, port_pin_set_output_level(), result, and test_assert_true.
Referenced by main().
|
static |
Setup function for callback mode test.
This function sets up the GPIO pin, the external interrupt channel & the callback function.
test | Current test case. |
References extint_chan_conf::detection_criteria, port_config::direction, eic_conf, EXTINT_CALLBACK_TYPE_DETECT, extint_chan_enable_callback(), extint_chan_get_config_defaults(), extint_chan_set_config(), EXTINT_DETECT_FALLING, EXTINT_PULL_UP, extint_register_callback(), extint_user_callback(), extint_chan_conf::gpio_pin, extint_chan_conf::gpio_pin_mux, extint_chan_conf::gpio_pin_pull, port_config::input_pull, pin_conf, port_get_config_defaults(), PORT_PIN_DIR_OUTPUT, PORT_PIN_PULL_NONE, port_pin_set_config(), and port_pin_set_output_level().
Referenced by main().
|
static |
Setup function for polled mode test.
This function sets up the GPIO pin and the external interrupt channel.
test | Current test case. |
References extint_chan_conf::detection_criteria, port_config::direction, eic_conf, extint_chan_get_config_defaults(), extint_chan_set_config(), EXTINT_DETECT_FALLING, EXTINT_PULL_UP, extint_chan_conf::gpio_pin, extint_chan_conf::gpio_pin_mux, extint_chan_conf::gpio_pin_pull, port_config::input_pull, pin_conf, port_get_config_defaults(), PORT_PIN_DIR_OUTPUT, PORT_PIN_PULL_NONE, port_pin_set_config(), and port_pin_set_output_level().
Referenced by main().
struct usart_module cdc_uart_module |
struct extint_chan_conf eic_conf |
struct port_config pin_conf |
Referenced by setup_extint_callback_mode_test(), and setup_extint_polled_mode_test().