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 |
Referenced by run_adcife_multichannel_test().
#define DAC_INTERNAL_MIN_VALUE 2449 |
Referenced by run_adcife_multichannel_test().
#define MAX_DIGITAL (4095) |
The maximal digital value.
#define VCC_SCALED_MAX_VALUE 1474 |
Referenced by run_adcife_multichannel_test().
#define VCC_SCALED_MIN_VALUE 434 |
Referenced by run_adcife_multichannel_test().
|
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 |
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().
int main | ( | void | ) |
Run ADCIFE driver unit tests.
References uart_rs232_options::baudrate, board_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, NULL, run_adcife_diff_test(), run_adcife_init_test(), run_adcife_itimer_trig_test(), run_adcife_multichannel_test(), run_adcife_wm_test(), stdio_serial_init(), sysclk_init(), test_suite_run(), and usart_serial_options.
|
static |
Callback function for PDCA interrupt.
References g_adc_sample_data, PDCA_CH_TRANSFER_COMPLETED, pdca_channel_disable_interrupt(), and pdca_channel_write_load().
Referenced by run_adcife_multichannel_test().
|
static |
Test ADCIFE in Differential mode.
test | Current test case. |
References ADC_BIPOLAR_DIFFERENTIAL, adc_ch_set_config(), adc_configure_gain(), adc_configure_trigger(), ADC_GAIN_1X, ADC_GCOMP_DIS, adc_get_last_conv_value(), adc_get_status(), ADC_HWLA_DIS, ADC_INTERNAL_3, ADC_MUXNEG_1, ADC_MUXPOS_2, ADC_NUM_OF_ATTEMPTS, ADC_RES_12_BIT, ADC_TRIG_CON, ADC_ZOOMRANGE_0, g_adc_inst, adc_ch_config::seq_cfg, test_assert_true, and adc_seq_config::zoomrange.
Referenced by main().
|
static |
Test ADCIFE Initialize is OK or not.
test | Current 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 |
Test ADCIFE in internal timer trigger mode, which also tests interrupt driven conversions.
test | Current test case. |
References ADC_BIPOLAR_SINGLEENDED, adc_ch_set_config(), adc_configure_gain(), adc_configure_itimer_period(), adc_configure_trigger(), ADC_GAIN_1X, ADC_GCOMP_DIS, ADC_HWLA_DIS, ADC_INTERNAL_3, ADC_MUXNEG_1, ADC_MUXPOS_2, ADC_RES_12_BIT, ADC_SEQ_SEOC, adc_set_callback(), adc_start_itimer(), ADC_TRIG_INTL_TIMER, ADC_ZOOMRANGE_0, adcife_set_conv_flag(), delay_ms, g_adc_inst, g_uc_condone_flag, adc_ch_config::internal_timer_max_count, adc_ch_config::seq_cfg, test_assert_true, and adc_seq_config::zoomrange.
Referenced by main().
|
static |
Test ADCIFE in multiple channel mode.
test | Current test case. |
References adc_configure_gain(), adc_configure_trigger(), ADC_GAIN_1X, adc_pdca_set_config(), ADC_TRIG_CON, DAC_INTERNAL_MAX_VALUE, DAC_INTERNAL_MIN_VALUE, delay_ms, g_adc_inst, g_adc_sample_data, pdca_channel_set_callback(), pdca_transfer_done(), start_dac(), test_assert_true, VCC_SCALED_MAX_VALUE, and VCC_SCALED_MIN_VALUE.
Referenced by main().
|
static |
Test ADCIFE in window monitor mode.
test | Current test case. |
References ADC_BIPOLAR_SINGLEENDED, adc_ch_set_config(), adc_configure_gain(), adc_configure_trigger(), adc_disable(), adc_enable_interrupt(), ADC_GAIN_1X, ADC_GCOMP_DIS, ADC_HWLA_DIS, ADC_INTERNAL_3, ADC_MUXNEG_1, ADC_MUXPOS_2, ADC_MUXPOS_3, ADC_RES_12_BIT, adc_set_callback(), ADC_TRIG_CON, ADC_WINDOW_MONITOR, ADC_WM_MODE_3, ADC_ZOOMRANGE_0, adcife_set_wm_flag(), delay_ms, g_adc_inst, g_uc_enter_win_flag, adc_seq_config::muxpos, adc_ch_config::seq_cfg, test_assert_true, and adc_seq_config::zoomrange.
Referenced by main().
|
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 |
uint16_t g_adc_sample_data[2] |
Conversion value.
Referenced by adcife_read_conv_result(), main(), pdca_transfer_done(), and run_adcife_multichannel_test().
volatile uint8_t g_uc_condone_flag = 0 |
Conversion done flag.
Referenced by adcife_read_conv_result(), adcife_set_conv_flag(), main(), pdca_transfer_done(), and run_adcife_itimer_trig_test().
volatile uint8_t g_uc_enter_win_flag = 0 |
Enter comparison window flag.
Referenced by adcife_set_wm_flag(), and run_adcife_wm_test().