From 50416e2161aade1e1ce2b754796d73e7a396b19d Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Wed, 4 Feb 2026 14:53:38 +0800 Subject: [PATCH] fix(legacy_touch): fixed the read stuck issue after deep sleep --- components/hal/esp32/touch_sensor_hal.c | 7 +++---- components/hal/esp32s2/touch_sensor_hal.c | 8 ++++---- components/hal/esp32s3/touch_sensor_hal.c | 9 ++++----- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/components/hal/esp32/touch_sensor_hal.c b/components/hal/esp32/touch_sensor_hal.c index d74a6686ddc..1f410664836 100644 --- a/components/hal/esp32/touch_sensor_hal.c +++ b/components/hal/esp32/touch_sensor_hal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -11,14 +11,13 @@ void touch_hal_init(void) { - touch_ll_stop_fsm(); - touch_ll_intr_disable(); + // Deinit to reset the registers in case of the registers are not reset when wakeup from deep sleep. + touch_hal_deinit(); touch_ll_intr_clear(); touch_ll_clear_channel_mask(TOUCH_PAD_BIT_MASK_ALL); touch_ll_clear_group_mask(TOUCH_PAD_BIT_MASK_ALL, TOUCH_PAD_BIT_MASK_ALL); touch_ll_set_trigger_mode(TOUCH_TRIGGER_MODE_DEFAULT); touch_ll_set_trigger_source(TOUCH_TRIGGER_SOURCE_DEFAULT); - touch_ll_clear_trigger_status_mask(); touch_ll_set_meas_time(TOUCH_PAD_MEASURE_CYCLE_DEFAULT); touch_ll_set_sleep_time(TOUCH_PAD_SLEEP_CYCLE_DEFAULT); touch_ll_set_fsm_mode(TOUCH_FSM_MODE_DEFAULT); diff --git a/components/hal/esp32s2/touch_sensor_hal.c b/components/hal/esp32s2/touch_sensor_hal.c index 520a5cb89ef..886dc8e0e79 100644 --- a/components/hal/esp32s2/touch_sensor_hal.c +++ b/components/hal/esp32s2/touch_sensor_hal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,11 +16,10 @@ static int s_meas_times = -1; void touch_hal_init(void) { + // Deinit to reset the registers in case of the registers are not reset when wakeup from deep sleep. + touch_hal_deinit(); touch_ll_stop_fsm(); - touch_ll_intr_disable(TOUCH_PAD_INTR_MASK_ALL); touch_ll_intr_clear(TOUCH_PAD_INTR_MASK_ALL); - touch_ll_clear_channel_mask(TOUCH_PAD_BIT_MASK_ALL); - touch_ll_clear_trigger_status_mask(); touch_ll_set_meas_times(TOUCH_PAD_MEASURE_CYCLE_DEFAULT); touch_ll_set_sleep_time(TOUCH_PAD_SLEEP_CYCLE_DEFAULT); /* Configure the touch-sensor power domain into self-bias since bandgap-bias @@ -47,6 +46,7 @@ void touch_hal_deinit(void) touch_ll_clear_channel_mask(TOUCH_PAD_BIT_MASK_ALL); touch_ll_clear_trigger_status_mask(); touch_ll_intr_disable(TOUCH_PAD_INTR_MASK_ALL); + touch_ll_intr_clear(TOUCH_PAD_INTR_MASK_ALL); touch_ll_timeout_disable(); touch_ll_waterproof_disable(); touch_ll_denoise_disable(); diff --git a/components/hal/esp32s3/touch_sensor_hal.c b/components/hal/esp32s3/touch_sensor_hal.c index 6ec7fc73083..f666b2c9388 100644 --- a/components/hal/esp32s3/touch_sensor_hal.c +++ b/components/hal/esp32s3/touch_sensor_hal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,11 +16,9 @@ static int s_meas_times = -1; void touch_hal_init(void) { + // Deinit to reset the registers in case of the registers are not reset when wakeup from deep sleep. + touch_hal_deinit(); touch_ll_stop_fsm(); - touch_ll_intr_disable(TOUCH_PAD_INTR_MASK_ALL); - touch_ll_intr_clear(TOUCH_PAD_INTR_MASK_ALL); - touch_ll_clear_channel_mask(TOUCH_PAD_BIT_MASK_ALL); - touch_ll_clear_trigger_status_mask(); touch_ll_set_meas_times(TOUCH_PAD_MEASURE_CYCLE_DEFAULT); touch_ll_set_sleep_time(TOUCH_PAD_SLEEP_CYCLE_DEFAULT); /* Configure the touch-sensor power domain into self-bias since bandgap-bias @@ -47,6 +45,7 @@ void touch_hal_deinit(void) touch_ll_clear_channel_mask(TOUCH_PAD_BIT_MASK_ALL); touch_ll_clear_trigger_status_mask(); touch_ll_intr_disable(TOUCH_PAD_INTR_MASK_ALL); + touch_ll_intr_clear(TOUCH_PAD_INTR_MASK_ALL); touch_ll_timeout_disable(); touch_ll_waterproof_disable(); touch_ll_denoise_disable();