diff --git a/cores/esp32/esp32-hal-gpio.c b/cores/esp32/esp32-hal-gpio.c index 90ad1e7f36d..197f789d94d 100644 --- a/cores/esp32/esp32-hal-gpio.c +++ b/cores/esp32/esp32-hal-gpio.c @@ -33,20 +33,21 @@ #include "soc/touch_sensor_periph.h" int8_t digitalPinToTouchChannel(uint8_t pin) { - int8_t ret = -1; if (pin < SOC_GPIO_PIN_COUNT) { for (uint8_t i = 0; i < SOC_TOUCH_SENSOR_NUM; i++) { if (touch_sensor_channel_io_map[i] == pin) { - ret = i; - break; + return i; } } } - return ret; + + log_e("No touch pad on selected pin(%u)!", pin); + return -1; } #else // No Touch Sensor available int8_t digitalPinToTouchChannel(uint8_t pin) { + log_e("Touch sensor not available on this chip"); return -1; } #endif diff --git a/cores/esp32/esp32-hal-touch-ng.c b/cores/esp32/esp32-hal-touch-ng.c index 98f9052d18c..44bde091be8 100644 --- a/cores/esp32/esp32-hal-touch-ng.c +++ b/cores/esp32/esp32-hal-touch-ng.c @@ -332,7 +332,6 @@ static void __touchChannelInit(int pad) { static touch_value_t __touchRead(uint8_t pin) { int8_t pad = digitalPinToTouchChannel(pin); if (pad < 0) { - log_e(" No touch pad on selected pin!"); return 0; } @@ -360,7 +359,6 @@ static touch_value_t __touchRead(uint8_t pin) { static void __touchConfigInterrupt(uint8_t pin, void (*userFunc)(void), void *Args, bool callWithArgs, touch_value_t threshold) { int8_t pad = digitalPinToTouchChannel(pin); if (pad < 0) { - log_e(" No touch pad on selected pin!"); return; } @@ -446,7 +444,6 @@ bool touchInterruptGetLastStatus(uint8_t pin) { void touchSleepWakeUpEnable(uint8_t pin, touch_value_t threshold) { int8_t pad = digitalPinToTouchChannel(pin); if (pad < 0) { - log_e(" No touch pad on selected pin!"); return; } diff --git a/cores/esp32/esp32-hal-touch.c b/cores/esp32/esp32-hal-touch.c index 10482234de0..e27064d20e1 100644 --- a/cores/esp32/esp32-hal-touch.c +++ b/cores/esp32/esp32-hal-touch.c @@ -206,7 +206,6 @@ static void __touchChannelInit(int pad) { static touch_value_t __touchRead(uint8_t pin) { int8_t pad = digitalPinToTouchChannel(pin); if (pad < 0) { - log_e(" No touch pad on selected pin!"); return 0; } @@ -233,7 +232,6 @@ static touch_value_t __touchRead(uint8_t pin) { static void __touchConfigInterrupt(uint8_t pin, void (*userFunc)(void), void *Args, touch_value_t threshold, bool callWithArgs) { int8_t pad = digitalPinToTouchChannel(pin); if (pad < 0) { - log_e(" No touch pad on selected pin!"); return; } @@ -295,7 +293,6 @@ bool touchInterruptGetLastStatus(uint8_t pin) { void touchSleepWakeUpEnable(uint8_t pin, touch_value_t threshold) { int8_t pad = digitalPinToTouchChannel(pin); if (pad < 0) { - log_e(" No touch pad on selected pin!"); return; }