Microchip® Advanced Software Framework

adcife_wm_example.c File Reference

ADCIFE Window Monitor example for SAM4L.

Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.

#include "asf.h"
#include "stdio_serial.h"
#include "conf_board.h"

Macros

#define MAX_DIGITAL   (4095)
 The maximal digital value. More...
 
#define MENU_HEADER
 
#define STRING_EOL   "\r"
 
#define STRING_HEADER
 
#define VDDANA   3300
 
#define VOLT_REF   1000
 

Functions

static void adcife_wm_handler (void)
 Callback function for ADCIFE interrupt. More...
 
static void configure_console (void)
 Configure UART console. More...
 
static void display_info (void)
 Display current information,including voltage on division resistor, thresholds and window monitor mode. More...
 
static void display_menu (void)
 Display main menu. More...
 
static uint32_t f_to_int (float x)
 Transform float data type to int. More...
 
static int16_t get_voltage (void)
 Get voltage from user input (range from 0 to 3300 mv). More...
 
static uint8_t get_wm_mode (void)
 Get window monitor mode. More...
 
int main (void)
 Example entry point. More...
 
static void start_dac (void)
 Start DAC ouput. More...
 

Variables

struct adc_dev_inst g_adc_inst
 ADC instance. More...
 
static uint16_t gs_us_high_threshold = 0
 High threshold. More...
 
static uint16_t gs_us_low_threshold = 0
 Low threshold. More...
 

#define MAX_DIGITAL   (4095)

The maximal digital value.

Referenced by adcife_wm_handler(), display_info(), and main().

#define MENU_HEADER
Value:
"\n\r-- Menu Choices for this example--\n\r" \
"-- 0: Modify DAC output value--\n\r" \
"-- 1: Modify low threshold.--\n\r" \
"-- 2: Modify high threshold.--\n\r" \
"-- 3: Choose comparison mode.--\n\r" \
"-- i: Display ADCIFE information.--\n\r" \
"-- m: Display this main menu.--\n\r"

Referenced by display_menu().

#define STRING_EOL   "\r"
#define STRING_HEADER
Value:
"-- ADCIFE Window Monitor Example --\r\n" \
"-- "BOARD_NAME" --\r\n" \
"-- Compiled: "__DATE__" "__TIME__" --"STRING_EOL
#define BOARD_NAME
Definition: inc/app_init.h:140
#define STRING_EOL
Definition: adcife_wm_example.c:108

Referenced by main().

#define VDDANA   3300

Referenced by main().

#define VOLT_REF   1000

static void adcife_wm_handler ( void  )
static
static void configure_console ( void  )
static

Configure UART console.

References uart_rs232_options::baudrate, and stdio_serial_init().

Referenced by main().

static void display_info ( void  )
static

Display current information,including voltage on division resistor, thresholds and window monitor mode.

References adc_get_last_conv_value(), adc_get_wm_mode(), f_to_int(), g_adc_inst, gs_us_high_threshold, gs_us_low_threshold, MAX_DIGITAL, and VOLT_REF.

Referenced by main().

static void display_menu ( void  )
static

Display main menu.

References MENU_HEADER.

Referenced by main().

static uint32_t f_to_int ( float  x)
static

Transform float data type to int.

Referenced by display_info(), and main().

static int16_t get_voltage ( void  )
static

Get voltage from user input (range from 0 to 3300 mv).

References VOLT_REF.

Referenced by main().

static uint8_t get_wm_mode ( void  )
static

Get window monitor mode.

References adc_get_wm_mode(), and g_adc_inst.

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

uint16_t gs_us_high_threshold = 0
static

High threshold.

Referenced by adcife_wm_handler(), display_info(), and main().

uint16_t gs_us_low_threshold = 0
static

Low threshold.

Referenced by adcife_wm_handler(), display_info(), and main().