Microchip® Advanced Software Framework

sam/drivers/adcife/unit_tests/unit_tests.c File Reference

Unit tests for ADCIFE driver.

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

#include <board.h>
#include <sysclk.h>
#include <delay.h>
#include "adcife.h"
#include "dacc.h"
#include "pdca.h"
#include <string.h>
#include <unit_test/suite.h>
#include <stdio_serial.h>
#include <conf_test.h>
#include <conf_board.h>

Macros

#define ADCIFE_STARTUP   24
 ADCIFE startup time value. More...
 
#define DAC_INTERNAL_MAX_VALUE   3673
 
#define DAC_INTERNAL_MIN_VALUE   2449
 
#define MAX_DIGITAL   (4095)
 The maximal digital value. More...
 
#define VCC_SCALED_MAX_VALUE   1474
 
#define VCC_SCALED_MIN_VALUE   434
 

Functions

static void adcife_set_conv_flag (void)
 Callback function for ADCIFE interrupt. More...
 
static void adcife_set_wm_flag (void)
 Callback function for ADCIFE enter compasion window interrupt. More...
 
int main (void)
 Run ADCIFE driver unit tests. More...
 
static void pdca_transfer_done (enum pdca_channel_status status)
 Callback function for PDCA interrupt. More...
 
static void run_adcife_diff_test (const struct test_case *test)
 Test ADCIFE in Differential mode. More...
 
static void run_adcife_init_test (const struct test_case *test)
 Test ADCIFE Initialize is OK or not. More...
 
static void run_adcife_itimer_trig_test (const struct test_case *test)
 Test ADCIFE in internal timer trigger mode, which also tests interrupt driven conversions. More...
 
static void run_adcife_multichannel_test (const struct test_case *test)
 Test ADCIFE in multiple channel mode. More...
 
static void run_adcife_wm_test (const struct test_case *test)
 Test ADCIFE in window monitor mode. More...
 
static void start_dac (void)
 Start DAC ouput. More...
 

Variables

struct adc_cdma_first_config g_adc_cdma_first_cfg [2]
 ADC CDMA config value. More...
 
struct adc_dev_inst g_adc_inst
 ADC instance. More...
 
struct adc_pdca_config g_adc_pdca_cfg
 
uint16_t g_adc_sample_data [2]
 Conversion value. More...
 
volatile uint8_t g_uc_condone_flag = 0
 Conversion done flag. More...
 
volatile uint8_t g_uc_enter_win_flag = 0
 Enter comparison window flag. More...
 

#define ADCIFE_STARTUP   24

ADCIFE startup time value.

#define DAC_INTERNAL_MAX_VALUE   3673
#define DAC_INTERNAL_MIN_VALUE   2449
#define MAX_DIGITAL   (4095)

The maximal digital value.

#define VCC_SCALED_MAX_VALUE   1474
#define VCC_SCALED_MIN_VALUE   434

static void adcife_set_conv_flag ( void  )
static

Callback function for ADCIFE interrupt.

References adc_clear_status(), adc_disable_interrupt(), adc_get_status(), ADC_SEQ_SEOC, g_adc_inst, and g_uc_condone_flag.

Referenced by run_adcife_itimer_trig_test().

static void adcife_set_wm_flag ( void  )
static

Callback function for ADCIFE enter compasion window interrupt.

References adc_clear_status(), adc_disable_interrupt(), ADC_WINDOW_MONITOR, g_adc_inst, and g_uc_enter_win_flag.

Referenced by run_adcife_wm_test().

static void pdca_transfer_done ( enum pdca_channel_status  status)
static
static void run_adcife_init_test ( const struct test_case test)
static

Test ADCIFE Initialize is OK or not.

Parameters
testCurrent test case.

References ADC_CLKSEL_APBCLK, adc_enable(), adc_init(), ADC_PRESCAL_DIV16, ADC_REFSEL_0, ADC_SPEED_150K, g_adc_inst, adc_config::prescal, STATUS_OK, and test_assert_true.

Referenced by main().

static void run_adcife_multichannel_test ( const struct test_case test)
static
static void start_dac ( void  )
static

Start DAC ouput.

Initialize DAC, set clock and timing, and set DAC to given mode.

References dacc_enable(), dacc_reset(), dacc_set_timing(), dacc_set_transfer_mode(), dacc_write_conversion_data(), and sysclk_enable_peripheral_clock().

Referenced by run_adcife_multichannel_test().

struct adc_cdma_first_config g_adc_cdma_first_cfg[2]

ADC CDMA config value.

struct adc_dev_inst g_adc_inst

ADC instance.

struct adc_pdca_config g_adc_pdca_cfg
Initial value:
= {
.wm = false,
.nb_channels = 2,
.buffer = g_adc_sample_data,
.pdc_rx_channel = CONFIG_ADC_PDCA_RX_CHANNEL,
.pdc_tx_channel = CONFIG_ADC_PDCA_TX_CHANNEL,
.cdma_cfg = (void *)&g_adc_cdma_first_cfg[0]
}
struct adc_cdma_first_config g_adc_cdma_first_cfg[2]
ADC CDMA config value.
Definition: sam/drivers/adcife/unit_tests/unit_tests.c:102
uint16_t g_adc_sample_data[2]
Conversion value.
Definition: sam/drivers/adcife/unit_tests/unit_tests.c:99
uint16_t g_adc_sample_data[2]
volatile uint8_t g_uc_condone_flag = 0
volatile uint8_t g_uc_enter_win_flag = 0

Enter comparison window flag.

Referenced by adcife_set_wm_flag(), and run_adcife_wm_test().