Function esp_idf_hal::sys::adc2_get_raw
source · pub unsafe extern "C" fn adc2_get_raw(
channel: u32,
width_bit: u32,
raw_out: *mut i32,
) -> i32
Expand description
@brief Take an ADC2 reading on a single channel
@note ESP32: When the power switch of SARADC1, SARADC2, HALL sensor and AMP sensor is turned on, the input of GPIO36 and GPIO39 will be pulled down for about 80ns. When enabling power for any of these peripherals, ignore input from GPIO36 and GPIO39. Please refer to section 3.11 of ‘ECO_and_Workarounds_for_Bugs_in_ESP32’ for the description of this issue. As a workaround, call sar_periph_ctrl_adc_oneshot_power_acquire() in the app. This will result in higher power consumption (by ~1mA), but will remove the glitches on GPIO36 and GPIO39.
@note ESP32:
For a given channel, adc2_config_channel_atten()
must be called before the first time this function is called. If Wi-Fi is started via esp_wifi_start()
, this
function will always fail with ESP_ERR_TIMEOUT
.
@note ESP32-S2: ADC2 support hardware arbiter. The arbiter is to improve the use efficiency of ADC2. After the control right is robbed by the high priority, the low priority controller will read the invalid ADC2 data. Default priority: Wi-Fi > RTC > Digital;
@param channel ADC2 channel to read @param width_bit Bit capture width for ADC2 @param raw_out the variable to hold the output data.
@return - ESP_OK if success - ESP_ERR_TIMEOUT ADC2 is being used by other controller and the request timed out. - ESP_ERR_INVALID_STATE The controller status is invalid. Please try again.