16
16
#include "freertos/FreeRTOS.h"
17
17
#include "freertos/task.h"
18
18
#include "esp_attr.h"
19
- #include "soc/rtc_io_reg.h"
20
19
#include "soc/rtc_cntl_reg.h"
21
- #include "soc/sens_reg.h"
22
-
23
20
#include "driver/adc.h"
24
21
25
22
#include "esp_system.h"
26
23
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
27
24
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
28
25
#include "esp_adc_cal.h"
26
+ #include "soc/sens_reg.h"
27
+ #include "soc/rtc_io_reg.h"
29
28
#include "esp32/rom/ets_sys.h"
30
29
#include "esp_intr_alloc.h"
31
30
#define DEFAULT_VREF 1100
@@ -34,6 +33,10 @@ static uint16_t __analogVRef = 0;
34
33
static uint8_t __analogVRefPin = 0 ;
35
34
#elif CONFIG_IDF_TARGET_ESP32S2
36
35
#include "esp32s2/rom/ets_sys.h"
36
+ #include "soc/sens_reg.h"
37
+ #include "soc/rtc_io_reg.h"
38
+ #elif CONFIG_IDF_TARGET_ESP32C3
39
+ #include "esp32c3/rom/ets_sys.h"
37
40
#else
38
41
#error Target CONFIG_IDF_TARGET is not supported
39
42
#endif
@@ -51,7 +54,9 @@ void __analogSetClockDiv(uint8_t clockDiv){
51
54
clockDiv = 1 ;
52
55
}
53
56
__analogClockDiv = clockDiv ;
57
+ #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
54
58
adc_set_clk_div (__analogClockDiv );
59
+ #endif
55
60
}
56
61
57
62
void __analogSetAttenuation (adc_attenuation_t attenuation )
@@ -114,11 +119,14 @@ bool __adcAttachPin(uint8_t pin){
114
119
WRITE_PERI_REG (SENS_SAR_TOUCH_ENABLE_REG , touch );
115
120
}
116
121
#endif
117
- } else if (pin == 25 ){
122
+ }
123
+ #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
124
+ else if (pin == 25 ){
118
125
CLEAR_PERI_REG_MASK (RTC_IO_PAD_DAC1_REG , RTC_IO_PDAC1_XPD_DAC | RTC_IO_PDAC1_DAC_XPD_FORCE );//stop dac1
119
126
} else if (pin == 26 ){
120
127
CLEAR_PERI_REG_MASK (RTC_IO_PAD_DAC2_REG , RTC_IO_PDAC2_XPD_DAC | RTC_IO_PDAC2_DAC_XPD_FORCE );//stop dac2
121
128
}
129
+ #endif
122
130
123
131
pinMode (pin , ANALOG );
124
132
__analogSetPinAttenuation (pin , __analogAttenuation );
0 commit comments