Unverified Commit 5fd73792 authored by Me No Dev's avatar Me No Dev Committed by GitHub

Fix wrong attenuation being set to pins (#5522)

Fixes: https://github.com/espressif/arduino-esp32/issues/5503
parent 5bb8177a
...@@ -104,7 +104,9 @@ void __analogSetPinAttenuation(uint8_t pin, adc_attenuation_t attenuation) ...@@ -104,7 +104,9 @@ void __analogSetPinAttenuation(uint8_t pin, adc_attenuation_t attenuation)
adc1_config_channel_atten(channel, attenuation); adc1_config_channel_atten(channel, attenuation);
} }
__analogInit(); __analogInit();
if((__pin_attenuation[pin] != ADC_ATTENDB_MAX) || (attenuation != __analogAttenuation)){
__pin_attenuation[pin] = attenuation; __pin_attenuation[pin] = attenuation;
}
} }
bool __adcAttachPin(uint8_t pin){ bool __adcAttachPin(uint8_t pin){
...@@ -113,6 +115,7 @@ bool __adcAttachPin(uint8_t pin){ ...@@ -113,6 +115,7 @@ bool __adcAttachPin(uint8_t pin){
log_e("Pin %u is not ADC pin!", pin); log_e("Pin %u is not ADC pin!", pin);
return false; return false;
} }
__analogInit();
int8_t pad = digitalPinToTouchChannel(pin); int8_t pad = digitalPinToTouchChannel(pin);
if(pad >= 0){ if(pad >= 0){
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment