Microchip® Advanced Software Framework

adc_feature.h File Reference

SAM ADC functionality.

Copyright (c) 2014-2020 Microchip Technology Inc. and its subsidiaries.

#include <system_interrupt.h>

Data Structures

struct  adc_config
 ADC configuration structure. More...
 
struct  adc_correction_config
 Gain and offset correction configuration structure. More...
 
struct  adc_events
 ADC event enable/disable structure. More...
 
struct  adc_module
 ADC software device instance structure. More...
 
struct  adc_window_config
 Window monitor configuration structure. More...
 

Macros

#define FEATURE_ADC_SUPPORT_MASTER_SLAVE
 Output Driver Strength Selection feature support. More...
 

Typedefs

typedef void(* adc_callback_t )(struct adc_module *const module)
 Type of the callback functions. More...
 

Enumerations

enum  adc_accumulate_samples {
  ADC_ACCUMULATE_DISABLE = ADC_AVGCTRL_SAMPLENUM_1,
  ADC_ACCUMULATE_SAMPLES_2 = ADC_AVGCTRL_SAMPLENUM_2,
  ADC_ACCUMULATE_SAMPLES_4 = ADC_AVGCTRL_SAMPLENUM_4,
  ADC_ACCUMULATE_SAMPLES_8 = ADC_AVGCTRL_SAMPLENUM_8,
  ADC_ACCUMULATE_SAMPLES_16 = ADC_AVGCTRL_SAMPLENUM_16,
  ADC_ACCUMULATE_SAMPLES_32 = ADC_AVGCTRL_SAMPLENUM_32,
  ADC_ACCUMULATE_SAMPLES_64 = ADC_AVGCTRL_SAMPLENUM_64,
  ADC_ACCUMULATE_SAMPLES_128 = ADC_AVGCTRL_SAMPLENUM_128,
  ADC_ACCUMULATE_SAMPLES_256 = ADC_AVGCTRL_SAMPLENUM_256,
  ADC_ACCUMULATE_SAMPLES_512 = ADC_AVGCTRL_SAMPLENUM_512,
  ADC_ACCUMULATE_SAMPLES_1024 = ADC_AVGCTRL_SAMPLENUM_1024
}
 ADC number of accumulated samples enum. More...
 
enum  adc_callback {
  ADC_CALLBACK_READ_BUFFER,
  ADC_CALLBACK_WINDOW,
  ADC_CALLBACK_ERROR
}
 ADC callback enum. More...
 
enum  adc_clock_prescaler {
  ADC_CLOCK_PRESCALER_DIV2 = ADC_CTRLB_PRESCALER_DIV2,
  ADC_CLOCK_PRESCALER_DIV4 = ADC_CTRLB_PRESCALER_DIV4,
  ADC_CLOCK_PRESCALER_DIV8 = ADC_CTRLB_PRESCALER_DIV8,
  ADC_CLOCK_PRESCALER_DIV16 = ADC_CTRLB_PRESCALER_DIV16,
  ADC_CLOCK_PRESCALER_DIV32 = ADC_CTRLB_PRESCALER_DIV32,
  ADC_CLOCK_PRESCALER_DIV64 = ADC_CTRLB_PRESCALER_DIV64,
  ADC_CLOCK_PRESCALER_DIV128 = ADC_CTRLB_PRESCALER_DIV128,
  ADC_CLOCK_PRESCALER_DIV256 = ADC_CTRLB_PRESCALER_DIV256
}
 ADC clock prescaler enum. More...
 
enum  adc_divide_result {
  ADC_DIVIDE_RESULT_DISABLE = 0,
  ADC_DIVIDE_RESULT_2 = 1,
  ADC_DIVIDE_RESULT_4 = 2,
  ADC_DIVIDE_RESULT_8 = 3,
  ADC_DIVIDE_RESULT_16 = 4,
  ADC_DIVIDE_RESULT_32 = 5,
  ADC_DIVIDE_RESULT_64 = 6,
  ADC_DIVIDE_RESULT_128 = 7
}
 ADC possible dividers for the result register. More...
 
enum  adc_dual_mode_trigger_selection {
  ADC_DUAL_MODE_BOTH = ADC_CTRLC_DUALSEL_BOTH,
  ADC_DUAL_MODE_INTERLEAVE = ADC_CTRLC_DUALSEL_INTERLEAVE
}
 Enum for the trigger selection in dual mode. More...
 
