Architecture specific ADC definitions and functions for ESP32. More...
Architecture specific ADC definitions and functions for ESP32.
All ESP32x SoCs have two SAR ADC units each. However, these have functionalities as well as specific properties that vary between the ESP32x SoC and therefore require different handling for each ESP32x SoC. This is already taken into account in the high-level API of the ESP-IDF. To avoid having to reimplement these specifics and the different handling, the high-level API of the ESP-IDF is used directly for the ADC peripherals.
Definition in file adc_arch.h.
Go to the source code of this file.
Enumerations | |
enum | adc_attenuation_t { ADC_ATTENUATION_0_DB = ADC_ATTEN_DB_0 , ADC_ATTENUATION_3_DB = ADC_ATTEN_DB_2_5 , ADC_ATTENUATION_6_DB = ADC_ATTEN_DB_6 , ADC_ATTENUATION_11_DB = ADC_ATTEN_DB_11 } |
Attenuations that can be set for ADC lines. More... | |
Functions | |
int | adc_set_attenuation (adc_t line, adc_atten_t atten) |
Set the attenuation for the ADC line. | |
int | adc_line_vref_to_gpio (adc_t line, gpio_t gpio) |
Output reference voltage of a ADC line to GPIO n. | |
enum adc_attenuation_t |
Attenuations that can be set for ADC lines.
Event though ESP-IDF type adc_atten_t
and ADC_ATTEN_DB_*
are used now, the adc_attenuation_t
type with constants ADC_ATTENUATION_*_DB
are kept for compatibility.
Definition at line 47 of file adc_arch.h.
int adc_line_vref_to_gpio | ( | adc_t | line, |
gpio_t | gpio | ||
) |
Output reference voltage of a ADC line to GPIO n.
The Vref of the ADC unit of the given ADC line is routed to a GPIO pin n. This allows to measure the Vref used by the ADC unit to adjusted the results of the conversions accordingly.
line | ADC line for which Vref of its ADC unit is routed to the GPIO |
gpio | GPIO to which Vref is routed (ADC2 channel GPIOs only) |
int adc_set_attenuation | ( | adc_t | line, |
adc_atten_t | atten | ||
) |
Set the attenuation for the ADC line.
Default attenuation is 11 dB.
For each ADC line, an attenuation of the input signal can be defined separately. This results in different full ranges of the measurable voltage at the input. The attenuation can be set to 0 dB, 3 dB, 6 dB and 11 dB, with 11 dB being the standard attenuation. Since an ADC input is measured against a reference voltage Vref of 1.1 V, approximately the following measurement ranges are given when using a corresponding attenuation:
Attenuation | Voltage Range | Symbol |
---|---|---|
0 dB | 0 ... 1.1V (Vref) | ADC_ATTEN_DB_0 |
2.5 dB | 0 ... 1.5V | ADC_ATTEN_DB_2_5 |
6 dB | 0 ... 2.2V | ADC_ATTEN_DB_6 |
11 dB (default) | 0 ... 3.3V | ADC_ATTEN_DB_11 |
line | ADC line for which the attenuation is set |
atten | Attenuation, see type definition of *adc_attenuation_t |