From ccf6d53524abd0035f3479b771751b81eba0ad56 Mon Sep 17 00:00:00 2001 From: Hu Rui Date: Fri, 15 May 2026 17:31:48 +0800 Subject: [PATCH] feat(touch): support touch sleep on ESP32-S31 Note: deep sleep wake-up currently has issue --- components/soc/esp32s31/include/soc/Kconfig.soc_caps.in | 2 +- components/soc/esp32s31/include/soc/soc_caps.h | 2 +- docs/en/api-reference/peripherals/cap_touch_sens.rst | 6 ++++++ docs/zh_CN/api-reference/peripherals/cap_touch_sens.rst | 6 ++++++ .../peripherals/touch_sensor/touch_sens_sleep/README.md | 8 ++++++-- .../touch_sensor/touch_sens_sleep/main/Kconfig.projbuild | 1 + 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in index 4f20d6895c2..a26a2318be0 100644 --- a/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in @@ -1153,7 +1153,7 @@ config SOC_TOUCH_MAX_CHAN_ID config SOC_TOUCH_SUPPORT_SLEEP_WAKEUP bool - default n + default y config SOC_TOUCH_SUPPORT_BENCHMARK bool diff --git a/components/soc/esp32s31/include/soc/soc_caps.h b/components/soc/esp32s31/include/soc/soc_caps.h index 558c6d6b729..2516c60be4d 100644 --- a/components/soc/esp32s31/include/soc/soc_caps.h +++ b/components/soc/esp32s31/include/soc/soc_caps.h @@ -461,7 +461,7 @@ #define SOC_TOUCH_MAX_CHAN_ID (13) /*!< Touch maximum channel number */ /* Touch Sensor Features */ -#define SOC_TOUCH_SUPPORT_SLEEP_WAKEUP (0) /*!< Touch sensor supports sleep awake */ +#define SOC_TOUCH_SUPPORT_SLEEP_WAKEUP (1) /*!< Touch sensor supports sleep awake */ #define SOC_TOUCH_SUPPORT_BENCHMARK (1) /*!< Touch sensor supports benchmark configuration */ #define SOC_TOUCH_SUPPORT_WATERPROOF (1) /*!< Touch sensor supports waterproof */ #define SOC_TOUCH_SUPPORT_PROX_SENSING (1) /*!< Touch sensor supports proximity sensing */ diff --git a/docs/en/api-reference/peripherals/cap_touch_sens.rst b/docs/en/api-reference/peripherals/cap_touch_sens.rst index 580bda0eb61..feb4325116b 100644 --- a/docs/en/api-reference/peripherals/cap_touch_sens.rst +++ b/docs/en/api-reference/peripherals/cap_touch_sens.rst @@ -446,6 +446,12 @@ Call :cpp:func:`touch_channel_read_data` to read the data with different types. // Register the deep sleep wake-up ESP_ERROR_CHECK(touch_sensor_config_sleep_wakeup(sens_handle, &deep_slp_cfg)); + .. only:: esp32s31 + + .. note:: + + ESP32-S31 touch sensor wake-up from deep sleep may fail in some cases. Increasing ``meas_interval_us`` in :cpp:type:`touch_sensor_config_t` can help mitigate this issue. + .. only:: SOC_TOUCH_SUPPORT_DENOISE_CHAN .. _touch-denoise-chan: diff --git a/docs/zh_CN/api-reference/peripherals/cap_touch_sens.rst b/docs/zh_CN/api-reference/peripherals/cap_touch_sens.rst index eb3ec0e62cd..ebe1ad682a4 100644 --- a/docs/zh_CN/api-reference/peripherals/cap_touch_sens.rst +++ b/docs/zh_CN/api-reference/peripherals/cap_touch_sens.rst @@ -446,6 +446,12 @@ // 注册 Deep-sleep 唤醒功能 ESP_ERROR_CHECK(touch_sensor_config_sleep_wakeup(sens_handle, &deep_slp_cfg)); + .. only:: esp32s31 + + .. note:: + + ESP32-S31 触摸传感器从 Deep-sleep 唤醒在部分场景下可能失败。增大 :cpp:type:`touch_sensor_config_t` 中的 ``meas_interval_us`` 可缓解该问题。 + .. only:: SOC_TOUCH_SUPPORT_DENOISE_CHAN .. _touch-denoise-chan: diff --git a/examples/peripherals/touch_sensor/touch_sens_sleep/README.md b/examples/peripherals/touch_sensor/touch_sens_sleep/README.md index a6375cbf52a..2949a10f6eb 100644 --- a/examples/peripherals/touch_sensor/touch_sens_sleep/README.md +++ b/examples/peripherals/touch_sensor/touch_sens_sleep/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-P4 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-P4 | ESP32-S2 | ESP32-S3 | ESP32-S31 | +| ----------------- | ----- | -------- | -------- | -------- | --------- | # Touch Sensor Sleep Wake up Example @@ -93,3 +93,7 @@ Entering deep sleep in: ## Troubleshooting For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon. + +## Known issues + +The ESP32-S31 touch sensor may fail to wake the chip from deep sleep. Increasing `meas_interval_us` in `touch_sensor_config_t` can mitigate this issue. diff --git a/examples/peripherals/touch_sensor/touch_sens_sleep/main/Kconfig.projbuild b/examples/peripherals/touch_sensor/touch_sens_sleep/main/Kconfig.projbuild index 238bae29a8b..d42e4fd1407 100644 --- a/examples/peripherals/touch_sensor/touch_sens_sleep/main/Kconfig.projbuild +++ b/examples/peripherals/touch_sensor/touch_sens_sleep/main/Kconfig.projbuild @@ -10,6 +10,7 @@ menu "Example Configuration" bool "Light sleep wakeup" config EXAMPLE_TOUCH_DEEP_SLEEP_WAKEUP bool "Deep sleep wakeup" + depends on !IDF_TARGET_ESP32S31 # TODO: DIG-826 endchoice config EXAMPLE_TOUCH_DEEP_SLEEP_PD