enum  adc_event_action {
  ADC_EVENT_ACTION_DISABLED = 0,
  ADC_EVENT_ACTION_FLUSH_START_CONV = ADC_EVCTRL_FLUSHEI,
  ADC_EVENT_ACTION_START_CONV = ADC_EVCTRL_STARTEI
}
 ADC event action enum. More...
 
enum  adc_interrupt_flag {
  ADC_INTERRUPT_RESULT_READY = ADC_INTFLAG_RESRDY,
  ADC_INTERRUPT_WINDOW = ADC_INTFLAG_WINMON,
  ADC_INTERRUPT_OVERRUN = ADC_INTFLAG_OVERRUN
}
 Enum for the possible ADC interrupt flags. More...
 
enum  adc_negative_input {
  ADC_NEGATIVE_INPUT_PIN0 = ADC_INPUTCTRL_MUXNEG_AIN0,
  ADC_NEGATIVE_INPUT_PIN1 = ADC_INPUTCTRL_MUXNEG_AIN1,
  ADC_NEGATIVE_INPUT_PIN2 = ADC_INPUTCTRL_MUXNEG_AIN2,
  ADC_NEGATIVE_INPUT_PIN3 = ADC_INPUTCTRL_MUXNEG_AIN3,
  ADC_NEGATIVE_INPUT_PIN4 = ADC_INPUTCTRL_MUXNEG_AIN4,
  ADC_NEGATIVE_INPUT_PIN5 = ADC_INPUTCTRL_MUXNEG_AIN5,
  ADC_NEGATIVE_INPUT_PIN6 = ADC_INPUTCTRL_MUXNEG_AIN6,
  ADC_NEGATIVE_INPUT_PIN7 = ADC_INPUTCTRL_MUXNEG_AIN7,
  ADC_NEGATIVE_INPUT_GND = ADC_INPUTCTRL_MUXNEG(0x18u)
}
 ADC negative MUX input selection enum. More...
 
enum  adc_oversampling_and_decimation {
  ADC_OVERSAMPLING_AND_DECIMATION_DISABLE = 0,
  ADC_OVERSAMPLING_AND_DECIMATION_1BIT,
  ADC_OVERSAMPLING_AND_DECIMATION_2BIT,
  ADC_OVERSAMPLING_AND_DECIMATION_3BIT,
  ADC_OVERSAMPLING_AND_DECIMATION_4BIT
}
 ADC oversampling and decimation enum. More...
 
enum  adc_positive_input {
  ADC_POSITIVE_INPUT_PIN0 = ADC_INPUTCTRL_MUXPOS_AIN0,
  ADC_POSITIVE_INPUT_PIN1 = ADC_INPUTCTRL_MUXPOS_AIN1,
  ADC_POSITIVE_INPUT_PIN2 = ADC_INPUTCTRL_MUXPOS_AIN2,
  ADC_POSITIVE_INPUT_PIN3 = ADC_INPUTCTRL_MUXPOS_AIN3,
  ADC_POSITIVE_INPUT_PIN4 = ADC_INPUTCTRL_MUXPOS_AIN4,
  ADC_POSITIVE_INPUT_PIN5 = ADC_INPUTCTRL_MUXPOS_AIN5,
  ADC_POSITIVE_INPUT_PIN6 = ADC_INPUTCTRL_MUXPOS_AIN6,
  ADC_POSITIVE_INPUT_PIN7 = ADC_INPUTCTRL_MUXPOS_AIN7,
  ADC_POSITIVE_INPUT_PIN8 = ADC_INPUTCTRL_MUXPOS_AIN8,
  ADC_POSITIVE_INPUT_PIN9 = ADC_INPUTCTRL_MUXPOS_AIN9,
  ADC_POSITIVE_INPUT_PIN10 = ADC_INPUTCTRL_MUXPOS_AIN10,
  ADC_POSITIVE_INPUT_PIN11 = ADC_INPUTCTRL_MUXPOS_AIN11,
  ADC_POSITIVE_INPUT_PIN12 = ADC_INPUTCTRL_MUXPOS_AIN12,
  ADC_POSITIVE_INPUT_PIN13 = ADC_INPUTCTRL_MUXPOS_AIN13,
  ADC_POSITIVE_INPUT_PIN14 = ADC_INPUTCTRL_MUXPOS_AIN14,
  ADC_POSITIVE_INPUT_PIN15 = ADC_INPUTCTRL_MUXPOS_AIN15,
  ADC_POSITIVE_INPUT_PIN16 = ADC_INPUTCTRL_MUXPOS_AIN16,
  ADC_POSITIVE_INPUT_PIN17 = ADC_INPUTCTRL_MUXPOS_AIN17,
  ADC_POSITIVE_INPUT_PIN18 = ADC_INPUTCTRL_MUXPOS_AIN18,
  ADC_POSITIVE_INPUT_PIN19 = ADC_INPUTCTRL_MUXPOS_AIN19,
  ADC_POSITIVE_INPUT_PIN20 = ADC_INPUTCTRL_MUXPOS_AIN20,
  ADC_POSITIVE_INPUT_PIN21 = ADC_INPUTCTRL_MUXPOS_AIN21,
  ADC_POSITIVE_INPUT_PIN22 = ADC_INPUTCTRL_MUXPOS_AIN22,
  ADC_POSITIVE_INPUT_PIN23 = ADC_INPUTCTRL_MUXPOS_AIN23,
  ADC_POSITIVE_INPUT_TEMP = ADC_INPUTCTRL_MUXPOS_TEMP,
  ADC_POSITIVE_INPUT_BANDGAP = ADC_INPUTCTRL_MUXPOS_BANDGAP,
  ADC_POSITIVE_INPUT_SCALEDCOREVCC = ADC_INPUTCTRL_MUXPOS_SCALEDCOREVCC,
  ADC_POSITIVE_INPUT_SCALEDIOVCC = ADC_INPUTCTRL_MUXPOS_SCALEDIOVCC,
  ADC_POSITIVE_INPUT_DAC = ADC_INPUTCTRL_MUXPOS_DAC
}
 ADC positive MUX input selection enum. More...
 
