ADC threshold wakeup example for SAM.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | BOARD_ADC_FREQ (6000000) |
ADC channel for potentiometer. More... | |
#define | MENU_HEADER |
#define | STRING_EOL "\r" |
The maximal digital value. More... | |
#define | STRING_HEADER |
#define | VOLT_REF (3300) |
Reference voltage for ADC, in mv. More... | |
Functions | |
void | ADC_Handler (void) |
static void | configure_console (void) |
static void | configure_tc0 (void) |
Configure Timer Counter 0 (TC0) to generate an interrupt every second. More... | |
static void | display_info (void) |
Display current information,including voltage on potentiometer, thresholds and comparison mode. More... | |
static void | display_menu (void) |
Display main menu. More... | |
static void | enter_asleep (void) |
Enter sleep mode using WFI instruction. More... | |
static uint32_t | f_to_int (float x) |
Transform float data type to int. More... | |
static uint8_t | get_comparison_mode (void) |
Get comparison mode. More... | |
static int16_t | get_voltage (void) |
Get voltage from user input (range from 0 to 3300 mv). More... | |
int | main (void) |
Example entry point. More... | |
Variables | |
static uint16_t | gs_us_high_threshold = 0 |
High threshold. More... | |
static uint16_t | gs_us_low_threshold = 0 |
Low threshold. More... | |
#define BOARD_ADC_FREQ (6000000) |
ADC channel for potentiometer.
ADC clock
#define MENU_HEADER |
Referenced by display_menu().
#define STRING_EOL "\r" |
The maximal digital value.
#define STRING_HEADER |
Referenced by main().
#define VOLT_REF (3300) |
Reference voltage for ADC, in mv.
Referenced by ADC_Handler(), display_info(), get_voltage(), and main().
void ADC_Handler | ( | void | ) |
|
static |
References uart_rs232_options::baudrate, stdio_serial_init(), and sysclk_enable_peripheral_clock().
Referenced by main().
|
static |
Configure Timer Counter 0 (TC0) to generate an interrupt every second.
This interrupt will be used to display the number of bytes received on the UART.
References pmc_enable_periph_clk(), and tc_init().
Referenced by main().
|
static |
Display current information,including voltage on potentiometer, thresholds and comparison mode.
References adc_get_channel_value(), f_to_int(), gs_us_high_threshold, gs_us_low_threshold, MAX_DIGITAL, and VOLT_REF.
Referenced by main().
|
static |
|
static |
Enter sleep mode using WFI instruction.
Enable interrupt first and then disable it after wake up.
References adc_enable_interrupt(), and adc_get_status().
Referenced by main().
|
static |
Transform float data type to int.
Referenced by display_info(), and main().
|
static |
|
static |
Get voltage from user input (range from 0 to 3300 mv).
References uart_read(), and VOLT_REF.
Referenced by main().
int main | ( | void | ) |
Example entry point.
Initialize ADC to 12-bit, enable channel "ADC_CHANNEL_POTENTIOMETER", then enable hardware trigger with TIOA0 every second. Finally, start conversion.
References adc_enable_channel(), adc_get_channel_value(), ADC_TRIG_TIO_CH_0, board_init(), configure_console(), configure_tc0(), display_info(), display_menu(), enter_asleep(), f_to_int(), get_comparison_mode(), get_voltage(), gs_us_high_threshold, gs_us_low_threshold, MAX_DIGITAL, pmc_enable_periph_clk(), STRING_HEADER, sysclk_get_cpu_hz(), sysclk_init(), tc_start(), uart_read(), and VOLT_REF.
|
static |
High threshold.
Referenced by ADC_Handler(), display_info(), and main().
|
static |
Low threshold.
Referenced by ADC_Handler(), display_info(), and main().