From 2ec93b33948a472c304455e42ca16d84cdd7fe82 Mon Sep 17 00:00:00 2001 From: boarchuz <46267286+boarchuz@users.noreply.github.com> Date: Sat, 16 Oct 2021 16:05:48 +1100 Subject: [PATCH 1/2] fix(touch): fix unexpected touch start on RTC peripheral init Merges https://github.com/espressif/esp-idf/pull/7707 --- components/hal/esp32/include/hal/touch_sensor_ll.h | 2 +- components/hal/esp32s2/include/hal/touch_sensor_ll.h | 2 +- components/hal/esp32s3/include/hal/touch_sensor_ll.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/hal/esp32/include/hal/touch_sensor_ll.h b/components/hal/esp32/include/hal/touch_sensor_ll.h index 455626b004..53929a20bf 100644 --- a/components/hal/esp32/include/hal/touch_sensor_ll.h +++ b/components/hal/esp32/include/hal/touch_sensor_ll.h @@ -681,8 +681,8 @@ static inline void touch_ll_stop_fsm(void) */ static inline void touch_ll_start_sw_meas(void) { - SENS.sar_touch_ctrl2.touch_start_en = 0; SENS.sar_touch_ctrl2.touch_start_en = 1; + SENS.sar_touch_ctrl2.touch_start_en = 0; } /** diff --git a/components/hal/esp32s2/include/hal/touch_sensor_ll.h b/components/hal/esp32s2/include/hal/touch_sensor_ll.h index a5e38e8982..2ce086cc6f 100644 --- a/components/hal/esp32s2/include/hal/touch_sensor_ll.h +++ b/components/hal/esp32s2/include/hal/touch_sensor_ll.h @@ -1061,8 +1061,8 @@ static inline bool touch_ll_get_fsm_state(void) */ static inline void touch_ll_start_sw_meas(void) { - RTCCNTL.touch_ctrl2.touch_start_en = 0; RTCCNTL.touch_ctrl2.touch_start_en = 1; + RTCCNTL.touch_ctrl2.touch_start_en = 0; } /** diff --git a/components/hal/esp32s3/include/hal/touch_sensor_ll.h b/components/hal/esp32s3/include/hal/touch_sensor_ll.h index 193950ee70..d57129e5c0 100644 --- a/components/hal/esp32s3/include/hal/touch_sensor_ll.h +++ b/components/hal/esp32s3/include/hal/touch_sensor_ll.h @@ -1086,8 +1086,8 @@ static inline bool touch_ll_get_fsm_state(void) */ static inline void touch_ll_start_sw_meas(void) { - RTCCNTL.touch_ctrl2.touch_start_en = 0; RTCCNTL.touch_ctrl2.touch_start_en = 1; + RTCCNTL.touch_ctrl2.touch_start_en = 0; } /** From e6fb6612c9055f6cc40f8041c71d1da20c6d4150 Mon Sep 17 00:00:00 2001 From: Huelsenfrucht Date: Fri, 10 Feb 2023 12:44:33 -0500 Subject: [PATCH 2/2] fix(touch): checks if the timer is active before stopping it Merges https://github.com/espressif/esp-idf/pull/10745 --- components/driver/touch_sensor/esp32/touch_sensor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/driver/touch_sensor/esp32/touch_sensor.c b/components/driver/touch_sensor/esp32/touch_sensor.c index 8731a080da..686207817f 100644 --- a/components/driver/touch_sensor/esp32/touch_sensor.c +++ b/components/driver/touch_sensor/esp32/touch_sensor.c @@ -512,7 +512,9 @@ esp_err_t touch_pad_filter_delete(void) esp_err_t ret = ESP_OK; xSemaphoreTake(rtc_touch_mux, portMAX_DELAY); if (s_touch_pad_filter->timer) { - ESP_GOTO_ON_ERROR(esp_timer_stop(s_touch_pad_filter->timer), err, TOUCH_TAG, "failed to stop the timer"); + if (esp_timer_is_active(s_touch_pad_filter->timer)) { + ESP_GOTO_ON_ERROR(esp_timer_stop(s_touch_pad_filter->timer), err, TOUCH_TAG, "failed to stop the timer"); + } ESP_GOTO_ON_ERROR(esp_timer_delete(s_touch_pad_filter->timer), err, TOUCH_TAG, "failed to delete the timer"); s_touch_pad_filter->timer = NULL; }