@@ -27,6 +27,16 @@ extern "C" {
2727#include "esp32-hal.h"
2828#include "soc/gpio_caps.h"
2929
30+ #if (CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 )
31+ #define NUM_OUPUT_PINS 45
32+ #define PIN_DAC1 17
33+ #define PIN_DAC2 18
34+ #else
35+ #define NUM_OUPUT_PINS 34
36+ #define PIN_DAC1 25
37+ #define PIN_DAC2 26
38+ #endif
39+
3040#define LOW 0x0
3141#define HIGH 0x1
3242
@@ -68,12 +78,12 @@ typedef struct {
6878extern const esp32_gpioMux_t esp32_gpioMux [GPIO_PIN_COUNT ];
6979extern const int8_t esp32_adc2gpio [20 ];
7080
71- #define digitalPinIsValid (pin ) ((pin) < 40 && esp32_gpioMux[(pin)].reg)
72- #define digitalPinCanOutput (pin ) ((pin) < 34 && esp32_gpioMux[(pin)].reg)
73- #define digitalPinToRtcPin (pin ) (((pin) < 40 )?esp32_gpioMux[(pin)].rtc:-1)
74- #define digitalPinToAnalogChannel (pin ) (((pin) < 40 )?esp32_gpioMux[(pin)].adc:-1)
75- #define digitalPinToTouchChannel (pin ) (((pin) < 40 )?esp32_gpioMux[(pin)].touch:-1)
76- #define digitalPinToDacChannel (pin ) (((pin) == 25 )?0:((pin) == 26 )?1:-1)
81+ #define digitalPinIsValid (pin ) ((pin) < GPIO_PIN_COUNT && esp32_gpioMux[(pin)].reg)
82+ #define digitalPinCanOutput (pin ) ((pin) < NUM_OUPUT_PINS && esp32_gpioMux[(pin)].reg)
83+ #define digitalPinToRtcPin (pin ) (((pin) < GPIO_PIN_COUNT )?esp32_gpioMux[(pin)].rtc:-1)
84+ #define digitalPinToAnalogChannel (pin ) (((pin) < GPIO_PIN_COUNT )?esp32_gpioMux[(pin)].adc:-1)
85+ #define digitalPinToTouchChannel (pin ) (((pin) < GPIO_PIN_COUNT )?esp32_gpioMux[(pin)].touch:-1)
86+ #define digitalPinToDacChannel (pin ) (((pin) == PIN_DAC1 )?0:((pin) == PIN_DAC2 )?1:-1)
7787
7888void pinMode (uint8_t pin , uint8_t mode );
7989void digitalWrite (uint8_t pin , uint8_t val );
0 commit comments