SAM TC 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... | |
int | main (void) |
Run TC unit tests. More... | |
static void | run_16bit_capture_and_compare_test (const struct test_case *test) |
Test capture and compare. More... | |
static void | run_basic_functionality_test (const struct test_case *test) |
Test basic functionality. More... | |
static void | run_callback_test (const struct test_case *test) |
Test the callback API. More... | |
static void | run_init_test (const struct test_case *test) |
Test of tc_init() and tc_get_config_defaults() More... | |
static void | run_reset_32bit_master_test (const struct test_case *test) |
Test initializing and resetting 32-bit TC and reinitialize. More... | |
static void | tc_callback_function (struct tc_module *const module_inst) |
Function used to test callback API. More... | |
Variables | |
bool | basic_functionality_test_passed = false |
volatile uint32_t | callback_function_entered = 0 |
struct usart_module | cdc_uart_module |
bool | tc_init_success = 0 |
struct tc_config | tc_test0_config |
struct tc_module | tc_test0_module |
struct tc_config | tc_test1_config |
struct tc_module | tc_test1_module |
|
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, CONF_STDIO_BAUDRATE, CONF_STDIO_MUX_SETTING, CONF_STDIO_PINMUX_PAD0, CONF_STDIO_PINMUX_PAD1, CONF_STDIO_PINMUX_PAD2, CONF_STDIO_PINMUX_PAD3, CONF_STDIO_USART, 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().
int main | ( | void | ) |
Run TC unit tests.
Initializes the system and serial output, then sets up the TC unit test suite and runs it.
References cdc_uart_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, run_16bit_capture_and_compare_test(), run_basic_functionality_test(), run_callback_test(), run_init_test(), run_reset_32bit_master_test(), system_init(), tc_reset(), tc_test0_module, tc_test1_module, and test_suite_run().
|
static |
Test capture and compare.
This test uses TC module 0 as a PWM generator (compare function). TC module 1 will be set to capture the signal from TC module 0 to test the capture functionality.
test | Current test case. |
References callback_function_entered, tc_config::clock_prescaler, tc_16bit_config::compare_capture_channel, CONF_CAPTURE_CHAN_0, CONF_CAPTURE_CHAN_1, CONF_EIC_MUX, CONF_EIC_PIN, CONF_EVENT_GENERATOR_ID, CONF_EVENT_USED_ID, CONF_TEST_PIN_MUX, CONF_TEST_PIN_OUT, CONF_TEST_TC0, CONF_TEST_TC1, CONF_TEST_TOLERANCE, tc_config::counter_16_bit, extint_chan_conf::detection_criteria, events_config::edge_detect, tc_config::enable_capture_on_channel, tc_pwm_channel::enabled, events_allocate(), events_attach_user(), EVENTS_EDGE_DETECT_NONE, events_get_config_defaults(), EVENTS_PATH_ASYNCHRONOUS, extint_chan_set_config(), EXTINT_DETECT_HIGH, extint_enable_events(), EXTINT_PULL_UP, extint_chan_conf::filter_input_signal, extint_events::generate_event_on_detect, events_config::generator, extint_chan_conf::gpio_pin, extint_chan_conf::gpio_pin_mux, extint_chan_conf::gpio_pin_pull, tc_events::on_event_perform_action, events_config::path, tc_pwm_channel::pin_mux, tc_pwm_channel::pin_out, tc_config::pwm_channel, system_clock_source_get_hz(), SYSTEM_CLOCK_SOURCE_OSC48M, TC_CALLBACK_CC_CHANNEL0, tc_callback_function(), TC_CLOCK_PRESCALER_DIV1, TC_COMPARE_CAPTURE_CHANNEL_0, TC_COMPARE_CAPTURE_CHANNEL_1, tc_enable(), tc_enable_callback(), tc_enable_events(), TC_EVENT_ACTION_PPW, tc_get_capture_value(), tc_get_config_defaults(), tc_init(), tc_init_success, tc_register_callback(), tc_reset(), tc_test0_config, tc_test0_module, tc_test1_config, tc_test1_module, TC_WAVE_GENERATION_MATCH_PWM, test_assert_true, extint_chan_conf::wake_if_sleeping, and tc_config::wave_generation.
Referenced by main().
|
static |
Test basic functionality.
This test tests the basic functionality for the TC. It tests the following functions:
test | Current test case. |
References basic_functionality_test_passed, CONF_TEST_TC0, tc_enable(), tc_get_config_defaults(), tc_get_count_value(), tc_init(), tc_init_success, tc_reset(), tc_set_count_value(), tc_start_counter(), tc_stop_counter(), tc_test0_config, tc_test0_module, and test_assert_true.
Referenced by main().
|
static |
Test the callback API.
This test tests the callback API for the TC. The TC uses one-shot mode.
test | Current test case. |
References basic_functionality_test_passed, callback_function_entered, tc_16bit_config::compare_capture_channel, CONF_TEST_TC0, tc_config::counter_16_bit, TC_CALLBACK_CC_CHANNEL1, tc_callback_function(), tc_clear_status(), TC_COMPARE_CAPTURE_CHANNEL_0, TC_COMPARE_CAPTURE_CHANNEL_1, tc_disable(), tc_disable_callback(), tc_enable(), tc_enable_callback(), tc_get_config_defaults(), tc_get_status(), tc_init(), tc_init_success, tc_register_callback(), tc_reset(), tc_set_count_value(), TC_STATUS_COUNT_OVERFLOW, tc_test0_config, tc_test0_module, TC_WAVE_GENERATION_MATCH_PWM, test_assert_true, and tc_config::wave_generation.
Referenced by main().
|
static |
Test of tc_init() and tc_get_config_defaults()
This test is used to initialize the tcx_module structs and associate the given hw module with the struct. This test should be run at the very beginning of testing as other tests depend on the result of this test.
References CONF_TEST_TC0, CONF_TEST_TC1, STATUS_OK, tc_get_config_defaults(), tc_init(), tc_init_success, tc_test0_config, tc_test0_module, tc_test1_config, tc_test1_module, and test_assert_true.
Referenced by main().
|
static |
Test initializing and resetting 32-bit TC and reinitialize.
This test tests the software reset of a 32-bit TC by the use of the tc_reset(). It also test re-enabling the two TC modules used in the 32-bit TC into two separate 16-bit TC's.
test | Current test case. |
References CONF_TEST_TC0, CONF_TEST_TC1, tc_config::counter_size, TC_COUNTER_SIZE_16BIT, TC_COUNTER_SIZE_32BIT, tc_enable(), tc_get_config_defaults(), tc_init(), tc_init_success, tc_is_syncing(), tc_reset(), tc_test0_config, tc_test0_module, tc_test1_config, tc_test1_module, test_assert_false, and test_assert_true.
Referenced by main().
|
static |
Function used to test callback API.
This function indicates that the callback function has been invoked.
References callback_function_entered.
Referenced by run_16bit_capture_and_compare_test(), and run_callback_test().
Referenced by run_basic_functionality_test(), and run_callback_test().
volatile uint32_t callback_function_entered = 0 |
Referenced by run_16bit_capture_and_compare_test(), run_callback_test(), and tc_callback_function().
struct usart_module cdc_uart_module |
Referenced by cdc_uart_init().
bool tc_init_success = 0 |
struct tc_config tc_test0_config |
struct tc_module tc_test0_module |
struct tc_config tc_test1_config |
Referenced by run_16bit_capture_and_compare_test(), run_init_test(), and run_reset_32bit_master_test().
struct tc_module tc_test1_module |
Referenced by main(), run_16bit_capture_and_compare_test(), run_init_test(), and run_reset_32bit_master_test().