Microchip® Advanced Software Framework

afec_example2.c File Reference

AFEC enhanced resolution mode 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 afec_data_ready (void)
 AFEC interrupt callback function. More...
 
static void configure_console (void)
 Configure UART console. More...
 
static void display_menu (void)
 Display main menu. More...
 
int main (void)
 Application entry point. More...
 
static void set_afec_resolution (void)
 Set AFEC resolution mode. More...
 

Variables

struct {
   bool   is_done
 
   uint32_t   value
 
g_afec_sample_data
 AFEC sample data. 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_resolution().

#define MENU_HEADER
Value:
"\n\r-- press a key to change the resolution mode--\n\r" \
"-- n: Normal Resolution Mode--\n\r" \
"-- e: Enhanced Resolution Mode--\n\r" \
"-- q: Quit Configuration--\n\r"

Referenced by display_menu().

#define STRING_EOL   "\r"
#define STRING_HEADER
Value:
"-- AFEC Enhanced Resolution 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_example2.c:93

Referenced by main().

#define VOLT_REF   (3300)

Reference voltage for AFEC in mv.

Referenced by main().

static void afec_data_ready ( void  )
static

AFEC interrupt callback function.

References afec_get_latest_value(), and g_afec_sample_data.

Referenced by main().

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

Display main menu.

References MENU_HEADER.

Referenced by main(), and set_afec_resolution().

static void set_afec_resolution ( void  )
static

Set AFEC resolution mode.

References AFEC_12_BITS, AFEC_16_BITS, afec_set_resolution(), display_menu(), g_max_digital, MAX_DIGITAL_12_BIT, and uart_read().

Referenced by main().

struct { ... } g_afec_sample_data

AFEC sample data.

Referenced by afec_data_ready(), and main().

uint32_t g_max_digital
static

The maximal digital value.

Referenced by main(), and set_afec_resolution().

bool is_done