diff --git a/components/esp_driver_touch_sens/test_apps/touch_sens/main/test_touch_sens_common.c b/components/esp_driver_touch_sens/test_apps/touch_sens/main/test_touch_sens_common.c index b3d4b28126..b6f783dc5f 100644 --- a/components/esp_driver_touch_sens/test_apps/touch_sens/main/test_touch_sens_common.c +++ b/components/esp_driver_touch_sens/test_apps/touch_sens/main/test_touch_sens_common.c @@ -31,14 +31,14 @@ static touch_channel_config_t s_chan_cfg = { #if SOC_TOUCH_SENSOR_VERSION == 1 .abs_active_thresh = {1000}, .charge_speed = TOUCH_CHARGE_SPEED_7, - .init_charge_volt = TOUCH_INIT_CHARGE_VOLT_LOW, + .init_charge_volt = TOUCH_INIT_CHARGE_VOLT_DEFAULT, .group = TOUCH_CHAN_TRIG_GROUP_BOTH, #elif SOC_TOUCH_SENSOR_VERSION == 2 .active_thresh = { 2000, }, .charge_speed = TOUCH_CHARGE_SPEED_7, - .init_charge_volt = TOUCH_INIT_CHARGE_VOLT_LOW, + .init_charge_volt = TOUCH_INIT_CHARGE_VOLT_DEFAULT, #elif SOC_TOUCH_SENSOR_VERSION == 3 .active_thresh = { 5000, diff --git a/components/hal/esp32/include/hal/touch_sensor_ll.h b/components/hal/esp32/include/hal/touch_sensor_ll.h index 53929a20bf..65b96ae142 100644 --- a/components/hal/esp32/include/hal/touch_sensor_ll.h +++ b/components/hal/esp32/include/hal/touch_sensor_ll.h @@ -305,7 +305,12 @@ static inline void touch_ll_set_init_charge_voltage(uint32_t touch_num, touch_in { // Workaround: swap chan 8 and chan 9 touch_num = TOUCH_LL_CHAN_SWAP(touch_num); - RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt; + if (init_charge_volt == TOUCH_INIT_CHARGE_VOLT_FLOAT) { + RTCIO.touch_pad[touch_num].xpd = 0; + } else { + RTCIO.touch_pad[touch_num].xpd = 1; + RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt; + } } /** @@ -613,7 +618,12 @@ static inline void touch_ll_get_slope(touch_pad_t touch_num, touch_cnt_slope_t * static inline void touch_ll_set_tie_option(touch_pad_t touch_num, touch_tie_opt_t opt) { touch_pad_t touch_pad_wrap = touch_ll_num_wrap(touch_num); - RTCIO.touch_pad[touch_pad_wrap].tie_opt = opt; + if (opt == TOUCH_PAD_TIE_OPT_FLOAT) { + RTCIO.touch_pad[touch_pad_wrap].xpd = 0; + } else { + RTCIO.touch_pad[touch_pad_wrap].xpd = 1; + RTCIO.touch_pad[touch_pad_wrap].tie_opt = opt; + } } /** @@ -625,7 +635,11 @@ static inline void touch_ll_set_tie_option(touch_pad_t touch_num, touch_tie_opt_ static inline void touch_ll_get_tie_option(touch_pad_t touch_num, touch_tie_opt_t *opt) { touch_pad_t touch_pad_wrap = touch_ll_num_wrap(touch_num); - *opt = (touch_tie_opt_t)RTCIO.touch_pad[touch_pad_wrap].tie_opt; + if (RTCIO.touch_pad[touch_pad_wrap].xpd) { + *opt = (touch_tie_opt_t)RTCIO.touch_pad[touch_pad_wrap].tie_opt; + } else { + *opt = TOUCH_PAD_TIE_OPT_FLOAT; + } } /** diff --git a/components/hal/esp32s2/include/hal/touch_sensor_ll.h b/components/hal/esp32s2/include/hal/touch_sensor_ll.h index a1d70d4197..b35b68908d 100644 --- a/components/hal/esp32s2/include/hal/touch_sensor_ll.h +++ b/components/hal/esp32s2/include/hal/touch_sensor_ll.h @@ -293,7 +293,12 @@ static inline void touch_ll_set_charge_voltage_low_limit(touch_volt_lim_l_t low_ */ static inline void touch_ll_set_init_charge_voltage(uint32_t touch_num, touch_init_charge_volt_t init_charge_volt) { - RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt; + if (init_charge_volt == TOUCH_INIT_CHARGE_VOLT_FLOAT) { + RTCIO.touch_pad[touch_num].xpd = 0; + } else { + RTCIO.touch_pad[touch_num].xpd = 1; + RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt; + } } /** @@ -949,7 +954,12 @@ static inline void touch_ll_get_slope(touch_pad_t touch_num, touch_cnt_slope_t * */ static inline void touch_ll_set_tie_option(touch_pad_t touch_num, touch_tie_opt_t opt) { - RTCIO.touch_pad[touch_num].tie_opt = opt; + if (opt == TOUCH_PAD_TIE_OPT_FLOAT) { + RTCIO.touch_pad[touch_num].xpd = 0; + } else { + RTCIO.touch_pad[touch_num].xpd = 1; + RTCIO.touch_pad[touch_num].tie_opt = opt; + } } /** @@ -960,7 +970,11 @@ static inline void touch_ll_set_tie_option(touch_pad_t touch_num, touch_tie_opt_ */ static inline void touch_ll_get_tie_option(touch_pad_t touch_num, touch_tie_opt_t *opt) { - *opt = (touch_tie_opt_t)RTCIO.touch_pad[touch_num].tie_opt; + if (RTCIO.touch_pad[touch_num].xpd) { + *opt = (touch_tie_opt_t)RTCIO.touch_pad[touch_num].tie_opt; + } else { + *opt = TOUCH_PAD_TIE_OPT_FLOAT; + } } /** diff --git a/components/hal/esp32s3/include/hal/touch_sensor_ll.h b/components/hal/esp32s3/include/hal/touch_sensor_ll.h index 3a9e1824f7..5a17306bbb 100644 --- a/components/hal/esp32s3/include/hal/touch_sensor_ll.h +++ b/components/hal/esp32s3/include/hal/touch_sensor_ll.h @@ -299,7 +299,12 @@ static inline void touch_ll_set_charge_voltage_low_limit(touch_volt_lim_l_t low_ */ static inline void touch_ll_set_init_charge_voltage(uint32_t touch_num, touch_init_charge_volt_t init_charge_volt) { - RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt; + if (init_charge_volt == TOUCH_INIT_CHARGE_VOLT_FLOAT) { + RTCIO.touch_pad[touch_num].xpd = 0; + } else { + RTCIO.touch_pad[touch_num].xpd = 1; + RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt; + } } /** @@ -974,7 +979,12 @@ static inline void touch_ll_get_slope(touch_pad_t touch_num, touch_cnt_slope_t * */ static inline void touch_ll_set_tie_option(touch_pad_t touch_num, touch_tie_opt_t opt) { - RTCIO.touch_pad[touch_num].tie_opt = opt; + if (opt == TOUCH_PAD_TIE_OPT_FLOAT) { + RTCIO.touch_pad[touch_num].xpd = 0; + } else { + RTCIO.touch_pad[touch_num].xpd = 1; + RTCIO.touch_pad[touch_num].tie_opt = opt; + } } /** @@ -985,7 +995,11 @@ static inline void touch_ll_set_tie_option(touch_pad_t touch_num, touch_tie_opt_ */ static inline void touch_ll_get_tie_option(touch_pad_t touch_num, touch_tie_opt_t *opt) { - *opt = (touch_tie_opt_t)RTCIO.touch_pad[touch_num].tie_opt; + if (RTCIO.touch_pad[touch_num].xpd) { + *opt = (touch_tie_opt_t)RTCIO.touch_pad[touch_num].tie_opt; + } else { + *opt = TOUCH_PAD_TIE_OPT_FLOAT; + } } /** diff --git a/components/hal/include/hal/touch_sens_types.h b/components/hal/include/hal/touch_sens_types.h index 143d92d65d..e28808cbf4 100644 --- a/components/hal/include/hal/touch_sens_types.h +++ b/components/hal/include/hal/touch_sens_types.h @@ -108,8 +108,10 @@ typedef enum { * @brief Touch sensor initial voltage before charging */ typedef enum { - TOUCH_INIT_CHARGE_VOLT_LOW = 0, /*!< Tie the initial charge voltage to low */ - TOUCH_INIT_CHARGE_VOLT_HIGH = 1, /*!< Tie the initial charge voltage to high */ + TOUCH_INIT_CHARGE_VOLT_LOW = 0, /*!< Tie the initial charge voltage to low. */ + TOUCH_INIT_CHARGE_VOLT_HIGH = 1, /*!< Tie the initial charge voltage to high. */ + TOUCH_INIT_CHARGE_VOLT_FLOAT = 2, /*!< The initial charge voltage will be float. The touch pad will be powered off between two measurements */ + TOUCH_INIT_CHARGE_VOLT_DEFAULT = TOUCH_INIT_CHARGE_VOLT_FLOAT, /*!< The initial charge voltage is default to be float. */ } touch_init_charge_volt_t; /** diff --git a/components/hal/include/hal/touch_sensor_legacy_types.h b/components/hal/include/hal/touch_sensor_legacy_types.h index c5428372c9..e708aefa7b 100644 --- a/components/hal/include/hal/touch_sensor_legacy_types.h +++ b/components/hal/include/hal/touch_sensor_legacy_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -86,7 +86,8 @@ typedef enum { typedef enum { TOUCH_PAD_TIE_OPT_LOW = 0, /*!