1616#include "freertos/FreeRTOS.h"
1717#include "freertos/task.h"
1818#include "esp_attr.h"
19- #include "soc/rtc_io_reg.h"
2019#include "soc/rtc_cntl_reg.h"
21- #include "soc/sens_reg.h"
22-
2320#include "driver/adc.h"
2421
2522#include "esp_system.h"
2623#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
2724#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
2825#include "esp_adc_cal.h"
26+ #include "soc/sens_reg.h"
27+ #include "soc/rtc_io_reg.h"
2928#include "esp32/rom/ets_sys.h"
3029#include "esp_intr_alloc.h"
3130#define DEFAULT_VREF 1100
@@ -34,6 +33,10 @@ static uint16_t __analogVRef = 0;
3433static uint8_t __analogVRefPin = 0 ;
3534#elif CONFIG_IDF_TARGET_ESP32S2
3635#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"
3740#else
3841#error Target CONFIG_IDF_TARGET is not supported
3942#endif
@@ -51,7 +54,9 @@ void __analogSetClockDiv(uint8_t clockDiv){
5154 clockDiv = 1 ;
5255 }
5356 __analogClockDiv = clockDiv ;
57+ #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
5458 adc_set_clk_div (__analogClockDiv );
59+ #endif
5560}
5661
5762void __analogSetAttenuation (adc_attenuation_t attenuation )
@@ -114,11 +119,14 @@ bool __adcAttachPin(uint8_t pin){
114119 WRITE_PERI_REG (SENS_SAR_TOUCH_ENABLE_REG , touch );
115120 }
116121#endif
117- } else if (pin == 25 ){
122+ }
123+ #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
124+ else if (pin == 25 ){
118125 CLEAR_PERI_REG_MASK (RTC_IO_PAD_DAC1_REG , RTC_IO_PDAC1_XPD_DAC | RTC_IO_PDAC1_DAC_XPD_FORCE );//stop dac1
119126 } else if (pin == 26 ){
120127 CLEAR_PERI_REG_MASK (RTC_IO_PAD_DAC2_REG , RTC_IO_PDAC2_XPD_DAC | RTC_IO_PDAC2_DAC_XPD_FORCE );//stop dac2
121128 }
129+ #endif
122130
123131 pinMode (pin , ANALOG );
124132 __analogSetPinAttenuation (pin , __analogAttenuation );
0 commit comments