Management and configuration functions for the individual ADC channels.
The API functions and definitions can be divided in two groups:
Data Structures | |
struct | adc_channel_config |
ADC channel configuration. More... | |
Macros | |
#define | CONFIG_ADC_INTLVL ADC_CH_INTLVL_LO_gc |
Default ADC channel interrupt level. More... | |
Enumerations | |
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_PAD_GND, ADCCH_NEG_INTERNAL_GND, 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_PIN8, ADCCH_POS_PIN9, ADCCH_POS_PIN10, ADCCH_POS_PIN11, ADCCH_POS_PIN12, ADCCH_POS_PIN13, ADCCH_POS_PIN14, ADCCH_POS_PIN15, ADCCH_POS_TEMPSENSE, ADCCH_POS_BANDGAP, ADCCH_POS_SCALED_VCC, ADCCH_POS_DAC } |
ADC channel positive input. More... | |
ADC channel configuration | |
void | adcch_write_configuration (ADC_t *adc, uint8_t ch_mask, const struct adc_channel_config *ch_conf) |
Write configuration to ADC channel. More... | |
void | adcch_read_configuration (ADC_t *adc, uint8_t ch_mask, struct adc_channel_config *ch_conf) |
Read configuration from ADC channel. More... | |
static uint8_t | adcch_get_gain_setting (uint8_t gain) |
Get ADC channel setting for specified gain. More... | |
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. More... | |
static void | adcch_set_pin_scan (struct adc_channel_config *ch_conf, uint8_t start_offset, uint8_t max_offset) |
Set ADC channel 0 pin scan. More... | |
static void | adcch_set_interrupt_mode (struct adc_channel_config *ch_conf, enum adcch_mode mode) |
Set ADC channel interrupt mode. More... | |
static void | adcch_enable_interrupt (struct adc_channel_config *ch_conf) |
Enable interrupts on ADC channel. More... | |
static void | adcch_disable_interrupt (struct adc_channel_config *ch_conf) |
Disable interrupts on ADC channel. More... | |
#define | ADCCH_FORCE_1X_GAINSTAGE 0xff |
Force enabling of gainstage with unity gain. More... | |
#define ADCCH_FORCE_1X_GAINSTAGE 0xff |
Force enabling of gainstage with unity gain.
Referenced by adcch_get_gain_setting().
#define CONFIG_ADC_INTLVL ADC_CH_INTLVL_LO_gc |
Default ADC channel interrupt level.
Referenced by adcch_enable_interrupt().
enum adcch_mode |
enum adcch_negative_input |
ADC channel negative input.
Identifies the signals that can be used as negative input to the ADC channels in differential mode. Some of the input signals are only available with certain gain settings, e.g., 1x gain.
enum adcch_positive_input |
ADC channel positive input.
Identifies the external and internal signals that can be used as positive input to the ADC channels.
|
inlinestatic |
Disable interrupts on ADC channel.
ch_conf | Pointer to ADC channel configuration. |
References adc_channel_config::intctrl.
Referenced by differential_signed_average(), main(), and single_ended_unsigned_average().
|
inlinestatic |
Enable interrupts on ADC channel.
ch_conf | Pointer to ADC channel configuration. |
References CONFIG_ADC_INTLVL, and adc_channel_config::intctrl.
Referenced by main().
|
inlinestatic |
Get ADC channel setting for specified gain.
Returns the setting that corresponds to specified gain.
gain | Valid gain factor for the measurement. |
References ADC_CH_GAIN_DIV2_gc, ADCCH_FORCE_1X_GAINSTAGE, and Assert.
Referenced by adcch_set_input().
void adcch_read_configuration | ( | ADC_t * | adc, |
uint8_t | ch_mask, | ||
struct adc_channel_config * | ch_conf | ||
) |
Read configuration from ADC channel.
Reads out the current configuration from the ADC channel to the specified buffer.
adc | Pointer to ADC module. |
ch_mask | Mask of ADC channel(s):
|
ch_conf | Pointer to ADC channel configuration. |
References ADC_CH0, adc_disable_clock(), adc_enable_clock(), adc_get_channel(), cpu_irq_restore(), cpu_irq_save(), adc_channel_config::ctrl, adc_channel_config::intctrl, adc_channel_config::muxctrl, and adc_channel_config::scan.
Referenced by main().
|
inlinestatic |
Set ADC channel input mode, multiplexing and gain.
Sets up an ADC channel's input mode and multiplexing according to specified input signals, as well as the gain.
ch_conf | Pointer to ADC channel configuration. |
pos | Positive input signal. |
neg | Negative input signal:
|
gain | Gain factor for measurements:
|
References ADC_CH_MUXNEG_MODE10_GND_gc, ADC_CH_MUXNEG_MODE10_INTGND_gc, ADC_CH_MUXNEG_MODE11_GND_gc, ADC_CH_MUXNEG_MODE11_INTGND_gc, adcch_get_gain_setting(), ADCCH_NEG_INTERNAL_GND, ADCCH_NEG_NONE, ADCCH_NEG_PAD_GND, ADCCH_NEG_PIN3, ADCCH_NEG_PIN4, ADCCH_NEG_PIN7, ADCCH_POS_TEMPSENSE, Assert, adc_channel_config::ctrl, and adc_channel_config::muxctrl.
Referenced by differential_signed_average(), main(), and single_ended_unsigned_average().
|
inlinestatic |
Set ADC channel interrupt mode.
ch_conf | Pointer to ADC channel configuration. |
mode | Interrupt mode to set. |
References adc_channel_config::intctrl.
Referenced by differential_signed_average(), main(), and single_ended_unsigned_average().
|
inlinestatic |
Set ADC channel 0 pin scan.
Sets the parameters for pin scan, which enables measurements on multiple, successive input pins without any reconfiguration between conversions.
Pin scan works by adding a offset to the positive MUX setting to get the current input pin. The offset is incremented for each conversion, and is reset to 0 once a conversion with the maximum offset is done.
ch_conf | Pointer to the ADC channel configuration structure |
start_offset | Initial offset to start pin scan at
|
max_offset | Maximum offset for the pin scan
|
References ADC_CH_OFFSET_gp, Assert, and adc_channel_config::scan.
void adcch_write_configuration | ( | ADC_t * | adc, |
uint8_t | ch_mask, | ||
const struct adc_channel_config * | ch_conf | ||
) |
Write configuration to ADC channel.
Writes the specified configuration to the ADC channel.
adc | Pointer to ADC module. |
ch_mask | Mask of ADC channel(s):
|
ch_conf | Pointer to ADC channel configuration. |
References ADC_CH0, adc_disable_clock(), adc_enable_clock(), adc_get_channel(), Assert, cpu_irq_restore(), cpu_irq_save(), adc_channel_config::ctrl, adc_channel_config::intctrl, adc_channel_config::muxctrl, and adc_channel_config::scan.
Referenced by differential_signed_average(), main(), and single_ended_unsigned_average().