Microchip® Advanced Software Framework

afec_example4.c File Reference

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
Value:
"\n\r-- press a key to set test feature--\n\r" \
"-- 0: Gain Test --\n\r" \
"-- 1: Dual AFEC Conversion Test --\n\r" \
"-- 2: Differential Input Test --\n\r" \
"-- 3: User Sequence Test --\n\r" \
"-- 4: Typical Application Test -- \n\r" \

Referenced by display_menu().

#define STRING_EOL   "\r"
#define STRING_HEADER
Value:
"-- AFEC Feature Test Example --\r\n" \
"-- "BOARD_NAME" --\r\n" \
"-- Compiled: "__DATE__" "__TIME__" --"STRING_EOL
#define BOARD_NAME
Definition: app_init.h:140
#define STRING_EOL
Definition: afec_example4.c:91

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 void afec0_data_ready ( void  )
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 void afec0_diff_data_ready ( void  )
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 void afec1_data_ready ( void  )
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 void afec_eoc_0 ( void  )
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 void afec_eoc_1 ( void  )
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 void configure_console ( void  )
static

Configure UART console.

References uart_rs232_options::baudrate, stdio_serial_init(), and sysclk_enable_peripheral_clock().

Referenced by main().

static void configure_tc_trigger ( void  )
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 void display_menu ( void  )
static

Display main menu.

References MENU_HEADER.

Referenced by set_afec_test().

static void print_float ( float  temp)
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().

enum afec_channel_num ch_list[]
Initial value:
=
{
AFEC_CHANNEL_1,
AFEC_CHANNEL_0,
}

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().

uint32_t g_delay_cnt
static

The delay counter value.

Referenced by main(), and set_afec_test().

uint32_t g_max_digital
static