Skip to content

Commit 5fd4a6b

Browse files
authored
Merge pull request #78 from tasmota/ADC_esp32s2_attenuation_fix
ADC esp32s2 attenuation fix for DAC pins
2 parents e5985e5 + 7cdefb1 commit 5fd4a6b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cores/esp32/esp32-hal-adc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "soc/rtc_io_reg.h"
2828
#include "esp32/rom/ets_sys.h"
2929
#include "esp_intr_alloc.h"
30+
#include "soc/dac_channel.h"
3031
#define DEFAULT_VREF 1100
3132
static esp_adc_cal_characteristics_t *__analogCharacteristics[2] = {NULL, NULL};
3233
static uint16_t __analogVRef = 0;
@@ -38,7 +39,8 @@ static uint8_t __analogVRefPin = 0;
3839
#elif CONFIG_IDF_TARGET_ESP32S3
3940
#include "esp32s3/rom/ets_sys.h"
4041
#include "soc/sens_reg.h"
41-
#include "soc/rtc_io_reg.h"
42+
#include "soc/rtc_io_reg.h
43+
#include "soc/dac_channel.h"
4244
#elif CONFIG_IDF_TARGET_ESP32C3
4345
#include "esp32c3/rom/ets_sys.h"
4446
#else
@@ -146,9 +148,9 @@ bool __adcAttachPin(uint8_t pin){
146148
#endif
147149
}
148150
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
149-
else if(pin == 25){
151+
else if(pin == DAC_CHANNEL_1_GPIO_NUM){
150152
CLEAR_PERI_REG_MASK(RTC_IO_PAD_DAC1_REG, RTC_IO_PDAC1_XPD_DAC | RTC_IO_PDAC1_DAC_XPD_FORCE);//stop dac1
151-
} else if(pin == 26){
153+
} else if(pin == DAC_CHANNEL_2_GPIO_NUM){
152154
CLEAR_PERI_REG_MASK(RTC_IO_PAD_DAC2_REG, RTC_IO_PDAC2_XPD_DAC | RTC_IO_PDAC2_DAC_XPD_FORCE);//stop dac2
153155
}
154156
#endif

0 commit comments

Comments
 (0)