From f81de7d17252e8104105c76e04323127adb675f7 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Fri, 16 Jul 2021 17:18:32 +0300 Subject: [PATCH 1/2] Fix pin attenuation being overwritten Fixes: https://github.com/espressif/arduino-esp32/issues/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 21eb443c149..c0325b5e55f 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 Date: Fri, 16 Jul 2021 17:23:47 +0300 Subject: [PATCH 2/2] Fix redeclaration error --- cores/esp32/esp32-hal-adc.c | 4 ++-- cores/esp32/esp32-hal-adc.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cores/esp32/esp32-hal-adc.c b/cores/esp32/esp32-hal-adc.c index c0325b5e55f..1af3ce3ae72 100644 --- a/cores/esp32/esp32-hal-adc.c +++ b/cores/esp32/esp32-hal-adc.c @@ -88,7 +88,7 @@ void __analogInit(){ __analogSetWidth(__analogWidth + 9);//in bits #endif for(int i=0; i