megaAVR ADC driver for ATmegaxx4, ATmegaxx4/A/P/PA, ATmegaxx0/xx1, ATmegaxx8 ATmegaxxxRF and ATmegaxx8A/P/PA.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | ADC_ADTS_SOURCE_MASK (1 << ADTS2 | 1 << ADTS1 | 1 << ADTS0) |
#define | ADC_MUX_MASK (1 << MUX3 | 1 << MUX2 | 1 << MUX1 | 1 << MUX0) |
#define | ADC_PRESCALER_MASK (1 << ADPS2 | 1 << ADPS1 | 1 << ADPS0) |
#define | ADC_VREF_MASK (1 << REFS1 | 1 << REFS0) |
Enumerations | |
enum | adc_adjustment { ADC_ADJUSTMENT_RIGHT = 0, ADC_ADJUSTMENT_LEFT = (1 << ADLAR) } |
enum | adc_auto_trigger_source { ADC_AUTOTRIGGER_SOURCE_FREERUNNING = (0x0 << ADTS0), ADC_AUTOTRIGGER_SOURCE_ANALOG_COMPARATOR = (0x1 << ADTS0), ADC_AUTOTRIGGER_SOURCE_EIR0 = (0x2 << ADTS0), ADC_AUTOTRIGGER_SOURCE_TC0_COMPARE = (0x3 << ADTS0), ADC_AUTOTRIGGER_SOURCE_TC0_OVERFLOW = (0x4 << ADTS0), ADC_AUTOTRIGGER_SOURCE_TC1_COMPARE_B = (0x5 << ADTS0), ADC_AUTOTRIGGER_SOURCE_TC1_OVERFLOW = (0x6 << ADTS0), ADC_AUTOTRIGGER_SOURCE_TC1_CAPTURE = (0x7 << ADTS0) } |
ADC Auto Trigger sources. More... | |
enum | adc_prescaler { ADC_PRESCALER_DIV2 = (0x1 << ADPS0), ADC_PRESCALER_DIV4 = (0x2 << ADPS0), ADC_PRESCALER_DIV8 = (0x3 << ADPS0), ADC_PRESCALER_DIV16 = (0x4 << ADPS0), ADC_PRESCALER_DIV32 = (0x5 << ADPS0), ADC_PRESCALER_DIV64 = (0x6 << ADPS0), ADC_PRESCALER_DIV128 = (0x7 << ADPS0) } |
ADC prescaler settings. More... | |
Functions | |
static bool | adc_conversion_is_complete (void) |
Poll ADC conversion complete interrupt flag. More... | |
static void | adc_disable (void) |
static void | adc_disable_autotrigger (void) |
static void | adc_disable_interrupt (void) |
static void | adc_enable (void) |
static void | adc_enable_autotrigger (void) |
static void | adc_enable_interrupt (void) |
static uint16_t | adc_get_data_10bit (void) |
static uint8_t | adc_get_data_8bit (void) |
static void | adc_init (enum adc_prescaler prescaler) |
ADC initialization. More... | |
static uint16_t | adc_read_10bit (enum adc_mux_setting input, enum adc_voltage_reference vref) |
Blocking ADC conversion with 10-bit result. More... | |
static uint8_t | adc_read_8bit (enum adc_mux_setting input, enum adc_voltage_reference vref) |
Blocking ADC conversion with 8-bit result. More... | |
static void | adc_set_autotrigger_source (enum adc_auto_trigger_source trg) |
Set ADC Auto Trigger source. More... | |
static void | adc_set_mux (enum adc_mux_setting input) |
Select source from ADC input mux. More... | |
static void | adc_set_prescaler (enum adc_prescaler prescaler) |
Set ADC clock prescaler. More... | |
static void | adc_set_voltage_reference (enum adc_voltage_reference vref) |
Set the ADC voltage reference. More... | |
static void | adc_start_conversion (void) |
Optimized functions for register accesses | |
These functions are for cases where you do not want the overhead of masking out bitfields before updating the register value. These will only do a write to the register instead of a read-modify-write. | |
static void | adc_set_admux (uint8_t regval) |
Set voltage reference, mux and adjustment bits in admux register. More... | |