Skip to content

Commit d2e430f

Browse files
committed
Fixes digitalPinToTouchChannel() for ESP32-S3
1 parent 694819d commit d2e430f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cores/esp32/esp32-hal-gpio.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@
5353
#endif
5454

5555
#include "soc/soc_caps.h"
56-
#include "soc/touch_sensor_periph.h"
5756
// It fixes lack of pin definition for S3 and for any future SoC
5857
// this function works for ESP32, ESP32-S2 and ESP32-S3 - including the C3, it will return -1 for any pin
59-
int8_t digitalPinToTouchChannel(uint8_t pin) {
58+
#if SOC_TOUCH_SENSOR_NUM > 0
59+
#include "soc/touch_sensor_periph.h"
60+
int8_t digitalPinToTouchChannel(uint8_t pin)
61+
{
6062
int8_t ret = -1;
6163
if (pin < SOC_GPIO_PIN_COUNT) {
6264
for (uint8_t i = 0; i < SOC_TOUCH_SENSOR_NUM; i++) {
@@ -68,6 +70,13 @@ int8_t digitalPinToTouchChannel(uint8_t pin) {
6870
}
6971
return ret;
7072
}
73+
#else
74+
// No Touch Sensor available
75+
int8_t digitalPinToTouchChannel(uint8_t pin)
76+
{
77+
return -1;
78+
}
79+
#endif
7180

7281
#if CONFIG_IDF_TARGET_ESP32
7382
const int8_t esp32_adc2gpio[20] = {36, 37, 38, 39, 32, 33, 34, 35, -1, -1, 4, 0, 2, 15, 13, 12, 14, 27, 25, 26};

0 commit comments

Comments
 (0)