Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7eec41d

Browse filesBrowse files
authored
Fixes Touch Sensor for ESP32-S3 and any future SoC (espressif#6234)
* Fixes digitalPinToTouchChannel() for ESP32-S3
1 parent 9dbc908 commit 7eec41d
Copy full SHA for 7eec41d

File tree

Expand file treeCollapse file tree

2 files changed

+28
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+28
-1
lines changed

‎cores/esp32/esp32-hal-gpio.c

Copy file name to clipboardExpand all lines: cores/esp32/esp32-hal-gpio.c
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,32 @@
5252
#include "esp_intr.h"
5353
#endif
5454

55+
#include "soc/soc_caps.h"
56+
// It fixes lack of pin definition for S3 and for any future SoC
57+
// this function works for ESP32, ESP32-S2 and ESP32-S3 - including the C3, it will return -1 for any pin
58+
#if SOC_TOUCH_SENSOR_NUM > 0
59+
#include "soc/touch_sensor_periph.h"
60+
int8_t digitalPinToTouchChannel(uint8_t pin)
61+
{
62+
int8_t ret = -1;
63+
if (pin < SOC_GPIO_PIN_COUNT) {
64+
for (uint8_t i = 0; i < SOC_TOUCH_SENSOR_NUM; i++) {
65+
if (touch_sensor_channel_io_map[i] == pin) {
66+
ret = i;
67+
break;
68+
}
69+
}
70+
}
71+
return ret;
72+
}
73+
#else
74+
// No Touch Sensor available
75+
int8_t digitalPinToTouchChannel(uint8_t pin)
76+
{
77+
return -1;
78+
}
79+
#endif
80+
5581
#if CONFIG_IDF_TARGET_ESP32
5682
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};
5783
#elif CONFIG_IDF_TARGET_ESP32S2

‎cores/esp32/esp32-hal-gpio.h

Copy file name to clipboardExpand all lines: cores/esp32/esp32-hal-gpio.h
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ extern const int8_t esp32_adc2gpio[20];
8282
#define digitalPinCanOutput(pin) ((pin) < NUM_OUPUT_PINS && esp32_gpioMux[(pin)].reg)
8383
#define digitalPinToRtcPin(pin) (((pin) < SOC_GPIO_PIN_COUNT)?esp32_gpioMux[(pin)].rtc:-1)
8484
#define digitalPinToAnalogChannel(pin) (((pin) < SOC_GPIO_PIN_COUNT)?esp32_gpioMux[(pin)].adc:-1)
85-
#define digitalPinToTouchChannel(pin) (((pin) < SOC_GPIO_PIN_COUNT)?esp32_gpioMux[(pin)].touch:-1)
8685
#define digitalPinToDacChannel(pin) (((pin) == PIN_DAC1)?0:((pin) == PIN_DAC2)?1:-1)
8786

8887
void pinMode(uint8_t pin, uint8_t mode);
@@ -93,6 +92,8 @@ void attachInterrupt(uint8_t pin, void (*)(void), int mode);
9392
void attachInterruptArg(uint8_t pin, void (*)(void*), void * arg, int mode);
9493
void detachInterrupt(uint8_t pin);
9594

95+
int8_t digitalPinToTouchChannel(uint8_t pin);
96+
9697
#ifdef __cplusplus
9798
}
9899
#endif

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.