SAM Event System Unit test.
Copyright (c) 2013-2020 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | TEST_EVENT_GEN EVSYS_ID_GEN_RTC_OVF |
#define | TEST_EVENT_USER EVSYS_ID_USER_TC3_EVU |
Functions | |
static void | cdc_uart_init (void) |
Initialize the USART for unit test. More... | |
static void | cleanup_asynchronous_event_test (const struct test_case *test) |
Cleanup Function: Asynchronous event propagation. More... | |
static void | cleanup_resynchronous_event_test (const struct test_case *test) |
Cleanup Function: Resynchronized event propagation. More... | |
static void | cleanup_synchronous_event_test (const struct test_case *test) |
Cleanup Function: Synchronous event propagation. More... | |
int | main (void) |
Run Event System unit tests. More... | |
static void | run_asynchronous_event_test (const struct test_case *test) |
Test for event system in asynchronous mode. More... | |
static void | run_resynchronous_event_test (const struct test_case *test) |
Test for event system in resynchronous mode. More... | |
static void | run_synchronous_event_test (const struct test_case *test) |
Test for event system in synchronous mode. More... | |
static void | setup_asynchronous_event_test (const struct test_case *test) |
Setup Function: Asynchronous event propagation. More... | |
static void | setup_resynchronous_event_test (const struct test_case *test) |
Setup Function: Resynchronized event propagation. More... | |
static void | setup_synchronous_event_test (const struct test_case *test) |
Setup Function: Synchronous event propagation. More... | |
static void | test_event_gen_user_init (void) |
Initialize the (TC3 | TC1) & RTC for unit test. More... | |
Variables | |
struct usart_module | cdc_uart_module |
struct events_resource | events |
volatile bool | init_success |
struct rtc_module | rtc_inst |
struct tc_module | tc_inst |
#define TEST_EVENT_GEN EVSYS_ID_GEN_RTC_OVF |
#define TEST_EVENT_USER EVSYS_ID_USER_TC3_EVU |
|
static |
Initialize the USART for unit test.
Initializes the SERCOM USART 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: Asynchronous event propagation.
This function disables the RTC, clears the RTC COUNT register and stops the timer (TC3 | TC1).
test | Current test case. |
References events, events_release(), rtc_count_disable(), rtc_count_set_count(), rtc_inst, tc_inst, and tc_stop_counter().
Referenced by main().
|
static |
Cleanup Function: Resynchronized event propagation.
This function disables the RTC, clears the RTC COUNT register and stops the timer (TC3 | TC1).
test | Current test case. |
References events, events_release(), rtc_count_disable(), rtc_count_set_count(), rtc_inst, tc_inst, and tc_stop_counter().
Referenced by main().
|
static |
Cleanup Function: Synchronous event propagation.
This function disables the RTC, clears the RTC COUNT register and stops the timer (TC3 | TC1).
test | Current test case. |
References events, events_release(), rtc_count_disable(), rtc_count_set_count(), rtc_inst, tc_inst, and tc_stop_counter().
Referenced by main().
int main | ( | void | ) |
Run Event System unit tests.
Initializes the system and serial output, then sets up the Event system unit test suite and runs it.
References cdc_uart_init(), cleanup_asynchronous_event_test(), cleanup_resynchronous_event_test(), cleanup_synchronous_event_test(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, run_asynchronous_event_test(), run_resynchronous_event_test(), run_synchronous_event_test(), setup_asynchronous_event_test(), setup_resynchronous_event_test(), setup_synchronous_event_test(), system_init(), test_event_gen_user_init(), and test_suite_run().
|
static |
Test for event system in asynchronous mode.
This test waits for event channel and user to be ready and then starts the RTC to generate overflow event. It waits until the timer is started. If the timer starts running then it can be assumed that the event has been propagated properly.
test | Current test case. |
References init_success, rtc_count_enable(), rtc_count_set_period(), rtc_inst, tc_get_count_value(), tc_inst, and test_assert_true.
Referenced by main().
|
static |
Test for event system in resynchronous mode.
This test waits for event channel and user to be ready and then starts the RTC to generate overflow event. It waits until the timer is started. If the timer starts running then it can be assumed that the event has been propagated properly.
test | Current test case. |
References events, events_is_busy(), events_is_users_ready(), init_success, rtc_count_enable(), rtc_count_set_period(), rtc_inst, tc_get_count_value(), tc_inst, and test_assert_true.
Referenced by main().
|
static |
Test for event system in synchronous mode.
This test waits for event channel and user to be ready and then starts the RTC to generate overflow event. It waits until the timer is started. If the timer starts running then it can be assumed that the event has been propagated properly.
test | Current test case. |
References events, events_is_busy(), events_is_users_ready(), init_success, rtc_count_enable(), rtc_count_set_period(), rtc_inst, tc_get_count_value(), tc_inst, and test_assert_true.
Referenced by main().
|
static |
Setup Function: Asynchronous event propagation.
This function initializes the event system channel 0 and the RTC module (event generator). The event channel clock will not be enabled for asynchronous event propagation.
test | Current test case. |
References events, events_allocate(), events_attach_user(), events_get_config_defaults(), EVENTS_PATH_ASYNCHRONOUS, events_config::generator, events_config::path, TEST_EVENT_GEN, and TEST_EVENT_USER.
Referenced by main().
|
static |
Setup Function: Resynchronized event propagation.
This function initializes the event system channel 0 and the RTC module (event generator) to be in the different clock domain for resynchronized event propagation.
test | Current test case. |
References events_config::clock_source, events_config::edge_detect, events, events_allocate(), events_attach_user(), EVENTS_EDGE_DETECT_RISING, events_get_config_defaults(), EVENTS_PATH_RESYNCHRONIZED, GCLK_GENERATOR_0, events_config::generator, events_config::path, TEST_EVENT_GEN, and TEST_EVENT_USER.
Referenced by main().
|
static |
Setup Function: Synchronous event propagation.
This function initializes the event system channel 0 and the RTC module (event generator) to be in the same clock domain for synchronous event propagation.
test | Current test case. |
References events_config::clock_source, events_config::edge_detect, events, events_allocate(), events_attach_user(), EVENTS_EDGE_DETECT_RISING, events_get_config_defaults(), EVENTS_PATH_SYNCHRONOUS, GCLK_GENERATOR_2, events_config::generator, events_config::path, TEST_EVENT_GEN, and TEST_EVENT_USER.
Referenced by main().
|
static |
Initialize the (TC3 | TC1) & RTC for unit test.
Initializes the RTC module and (TC3 | TC1) module which are used as event generator and event user respectively.
References tc_16bit_config::compare_capture_channel, rtc_count_config::compare_values, tc_config::counter_16_bit, tc_events::event_action, rtc_count_events::generate_event_on_overflow, init_success, rtc_count_config::mode, tc_events::on_event_perform_action, rtc_count_config::prescaler, rtc_count_enable_events(), rtc_count_get_config_defaults(), rtc_count_init(), RTC_COUNT_MODE_16BIT, RTC_COUNT_PRESCALER_DIV_1, rtc_inst, STATUS_OK, tc_enable(), tc_enable_events(), TC_EVENT_ACTION_START, tc_get_config_defaults(), tc_init(), and tc_inst.
Referenced by main().
struct usart_module cdc_uart_module |
struct events_resource events |
volatile bool init_success |
struct rtc_module rtc_inst |