Microchip® Advanced Software Framework

drivers/dac/unit_test/unit_test.c File Reference

SAM DAC Unit Test.

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

#include <asf.h>
#include <stdio_serial.h>
#include <string.h>
#include "conf_test.h"

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
 [rtc_module_instance] More...
 

static void cdc_uart_init ( void  )
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().

void configure_event_resource ( void  )

event source for DAC conversion

set rtc overflow as the event generator for DAC conversion

void configure_rtc_count ( void  )

rtc for event generator

set rtc clock prescaler and mode to generate overflow events

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(), NULL, run_dac_event_control_test(), run_dac_init_test(), system_init(), and test_suite_run().

static void run_dac_event_control_test ( const struct test_case test)
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 void run_dac_init_test ( const struct test_case test)
static

struct usart_module cdc_uart_module
struct dac_module dac_instance
struct events_resource event_dac
struct rtc_module rtc_instance

[rtc_module_instance]

[rtc_module_instance]

[rtc_module_inst]