AFEC feature test example for SAM.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "asf.h"
Macros | |
#define | MAX_DIGITAL_12_BIT (4095UL) |
The maximal digital value. More... | |
#define | MENU_HEADER |
#define | STRING_EOL "\r" |
#define | STRING_HEADER |
#define | VOLT_REF (3300) |
Reference voltage for AFEC in mv. More... | |
Functions | |
static void | afec0_data_ready (void) |
AFEC0 DRDY interrupt callback function. More... | |
static void | afec0_diff_data_ready (void) |
AFEC0 DRDY interrupt callback function. More... | |
static void | afec1_data_ready (void) |
AFEC1 DRDY interrupt callback function. More... | |
static void | afec_eoc_0 (void) |
AFEC0 EOC0 interrupt callback function. More... | |
static void | afec_eoc_1 (void) |
AFEC0 EOC1 interrupt callback function. More... | |
static void | configure_console (void) |
Configure UART console. More... | |
static void | configure_tc_trigger (void) |
Configure to trigger AFEC by TIOA output of timer. More... | |
static void | display_menu (void) |
Display main menu. More... | |
int | main (void) |
Application entry point. More... | |
static void | print_float (float temp) |
Simple function to replace printf with float formatting. More... | |
static void | set_afec_test (void) |
Set AFEC test mode. More... | |
Variables | |
enum afec_channel_num | ch_list [] |
float | g_afec0_sample_data |
AFEC sample data. More... | |
float | g_afec1_sample_data |
static uint32_t | g_delay_cnt |
The delay counter value. More... | |
static uint32_t | g_max_digital |
The maximal digital value. More... | |
#define MAX_DIGITAL_12_BIT (4095UL) |
The maximal digital value.
Referenced by main(), and set_afec_test().
#define MENU_HEADER |
Referenced by display_menu().
#define STRING_EOL "\r" |
#define STRING_HEADER |
Referenced by main().
#define VOLT_REF (3300) |
Reference voltage for AFEC in mv.
Referenced by afec0_data_ready(), afec0_diff_data_ready(), afec1_data_ready(), afec_eoc_0(), and afec_eoc_1().
|
static |
AFEC0 DRDY interrupt callback function.
References afec_get_latest_value(), g_afec0_sample_data, g_max_digital, print_float(), and VOLT_REF.
Referenced by set_afec_test().
|
static |
AFEC0 DRDY interrupt callback function.
References afec_get_latest_value(), g_afec0_sample_data, g_max_digital, print_float(), and VOLT_REF.
Referenced by set_afec_test().
|
static |
AFEC1 DRDY interrupt callback function.
References afec_get_latest_value(), g_afec1_sample_data, g_max_digital, print_float(), and VOLT_REF.
Referenced by set_afec_test().
|
static |
AFEC0 EOC0 interrupt callback function.
References afec_channel_get_value(), g_afec0_sample_data, g_max_digital, print_float(), and VOLT_REF.
Referenced by set_afec_test().
|
static |
AFEC0 EOC1 interrupt callback function.
References afec_channel_get_value(), g_afec1_sample_data, g_max_digital, print_float(), and VOLT_REF.
Referenced by set_afec_test().
|
static |
Configure UART console.
References uart_rs232_options::baudrate, stdio_serial_init(), and sysclk_enable_peripheral_clock().
Referenced by main().
|
static |
Configure to trigger AFEC by TIOA output of timer.
References afec_set_trigger(), AFEC_TRIG_TIO_CH_0, pmc_enable_periph_clk(), sysclk_get_cpu_hz(), tc_find_mck_divisor(), tc_init(), and tc_start().
Referenced by set_afec_test().
|
static |
int main | ( | void | ) |
Application entry point.
References afec_disable_interrupt(), afec_start_software_conversion(), board_init(), configure_console(), delay_ms, g_afec0_sample_data, g_afec1_sample_data, g_delay_cnt, g_max_digital, MAX_DIGITAL_12_BIT, set_afec_test(), STRING_HEADER, sysclk_init(), tc_stop(), and uart_read().
|
static |
Simple function to replace printf with float formatting.
Referenced by afec0_data_ready(), afec0_diff_data_ready(), afec1_data_ready(), afec_eoc_0(), and afec_eoc_1().
|
static |
Set AFEC test mode.
References afec0_data_ready(), afec0_diff_data_ready(), afec1_data_ready(), AFEC_16_BITS, afec_ch_get_config_defaults(), afec_ch_set_config(), afec_channel_enable(), afec_channel_set_analog_offset(), afec_configure_sequence(), afec_enable(), afec_eoc_0(), afec_eoc_1(), AFEC_GAINVALUE_3, afec_get_config_defaults(), afec_get_interrupt_status(), afec_init(), afec_set_callback(), afec_set_trigger(), AFEC_TRIG_SW, ch_list, configure_tc_trigger(), afec_ch_config::diff, display_menu(), g_delay_cnt, g_max_digital, afec_ch_config::gain, MAX_DIGITAL_12_BIT, afec_config::resolution, and uart_read().
Referenced by main().
enum afec_channel_num ch_list[] |
Referenced by set_afec_test().
float g_afec0_sample_data |
AFEC sample data.
Referenced by afec0_data_ready(), afec0_diff_data_ready(), afec_eoc_0(), and main().
float g_afec1_sample_data |
Referenced by afec1_data_ready(), afec_eoc_1(), and main().
|
static |
The delay counter value.
Referenced by main(), and set_afec_test().
|
static |
The maximal digital value.
Referenced by afec0_data_ready(), afec0_diff_data_ready(), afec1_data_ready(), afec_eoc_0(), afec_eoc_1(), main(), and set_afec_test().