Xmega Application Note | |||||
AVR XMEGA Analog to Digital Converter driver. More...
#include <compiler.h>
#include <conf_adc.h>
#include <conf_intlvl.h>
#include <nvm.h>
#include <parts.h>
#include <sleepmgr.h>
#include <sysclk.h>
Go to the source code of this file.
Data Structures | |
struct | adc_channel_config |
ADC channel configuration. More... | |
struct | adc_config |
ADC configuration. More... | |
Defines | |
#define | CONFIG_ADC_INTLVL ADC_CH_INTLVL_LO_gc |
Default ADC channel interrupt level. | |
ADC channel masks | |
#define | ADC_CH0 (1U << 0) |
ADC channel 0. | |
Internal ADC input masks | |
#define | ADC_INT_BANDGAP ADC_BANDGAP_bm |
Bandgap reference. | |
#define | ADC_INT_TEMPSENSE ADC_TEMPREF_bm |
Temperature sensor. | |
Calibration data addresses | |
#define | ADCACAL0 offsetof(NVM_PROD_SIGNATURES_t, ADCACAL0) |
ADC A, calibration byte 0. | |
#define | ADCACAL1 offsetof(NVM_PROD_SIGNATURES_t, ADCACAL1) |
ADC A, calibration byte 1. | |
#define | ADCBCAL0 offsetof(NVM_PROD_SIGNATURES_t, ADCBCAL0) |
ADC B, calibration byte 0. | |
#define | ADCBCAL1 offsetof(NVM_PROD_SIGNATURES_t, ADCBCAL1) |
ADC B, calibration byte 1. | |
#define | TEMPSENSE0 offsetof(NVM_PROD_SIGNATURES_t, TEMPSENSE0) |
Temperature sensor calibration byte 0. | |
#define | TEMPSENSE1 offsetof(NVM_PROD_SIGNATURES_t, TEMPSENSE1) |
Temperature sensor calibration byte 1. | |
Enumerations | |
enum | adc_calibration_data { ADC_CAL_ADCA, ADC_CAL_ADCB, ADC_CAL_TEMPSENSE } |
ADC calibration data. More... | |
enum | adc_reference { ADC_REF_BANDGAP = ADC_REFSEL_INT1V_gc, ADC_REF_VCC = ADC_REFSEL_VCC_gc, ADC_REF_AREFA = ADC_REFSEL_AREFA_gc, ADC_REF_AREFB = ADC_REFSEL_AREFB_gc } |
ADC reference settings. More... | |
enum | adc_resolution { ADC_RES_8 = ADC_RESOLUTION_8BIT_gc, ADC_RES_12 = ADC_RESOLUTION_12BIT_gc, ADC_RES_12_LEFT = ADC_RESOLUTION_LEFT12BIT_gc } |
ADC resolution settings. More... | |
enum | adc_sign { ADC_SIGN_OFF, ADC_SIGN_ON = ADC_CONMODE_bm } |
ADC signedness settings. More... | |
enum | adc_trigger { ADC_TRIG_MANUAL, ADC_TRIG_FREERUN_SWEEP, ADC_TRIG_EVENT_SINGLE } |
ADC conversion trigger settings. More... | |
enum | adcch_mode { ADCCH_MODE_COMPLETE = ADC_CH_INTMODE_COMPLETE_gc, ADCCH_MODE_BELOW = ADC_CH_INTMODE_BELOW_gc, ADCCH_MODE_ABOVE = ADC_CH_INTMODE_ABOVE_gc } |
ADC channel interrupt modes. More... | |
enum | adcch_negative_input { ADCCH_NEG_PIN0, ADCCH_NEG_PIN1, ADCCH_NEG_PIN2, ADCCH_NEG_PIN3, ADCCH_NEG_PIN4, ADCCH_NEG_PIN5, ADCCH_NEG_PIN6, ADCCH_NEG_PIN7, ADCCH_NEG_NONE } |
ADC channel negative input. More... | |
enum | adcch_positive_input { ADCCH_POS_PIN0, ADCCH_POS_PIN1, ADCCH_POS_PIN2, ADCCH_POS_PIN3, ADCCH_POS_PIN4, ADCCH_POS_PIN5, ADCCH_POS_PIN6, ADCCH_POS_PIN7, ADCCH_POS_TEMPSENSE, ADCCH_POS_BANDGAP, ADCCH_POS_SCALED_VCC } |
ADC channel positive input. More... | |
Functions | |
ADC channel configuration | |
static void | adcch_disable_interrupt (struct adc_channel_config *ch_conf) |
Disable interrupts on ADC channel. | |
static void | adcch_enable_interrupt (struct adc_channel_config *ch_conf) |
Enable interrupts on ADC channel. | |
static uint8_t | adcch_get_gain_setting (uint8_t gain) |
Get ADC channel setting for specified gain. | |
void | adcch_read_configuration (ADC_t *adc, uint8_t ch, struct adc_channel_config *ch_conf) |
Read configuration from ADC channel. | |
static void | adcch_set_input (struct adc_channel_config *ch_conf, enum adcch_positive_input pos, enum adcch_negative_input neg, uint8_t gain) |
Set ADC channel input mode, multiplexing and gain. | |
static void | adcch_set_interrupt_mode (struct adc_channel_config *ch_conf, enum adcch_mode mode) |
Set ADC channel interrupt mode. | |
void | adcch_write_configuration (ADC_t *adc, uint8_t ch, const struct adc_channel_config *ch_conf) |
Write configuration to ADC channel. | |
ADC module management | |
| |
#define | adc_get_compare_value(adc) ((adc)->CMP) |
Get compare value directly from ADC. | |
#define | adc_set_compare_value(adc, val) |
Set compare value directly to ADC. | |
static void | adc_clear_interrupt_flag (ADC_t *adc, uint8_t ch_mask) |
Clear interrupt flag of ADC channel(s). | |
void | adc_disable (ADC_t *adc) |
Disable ADC. | |
void | adc_enable (ADC_t *adc) |
Enable ADC. | |
static void | adc_flush (ADC_t *adc) |
Flush the ADC. | |
static uint16_t | adc_get_calibration_data (enum adc_calibration_data cal) |
Get calibration data. | |
static uint8_t | adc_get_interrupt_flag (ADC_t *adc, uint8_t ch_mask) |
Get interrupt flag of ADC channel(s). | |
static int16_t | adc_get_signed_compare_value (ADC_t *adc) |
Get signed compare value directly from ADC. | |
static uint16_t | adc_get_unsigned_compare_value (ADC_t *adc) |
Get unsigned compare value directly from ADC. | |
bool | adc_is_enabled (ADC_t *adc) |
Check if the ADC is enabled. | |
static void | adc_start_conversion (ADC_t *adc, uint8_t ch_mask) |
Start one-shot conversion on ADC channel(s). | |
static void | adc_wait_for_interrupt_flag (ADC_t *adc, uint8_t ch_mask) |
Wait for interrupt flag of ADC channel(s). | |
ADC module configuration | |
| |
#define | adc_get_config_compare_value(conf) (conf->cmp) |
Get ADC compare value from configuration. | |
#define | adc_set_config_compare_value(conf, val) |
Set ADC compare value in configuration. | |
static void | adc_disable_internal_input (struct adc_config *conf, uint8_t int_inp) |
Disable internal ADC input. | |
static void | adc_enable_internal_input (struct adc_config *conf, uint8_t int_inp) |
Enable internal ADC input. | |
void | adc_read_configuration (ADC_t *adc, struct adc_config *conf) |
Read configuration from ADC module. | |
static void | adc_set_clock_rate (struct adc_config *conf, uint32_t clk_adc) |
Set ADC prescaler to get desired clock rate. | |
static void | adc_set_conversion_parameters (struct adc_config *conf, enum adc_sign sign, enum adc_resolution res, enum adc_reference ref) |
Set ADC conversion parameters. | |
static void | adc_set_conversion_trigger (struct adc_config *conf, enum adc_trigger trig, uint8_t nr_of_ch, uint8_t base_ev_ch) |
Set ADC conversion trigger. | |
void | adc_write_configuration (ADC_t *adc, const struct adc_config *conf) |
Write configuration to ADC module. | |
ADC channel management | |
| |
#define | adcch_get_result(adc, ch) ((&(adc)->CH0 + ch)->RES) |
Get result from ADC channel. | |
static int16_t | adcch_get_signed_result (ADC_t *adc, uint8_t ch) |
Get signed result from ADC channel. | |
static uint16_t | adcch_get_unsigned_result (ADC_t *adc, uint8_t ch) |
Get unsigned result from ADC channel. |
AVR XMEGA Analog to Digital Converter driver.
Copyright (C) 2010 Atmel Corporation. All rights reserved.
Definition in file adc.h.
Generated on Fri Oct 22 12:15:25 2010 for AVR1300 Using the Xmega ADC by ![]() |