enum  adc_reference {
  ADC_REFERENCE_INTREF = ADC_REFCTRL_REFSEL_INTREF,
  ADC_REFERENCE_INTVCC0 = ADC_REFCTRL_REFSEL_INTVCC0,
  ADC_REFERENCE_INTVCC1 = ADC_REFCTRL_REFSEL_INTVCC1,
  ADC_REFERENCE_AREFA = ADC_REFCTRL_REFSEL_AREFA,
  ADC_REFERENCE_INTVCC2 = ADC_REFCTRL_REFSEL_INTVCC2
}
 ADC reference voltage enum. More...
 
enum  adc_resolution {
  ADC_RESOLUTION_12BIT = ADC_CTRLC_RESSEL_12BIT,
  ADC_RESOLUTION_16BIT = ADC_CTRLC_RESSEL_16BIT,
  ADC_RESOLUTION_10BIT = ADC_CTRLC_RESSEL_10BIT,
  ADC_RESOLUTION_8BIT = ADC_CTRLC_RESSEL_8BIT,
  ADC_RESOLUTION_13BIT,
  ADC_RESOLUTION_14BIT,
  ADC_RESOLUTION_15BIT,
  ADC_RESOLUTION_CUSTOM
}
 ADC resolution enum. More...
 
enum  adc_window_mode {
  ADC_WINDOW_MODE_DISABLE = ADC_CTRLC_WINMODE_DISABLE,
  ADC_WINDOW_MODE_ABOVE_LOWER = ADC_CTRLC_WINMODE_MODE1,
  ADC_WINDOW_MODE_BELOW_UPPER = ADC_CTRLC_WINMODE_MODE2,
  ADC_WINDOW_MODE_BETWEEN = ADC_CTRLC_WINMODE_MODE3,
  ADC_WINDOW_MODE_BETWEEN_INVERTED = ADC_CTRLC_WINMODE_MODE4
}
 ADC window monitor mode enum. More...
 

Functions

static void adc_set_master_slave_mode (struct adc_module *const master_inst, struct adc_module *const slave_inst, enum adc_dual_mode_trigger_selection dualsel)
 Set ADC master and slave mode. More...
 
Positive Input Sequence
static void adc_enable_positive_input_sequence (struct adc_module *const module_inst, uint32_t positive_input_sequence_mask_enable)
 Enable positive input sequence mask for conversion. More...
 
static void adc_disable_positive_input_sequence (struct adc_module *const module_inst)
 Disable positive input in the sequence. More...
 
static void adc_get_sequence_status (struct adc_module *const module_inst, bool *is_sequence_busy, uint8_t *sequence_state)
 Get ADC sequence status. More...