SAM DAC Unit Test.
Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
Functions | |
static void | cdc_uart_init (void) |
Initialize the USART for unit test. More... | |
void | configure_event_resource (void) |
event source for DAC conversion More... | |
void | configure_rtc_count (void) |
rtc for event generator More... | |
int | main (void) |
Run DAC unit tests. More... | |
static void | run_dac_event_control_test (const struct test_case *test) |
Test for DAC conversion driven by events in polled mode. More... | |
static void | run_dac_init_test (const struct test_case *test) |
Initialize the DAC for unit test. More... | |
Variables | |
struct usart_module | cdc_uart_module |
struct dac_module | dac_instance |
struct events_resource | event_dac |
struct rtc_module | rtc_instance |
|
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, 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().
void configure_event_resource | ( | void | ) |
event source for DAC conversion
set rtc overflow as the event generator for DAC conversion
References events_config::clock_source, events_config::edge_detect, event_dac, events_allocate(), events_attach_user(), EVENTS_EDGE_DETECT_NONE, events_get_config_defaults(), EVENTS_PATH_ASYNCHRONOUS, GCLK_GENERATOR_0, events_config::generator, and events_config::path.
Referenced by run_dac_event_control_test().
void configure_rtc_count | ( | void | ) |
rtc for event generator
set rtc clock prescaler and mode to generate overflow events
References rtc_count_config::continuously_update, rtc_count_events::generate_event_on_overflow, rtc_count_config::mode, rtc_count_config::prescaler, rtc_count_enable(), rtc_count_enable_events(), rtc_count_get_config_defaults(), rtc_count_init(), RTC_COUNT_MODE_16BIT, RTC_COUNT_PRESCALER_DIV_1, and rtc_instance.
Referenced by run_dac_event_control_test().
int main | ( | void | ) |
Run DAC unit tests.
Initializes the system and serial output, then sets up the DAC unit test suite and runs it.
References cdc_uart_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, delay_init(), run_dac_event_control_test(), run_dac_init_test(), system_init(), and test_suite_run().
|
static |
Test for DAC conversion driven by events in polled mode.
after the first event, dac should enter channel buffer empty status. after the second event, dac should enter channel buffer underrun status.
References configure_event_resource(), configure_rtc_count(), dac_chan_write(), DAC_CHANNEL_0, dac_get_status(), dac_instance, DAC_STATUS_CHANNEL_0_EMPTY, DAC_STATUS_CHANNEL_0_UNDERRUN, delay_ms, rtc_count_set_period(), rtc_instance, STATUS_OK, and test_assert_true.
Referenced by main().
|
static |
Initialize the DAC for unit test.
Initializes the DAC module to accept events to start conversion
References dac_chan_enable(), dac_chan_get_config_defaults(), dac_chan_set_config(), DAC_CHANNEL_0, dac_enable(), dac_enable_events(), dac_get_config_defaults(), dac_init(), dac_instance, dac_events::on_event_chan0_start_conversion, STATUS_ERR_IO, STATUS_OK, and test_assert_true.
Referenced by main().
struct usart_module cdc_uart_module |
Referenced by cdc_uart_init().
struct dac_module dac_instance |
Referenced by run_dac_event_control_test(), and run_dac_init_test().
struct events_resource event_dac |
Referenced by configure_event_resource().
struct rtc_module rtc_instance |
Referenced by configure_rtc_count(), and run_dac_event_control_test().