Microchip® Advanced Software Framework

adcife_example.c File Reference

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
Value:
"\n\r" \
"===================================================\n\r" \
"Menu: press a key to change the configuration.\n\r" \
"---------------------------------------------------------\n\r"

Referenced by display_menu().

#define STRING_EOL   "\r"
#define STRING_HEADER
Value:
"-- ADCIFE Example --\r\n" \
"-- "BOARD_NAME" --\r\n" \
"-- Compiled: "__DATE__" "__TIME__" --"STRING_EOL
#define STRING_EOL
Definition: adcife_example.c:100
#define BOARD_NAME
Name string macro.
Definition: sam4l8_xplained_pro.h:86

Referenced by main().

#define VOLT_REF   1000

Referenced by main().

anonymous enum

ADCIFE trigger modes.

Enumerator
TRIGGER_MODE_SOFTWARE 
TRIGGER_MODE_ITIMER 
TRIGGER_MODE_CON 

static void adcife_read_conv_result ( void  )
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 void configure_console ( void  )
static
static void display_menu ( void  )
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().

static void pdca_transfer_done ( enum pdca_channel_status  status)
static
static void set_adc_test_mode ( void  )
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 void start_dac ( void  )
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
Initial value:
= {
.wm = false,
.nb_channels = 2,
.buffer = g_adc_sample_data,
.pdc_rx_channel = CONFIG_ADC_PDCA_RX_CHANNEL,
.pdc_tx_channel = CONFIG_ADC_PDCA_TX_CHANNEL,
.cdma_cfg = (void *)&g_adc_cdma_first_cfg[0]
}
struct adc_cdma_first_config g_adc_cdma_first_cfg[2]
ADC CDMA config value.
Definition: adcife_example.c:120
#define CONFIG_ADC_PDCA_RX_CHANNEL
Definition: conf_adcife.h:46
#define CONFIG_ADC_PDCA_TX_CHANNEL
Definition: conf_adcife.h:47
uint16_t g_adc_sample_data[2]
Conversion value.
Definition: adcife_example.c:114
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