From a9bd39de666557c9ff0daf3540a6d02afd45a05b Mon Sep 17 00:00:00 2001 From: Me No Dev Date: Fri, 16 Jul 2021 17:34:25 +0300 Subject: [PATCH] Fix pin attenuation being overwritten (#5399) Fixes: #5041 --- cores/esp32/esp32-hal-adc.c | 7 ++++++- cores/esp32/esp32-hal-adc.h | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cores/esp32/esp32-hal-adc.c b/cores/esp32/esp32-hal-adc.c index 21eb443c1..1af3ce3ae 100644 --- a/cores/esp32/esp32-hal-adc.c +++ b/cores/esp32/esp32-hal-adc.c @@ -48,6 +48,7 @@ static uint8_t __analogVRefPin = 0; static uint8_t __analogAttenuation = 3;//11db static uint8_t __analogWidth = 3;//12 bits static uint8_t __analogClockDiv = 1; +static adc_attenuation_t __pin_attenuation[SOC_GPIO_PIN_COUNT]; void __analogSetClockDiv(uint8_t clockDiv){ if(!clockDiv){ @@ -86,6 +87,9 @@ void __analogInit(){ #if CONFIG_IDF_TARGET_ESP32 __analogSetWidth(__analogWidth + 9);//in bits #endif + for(int i=0; i