SAM Peripheral Analog-to-Digital Converter Driver.
Copyright (c) 2014-2020 Microchip Technology Inc. and its subsidiaries.
#include "adc.h"
Macros | |
#define | PIN_INVALID_ADC_AIN 0xFFFFUL |
Functions | |
static void | _adc_configure_ain_pin (uint8_t index, uint32_t pin) |
uint8_t | _adc_get_inst_index (Adc *const hw) |
static enum status_code | _adc_set_config (uint8_t index, struct adc_module *const module_inst, struct adc_config *const config) |
void | adc_get_config_defaults (struct adc_config *const config) |
Initializes an ADC configuration structure to defaults. More... | |
enum status_code | adc_init (struct adc_module *const module_inst, Adc *hw, struct adc_config *config) |
Initializes the ADC. More... | |
void | adc_set_window_mode (struct adc_module *const module_inst, const enum adc_window_mode window_mode, const int16_t window_lower_value, const int16_t window_upper_value) |
Sets the ADC window mode. More... | |
Variables | |
const uint32_t | _adc_biascomp_addr [ADC_INST_NUM] = { ADC_FUSES_BIASCOMP_ADDR } |
const uint8_t | _adc_biascomp_pos [ADC_INST_NUM] = { ADC_FUSES_BIASCOMP_Pos } |
const uint32_t | _adc_biasrefbuf_addr [ADC_INST_NUM] = { ADC_FUSES_BIASREFBUF_ADDR } |
const uint8_t | _adc_biasrefbuf_pos [ADC_INST_NUM] = { ADC_FUSES_BIASREFBUF_Pos } |
const uint32_t | _adc_extchannel_msb [ADC_INST_NUM] = { ADC_EXTCHANNEL_MSB } |
const uint8_t | _adc_gclk_ids [ADC_INST_NUM] = { ADC_GCLK_ID } |
#define PIN_INVALID_ADC_AIN 0xFFFFUL |
Referenced by _adc_configure_ain_pin().
|
inlinestatic |
Configure MUX settings for the analog pins.
This function will set the given ADC input pins to the analog function in the pin mux, giving the ADC access to the analog signal.
[in] | index | Index of the ADC module instance. |
[in] | pin | AINxx pin to configure |
References _adc_extchannel_msb, Assert, system_pinmux_config::input_pull, system_pinmux_config::mux_position, NULL, PIN_INVALID_ADC_AIN, system_pinmux_get_config_defaults(), SYSTEM_PINMUX_PIN_PULL_NONE, and system_pinmux_pin_set_config().
Referenced by _adc_set_config().
uint8_t _adc_get_inst_index | ( | Adc *const | hw | ) |
Find the index of given ADC module instance.
[in] | ADC | module instance pointer. |
Referenced by adc_disable(), adc_enable(), and adc_init().
|
static |
Writes an ADC configuration to the hardware module.
Writes out a given ADC module configuration to the hardware module.
[in] | index | Index of the ADC module instance |
[out] | module_inst | Pointer to the ADC software instance struct |
[in] | config | Pointer to configuration struct |
STATUS_OK | The configuration was successful |
STATUS_ERR_INVALID_ARG | Invalid argument(s) were provided |
References _adc_biascomp_addr, _adc_biascomp_pos, _adc_biasrefbuf_addr, _adc_biasrefbuf_pos, _adc_configure_ain_pin(), _adc_extchannel_msb, _adc_gclk_ids, adc_config::accumulate_samples, ADC_ACCUMULATE_DISABLE, ADC_ACCUMULATE_SAMPLES_16, ADC_ACCUMULATE_SAMPLES_256, ADC_ACCUMULATE_SAMPLES_4, ADC_ACCUMULATE_SAMPLES_64, ADC_DIVIDE_RESULT_2, ADC_DIVIDE_RESULT_4, ADC_DIVIDE_RESULT_DISABLE, ADC_RESOLUTION_10BIT, ADC_RESOLUTION_12BIT, ADC_RESOLUTION_13BIT, ADC_RESOLUTION_14BIT, ADC_RESOLUTION_15BIT, ADC_RESOLUTION_16BIT, ADC_RESOLUTION_8BIT, ADC_RESOLUTION_CUSTOM, ADC_WINDOW_MODE_DISABLE, adc_config::clock_prescaler, adc_config::clock_source, adc_config::correction, adc_correction_config::correction_enable, adc_config::differential_mode, adc_config::divide_result, adc_config::event_action, adc_config::freerunning, adc_correction_config::gain_correction, i, adc_config::left_adjust, adc_config::negative_input, adc_correction_config::offset_correction, adc_config::on_demand, adc_config::positive_input, adc_config::positive_input_sequence_mask_enable, adc_config::reference, adc_config::reference_compensation_enable, resolution, adc_config::resolution, adc_config::run_in_standby, adc_config::sample_length, adc_config::sampling_time_compensation_enable, system_gclk_chan_config::source_generator, STATUS_ERR_INVALID_ARG, STATUS_OK, system_gclk_chan_enable(), system_gclk_chan_get_config_defaults(), system_gclk_chan_set_config(), adc_config::window, adc_window_config::window_lower_value, adc_window_config::window_mode, and adc_window_config::window_upper_value.
Referenced by adc_init().
const uint32_t _adc_biascomp_addr[ADC_INST_NUM] = { ADC_FUSES_BIASCOMP_ADDR } |
Referenced by _adc_set_config().
const uint8_t _adc_biascomp_pos[ADC_INST_NUM] = { ADC_FUSES_BIASCOMP_Pos } |
Referenced by _adc_set_config().
const uint32_t _adc_biasrefbuf_addr[ADC_INST_NUM] = { ADC_FUSES_BIASREFBUF_ADDR } |
Referenced by _adc_set_config().
const uint8_t _adc_biasrefbuf_pos[ADC_INST_NUM] = { ADC_FUSES_BIASREFBUF_Pos } |
Referenced by _adc_set_config().
const uint32_t _adc_extchannel_msb[ADC_INST_NUM] = { ADC_EXTCHANNEL_MSB } |
Referenced by _adc_configure_ain_pin(), and _adc_set_config().
const uint8_t _adc_gclk_ids[ADC_INST_NUM] = { ADC_GCLK_ID } |
Referenced by _adc_set_config().