From 61bca5631633e30cf5ca61da656b1529186a4aab Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 11 Jun 2025 22:43:25 -0500 Subject: [PATCH] try touch_ll_read_raw_data --- esphome/components/esp32_touch/esp32_touch.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/esphome/components/esp32_touch/esp32_touch.cpp b/esphome/components/esp32_touch/esp32_touch.cpp index 29ac51df4d..e661cbe388 100644 --- a/esphome/components/esp32_touch/esp32_touch.cpp +++ b/esphome/components/esp32_touch/esp32_touch.cpp @@ -7,6 +7,11 @@ #include +#if !defined(USE_ESP32_VARIANT_ESP32S2) && !defined(USE_ESP32_VARIANT_ESP32S3) +// For ESP32 classic, we need the low-level HAL functions for ISR-safe reads +#include "hal/touch_sensor_ll.h" +#endif + namespace esphome { namespace esp32_touch { @@ -412,9 +417,9 @@ void IRAM_ATTR ESP32TouchComponent::touch_isr_handler(void *arg) { #if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) touch_pad_read_raw_data(pad, &event.value); #else - uint16_t val = 0; - touch_pad_read(pad, &val); - event.value = val; + // For ESP32, we need to use the low-level HAL function that doesn't use semaphores + // touch_pad_read() uses a semaphore internally and cannot be called from ISR + event.value = touch_ll_read_raw_data(pad); #endif // Send to queue from ISR BaseType_t xHigherPriorityTaskWoken = pdFALSE;