Analog-to-Digital Converter Interface Example for SAM4L.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#include "asf.h"
Macros | |
#define | MAX_DIGITAL 4095 |
The maximal digital value. More... | |
#define | MENU_HEADER |
#define | STRING_EOL "\r" |
#define | STRING_HEADER |
#define | VOLT_REF 1000 |
Enumerations | |
enum | { TRIGGER_MODE_SOFTWARE = 0, TRIGGER_MODE_ITIMER, TRIGGER_MODE_CON } |
ADCIFE trigger modes. More... | |
Functions | |
static void | adcife_read_conv_result (void) |
Callback function for ADCIFE interrupt. More... | |
static void | configure_console (void) |
Configure UART console. More... | |
static void | display_menu (void) |
Display ADCIFE configuration menu. More... | |
int | main (void) |
Application entry point for adcife example. More... | |
static void | pdca_transfer_done (enum pdca_channel_status status) |
Callback function for PDCA interrupt. More... | |
static void | set_adc_test_mode (void) |
Set ADCIFE test mode. More... | |
static void | start_adc (void) |
Start ADC sample. More... | |
static void | start_dac (void) |
Start DAC ouput. More... | |
Variables | |
enum { ... } | e_trigger_mode |
ADCIFE trigger modes. More... | |
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... | |
struct { | |
uint8_t uc_gain_en | |
uint8_t uc_pdc_en | |
uint8_t uc_trigger_mode | |
} | g_adc_test_mode |
ADCIFE test mode structure. More... | |
volatile uint8_t | g_uc_condone_flag = 0 |
Conversion done flag. More... | |
#define MAX_DIGITAL 4095 |
The maximal digital value.
Referenced by main().
#define MENU_HEADER |
Referenced by display_menu().
#define STRING_EOL "\r" |
#define STRING_HEADER |
Referenced by main().
#define VOLT_REF 1000 |
Referenced by main().
anonymous enum |
|
static |
Callback function for ADCIFE interrupt.
References adc_clear_status(), adc_get_last_conv_value(), adc_get_status(), g_adc_inst, g_adc_sample_data, and g_uc_condone_flag.
Referenced by start_adc().
|
static |
Configure UART console.
References uart_rs232_options::baudrate, CONF_UART, CONF_UART_BAUDRATE, CONF_UART_CHAR_LENGTH, CONF_UART_PARITY, CONF_UART_STOP_BITS, and stdio_serial_init().
Referenced by main().
|
static |
Display ADCIFE configuration menu.
References g_adc_test_mode, MENU_HEADER, TRIGGER_MODE_CON, TRIGGER_MODE_ITIMER, and TRIGGER_MODE_SOFTWARE.
Referenced by main(), and set_adc_test_mode().
int main | ( | void | ) |
Application entry point for adcife example.
References adc_disable_interrupt(), ADC_SEQ_SEOC, adc_start_software_conversion(), board_init(), CONF_UART, configure_console(), delay_ms, display_menu(), g_adc_inst, g_adc_sample_data, g_adc_test_mode, g_uc_condone_flag, MAX_DIGITAL, set_adc_test_mode(), start_adc(), start_dac(), STRING_HEADER, sysclk_init(), TRIGGER_MODE_SOFTWARE, usart_read(), and VOLT_REF.
|
static |
Callback function for PDCA interrupt.
References CONFIG_ADC_PDCA_RX_CHANNEL, CONFIG_ADC_PDCA_TX_CHANNEL, g_adc_sample_data, g_uc_condone_flag, PDCA_CH_TRANSFER_COMPLETED, and pdca_channel_write_load().
Referenced by start_adc().
|
static |
Set ADCIFE test mode.
References display_menu(), g_adc_test_mode, TRIGGER_MODE_CON, TRIGGER_MODE_ITIMER, and TRIGGER_MODE_SOFTWARE.
Referenced by main().
|
static |
Start ADC sample.
Initialize ADC, set clock and timing, and set ADC to given mode.
References ADC_BIPOLAR_SINGLEENDED, adc_ch_set_config(), ADC_CLKSEL_APBCLK, adc_configure_gain(), adc_configure_itimer_period(), adc_configure_trigger(), adc_disable_interrupt(), adc_enable(), ADC_GAIN_1X, ADC_GAIN_2X, ADC_GCOMP_DIS, ADC_HWLA_DIS, adc_init(), ADC_INTERNAL_3, ADC_MUXNEG_1, ADC_MUXPOS_3, adc_pdca_set_config(), ADC_PRESCAL_DIV16, ADC_REFSEL_0, ADC_RES_12_BIT, ADC_SEQ_SEOC, adc_set_callback(), ADC_SPEED_150K, adc_start_itimer(), ADC_TRIG_CON, ADC_TRIG_INTL_TIMER, ADC_TRIG_SW, ADC_ZOOMRANGE_0, adcife_read_conv_result(), CONFIG_ADC_PDCA_RX_CHANNEL, CONFIG_ADC_PDCA_TX_CHANNEL, CONFIG_ADC_STARTUP, g_adc_inst, g_adc_test_mode, adc_ch_config::internal_timer_max_count, pdca_channel_disable_interrupt(), pdca_channel_set_callback(), pdca_transfer_done(), adc_config::prescal, adc_ch_config::seq_cfg, STATUS_OK, TRIGGER_MODE_CON, TRIGGER_MODE_ITIMER, TRIGGER_MODE_SOFTWARE, 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 main().
enum { ... } e_trigger_mode |
ADCIFE trigger modes.
struct adc_cdma_first_config g_adc_cdma_first_cfg[2] |
ADC CDMA config value.
struct adc_dev_inst g_adc_inst |
ADC instance.
Referenced by adcife_read_conv_result(), main(), and start_adc().
struct adc_pdca_config g_adc_pdca_cfg |
uint16_t g_adc_sample_data[2] |
Conversion value.
Referenced by adcife_read_conv_result(), main(), and pdca_transfer_done().
struct { ... } g_adc_test_mode |
ADCIFE test mode structure.
Referenced by display_menu(), main(), set_adc_test_mode(), and start_adc().
volatile uint8_t g_uc_condone_flag = 0 |
Conversion done flag.
Referenced by adcife_read_conv_result(), main(), and pdca_transfer_done().
uint8_t uc_gain_en |
uint8_t uc_pdc_en |
uint8_t uc_trigger_mode |