Unit tests for AFEC driver.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#include <board.h>
#include <sysclk.h>
#include <delay.h>
#include "afec.h"
#include "tc.h"
#include "ioport.h"
#include <string.h>
#include <unit_test/suite.h>
#include <stdio_serial.h>
#include <conf_test.h>
#include <conf_board.h>
Functions | |
static void | afec_set_comp_flag (void) |
Callback function for AFEC enter compasion window interrupt. More... | |
static void | afec_set_data_ready_flag (void) |
Callback function for AFEC conversion data is ready interrupt. More... | |
static void | configure_tc_trigger (void) |
Configure to trigger AFEC by TIOA output of timer. More... | |
int | main (void) |
Run AFEC driver unit tests. More... | |
static void | run_afec_comp_test (const struct test_case *test) |
Test AFEC in comparsion window mode. More... | |
static void | run_afec_tc_trig_test (const struct test_case *test) |
Test AFEC in TC trigger mode, which also tests interrupt driven conversions. More... | |
Variables | |
volatile bool | is_comp_event_flag = false |
Enter comparison window flag. More... | |
volatile bool | is_data_ready = false |
Conversion data is ready flag. More... | |
|
static |
Callback function for AFEC enter compasion window interrupt.
References afec_disable_interrupt(), and is_comp_event_flag.
Referenced by run_afec_comp_test().
|
static |
Callback function for AFEC conversion data is ready interrupt.
References afec_disable_interrupt(), is_data_ready, and tc_stop().
Referenced by run_afec_tc_trig_test().
|
static |
Configure to trigger AFEC by TIOA output of timer.
References afec_set_trigger(), AFEC_TRIG_TIO_CH_0, ioport_disable_pin(), ioport_set_pin_mode(), PIN_TC0_TIOA0, PIN_TC0_TIOA0_FLAGS, pmc_enable_periph_clk(), sysclk_get_cpu_hz(), tc_find_mck_divisor(), tc_init(), and tc_start().
Referenced by run_afec_tc_trig_test().
int main | ( | void | ) |
Run AFEC driver unit tests.
References afec_channel_enable(), afec_channel_set_analog_offset(), afec_enable(), afec_get_config_defaults(), afec_init(), uart_rs232_options::baudrate, board_init(), CONF_TEST_BAUDRATE, CONF_TEST_PARITY, CONF_TEST_USART, CONF_UART_CHAR_LENGTH, CONF_UART_STOP_BITS, CONSOLE_UART_ID, DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, run_afec_comp_test(), run_afec_tc_trig_test(), stdio_serial_init(), sysclk_enable_peripheral_clock(), sysclk_init(), and test_suite_run().
|
static |
Test AFEC in comparsion window mode.
test | Current test case. |
References AFEC_CMP_MODE_2, afec_set_callback(), afec_set_comp_flag(), afec_set_comparison_mode(), afec_set_comparison_window(), afec_set_trigger(), afec_start_software_conversion(), AFEC_TRIG_SW, delay_ms, is_comp_event_flag, and test_assert_true.
Referenced by main().
|
static |
Test AFEC in TC trigger mode, which also tests interrupt driven conversions.
test | Current test case. |
References afec_set_callback(), afec_set_data_ready_flag(), configure_tc_trigger(), delay_ms, is_data_ready, and test_assert_true.
Referenced by main().
Enter comparison window flag.
Referenced by afec_set_comp_flag(), and run_afec_comp_test().
Conversion data is ready flag.
Referenced by afec_set_data_ready_flag(), and run_afec_tc_trig_test().