Fix wrong attenuation being set to pins (#5522)

Fixes: https://github.com/espressif/arduino-esp32/issues/5503
This commit is contained in:
Me No Dev 2021-08-11 13:05:26 +03:00 committed by GitHub
parent 5bb8177aa1
commit 5fd737925f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -104,7 +104,9 @@ void __analogSetPinAttenuation(uint8_t pin, adc_attenuation_t attenuation)
adc1_config_channel_atten(channel, attenuation);
}
__analogInit();
if((__pin_attenuation[pin] != ADC_ATTENDB_MAX) || (attenuation != __analogAttenuation)){
__pin_attenuation[pin] = attenuation;
}
}
bool __adcAttachPin(uint8_t pin){
@ -113,6 +115,7 @@ bool __adcAttachPin(uint8_t pin){
log_e("Pin %u is not ADC pin!", pin);
return false;
}
__analogInit();
int8_t pad = digitalPinToTouchChannel(pin);
if(pad >= 0){
#if CONFIG_IDF_TARGET_ESP32