diff --git a/components/esp_driver_touch_sens/common/touch_sens_common.c b/components/esp_driver_touch_sens/common/touch_sens_common.c index 4a3a57f640..19450a568b 100644 --- a/components/esp_driver_touch_sens/common/touch_sens_common.c +++ b/components/esp_driver_touch_sens/common/touch_sens_common.c @@ -90,6 +90,9 @@ esp_err_t touch_sensor_new_controller(const touch_sensor_config_t *sens_cfg, tou ESP_GOTO_ON_FALSE(g_touch->mutex, ESP_ERR_NO_MEM, err, TAG, "No memory for mutex semaphore"); touch_priv_enable_module(true); +#if SOC_TOUCH_SENSOR_VERSION >= 2 + touch_ll_reset_module(); +#endif ESP_GOTO_ON_ERROR(touch_priv_config_controller(g_touch, sens_cfg), err, TAG, "Failed to configure the touch controller"); #if SOC_TOUCH_SENSOR_VERSION <= 2 ESP_GOTO_ON_ERROR(rtc_isr_register(touch_priv_default_intr_handler, NULL, TOUCH_LL_INTR_MASK_ALL, 0), err, TAG, "Failed to register interrupt handler"); diff --git a/components/hal/esp32/touch_sensor_hal.c b/components/hal/esp32/touch_sensor_hal.c index d74a6686dd..1f41066483 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 78bc17819e..4d3d7f8135 100644 --- a/components/hal/esp32s2/touch_sensor_hal.c +++ b/components/hal/esp32s2/touch_sensor_hal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 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 83dcc05cd5..bb0f48b71d 100644 --- a/components/hal/esp32s3/touch_sensor_hal.c +++ b/components/hal/esp32s3/touch_sensor_hal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 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();