[−][src]Function esp_idf_sys::adc2_config_channel_atten
pub unsafe extern "C" fn adc2_config_channel_atten(
channel: adc2_channel_t,
atten: adc_atten_t
) -> esp_err_t
@brief Configure the ADC2 channel, including setting attenuation.
@note This function also configures the input GPIO pin mux to
connect it to the ADC2 channel. It must be called before calling
adc2_get_raw()
for this channel.
The default ADC full-scale voltage is 1.1V. To read higher voltages (up to the pin maximum voltage, usually 3.3V) requires setting >0dB signal attenuation for that ADC channel.
When VDD_A is 3.3V:
- 0dB attenuaton (ADC_ATTEN_0db) gives full-scale voltage 1.1V
- 2.5dB attenuation (ADC_ATTEN_2_5db) gives full-scale voltage 1.5V
- 6dB attenuation (ADC_ATTEN_6db) gives full-scale voltage 2.2V
- 11dB attenuation (ADC_ATTEN_11db) gives full-scale voltage 3.9V (see note below)
@note The full-scale voltage is the voltage corresponding to a maximum reading (depending on ADC2 configured bit width, this value is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits.)
@note At 11dB attenuation the maximum voltage is limited by VDD_A, not the full scale voltage.
@param channel ADC2 channel to configure @param atten Attenuation level
@return - ESP_OK success - ESP_ERR_INVALID_ARG Parameter error