Skip to content

Commit 37cbd1e

Browse files
committed
fix(touch): fixed tie option take no effect
1 parent fe73a61 commit 37cbd1e

File tree

7 files changed

+63
-18
lines changed

7 files changed

+63
-18
lines changed

components/esp_driver_touch_sens/test_apps/touch_sens/main/test_touch_sens_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ static touch_channel_config_t s_chan_cfg = {
3131
#if SOC_TOUCH_SENSOR_VERSION == 1
3232
.abs_active_thresh = {1000},
3333
.charge_speed = TOUCH_CHARGE_SPEED_7,
34-
.init_charge_volt = TOUCH_INIT_CHARGE_VOLT_LOW,
34+
.init_charge_volt = TOUCH_INIT_CHARGE_VOLT_DEFAULT,
3535
.group = TOUCH_CHAN_TRIG_GROUP_BOTH,
3636
#elif SOC_TOUCH_SENSOR_VERSION == 2
3737
.active_thresh = {
3838
2000,
3939
},
4040
.charge_speed = TOUCH_CHARGE_SPEED_7,
41-
.init_charge_volt = TOUCH_INIT_CHARGE_VOLT_LOW,
41+
.init_charge_volt = TOUCH_INIT_CHARGE_VOLT_DEFAULT,
4242
#elif SOC_TOUCH_SENSOR_VERSION == 3
4343
.active_thresh = {
4444
5000,

components/hal/esp32/include/hal/touch_sensor_ll.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,12 @@ static inline void touch_ll_set_init_charge_voltage(uint32_t touch_num, touch_in
305305
{
306306
// Workaround: swap chan 8 and chan 9
307307
touch_num = TOUCH_LL_CHAN_SWAP(touch_num);
308-
RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt;
308+
if (init_charge_volt == TOUCH_INIT_CHARGE_VOLT_FLOAT) {
309+
RTCIO.touch_pad[touch_num].xpd = 0;
310+
} else {
311+
RTCIO.touch_pad[touch_num].xpd = 1;
312+
RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt;
313+
}
309314
}
310315

311316
/**
@@ -613,7 +618,12 @@ static inline void touch_ll_get_slope(touch_pad_t touch_num, touch_cnt_slope_t *
613618
static inline void touch_ll_set_tie_option(touch_pad_t touch_num, touch_tie_opt_t opt)
614619
{
615620
touch_pad_t touch_pad_wrap = touch_ll_num_wrap(touch_num);
616-
RTCIO.touch_pad[touch_pad_wrap].tie_opt = opt;
621+
if (opt == TOUCH_PAD_TIE_OPT_FLOAT) {
622+
RTCIO.touch_pad[touch_pad_wrap].xpd = 0;
623+
} else {
624+
RTCIO.touch_pad[touch_pad_wrap].xpd = 1;
625+
RTCIO.touch_pad[touch_pad_wrap].tie_opt = opt;
626+
}
617627
}
618628

619629
/**
@@ -625,7 +635,11 @@ static inline void touch_ll_set_tie_option(touch_pad_t touch_num, touch_tie_opt_
625635
static inline void touch_ll_get_tie_option(touch_pad_t touch_num, touch_tie_opt_t *opt)
626636
{
627637
touch_pad_t touch_pad_wrap = touch_ll_num_wrap(touch_num);
628-
*opt = (touch_tie_opt_t)RTCIO.touch_pad[touch_pad_wrap].tie_opt;
638+
if (RTCIO.touch_pad[touch_pad_wrap].xpd) {
639+
*opt = (touch_tie_opt_t)RTCIO.touch_pad[touch_pad_wrap].tie_opt;
640+
} else {
641+
*opt = TOUCH_PAD_TIE_OPT_FLOAT;
642+
}
629643
}
630644

631645
/**

components/hal/esp32s2/include/hal/touch_sensor_ll.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,12 @@ static inline void touch_ll_set_charge_voltage_low_limit(touch_volt_lim_l_t low_
293293
*/
294294
static inline void touch_ll_set_init_charge_voltage(uint32_t touch_num, touch_init_charge_volt_t init_charge_volt)
295295
{
296-
RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt;
296+
if (init_charge_volt == TOUCH_INIT_CHARGE_VOLT_FLOAT) {
297+
RTCIO.touch_pad[touch_num].xpd = 0;
298+
} else {
299+
RTCIO.touch_pad[touch_num].xpd = 1;
300+
RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt;
301+
}
297302
}
298303

299304
/**
@@ -949,7 +954,12 @@ static inline void touch_ll_get_slope(touch_pad_t touch_num, touch_cnt_slope_t *
949954
*/
950955
static inline void touch_ll_set_tie_option(touch_pad_t touch_num, touch_tie_opt_t opt)
951956
{
952-
RTCIO.touch_pad[touch_num].tie_opt = opt;
957+
if (opt == TOUCH_PAD_TIE_OPT_FLOAT) {
958+
RTCIO.touch_pad[touch_num].xpd = 0;
959+
} else {
960+
RTCIO.touch_pad[touch_num].xpd = 1;
961+
RTCIO.touch_pad[touch_num].tie_opt = opt;
962+
}
953963
}
954964

955965
/**
@@ -960,7 +970,11 @@ static inline void touch_ll_set_tie_option(touch_pad_t touch_num, touch_tie_opt_
960970
*/
961971
static inline void touch_ll_get_tie_option(touch_pad_t touch_num, touch_tie_opt_t *opt)
962972
{
963-
*opt = (touch_tie_opt_t)RTCIO.touch_pad[touch_num].tie_opt;
973+
if (RTCIO.touch_pad[touch_num].xpd) {
974+
*opt = (touch_tie_opt_t)RTCIO.touch_pad[touch_num].tie_opt;
975+
} else {
976+
*opt = TOUCH_PAD_TIE_OPT_FLOAT;
977+
}
964978
}
965979

966980
/**

components/hal/esp32s3/include/hal/touch_sensor_ll.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,12 @@ static inline void touch_ll_set_charge_voltage_low_limit(touch_volt_lim_l_t low_
299299
*/
300300
static inline void touch_ll_set_init_charge_voltage(uint32_t touch_num, touch_init_charge_volt_t init_charge_volt)
301301
{
302-
RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt;
302+
if (init_charge_volt == TOUCH_INIT_CHARGE_VOLT_FLOAT) {
303+
RTCIO.touch_pad[touch_num].xpd = 0;
304+
} else {
305+
RTCIO.touch_pad[touch_num].xpd = 1;
306+
RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt;
307+
}
303308
}
304309

305310
/**
@@ -974,7 +979,12 @@ static inline void touch_ll_get_slope(touch_pad_t touch_num, touch_cnt_slope_t *
974979
*/
975980
static inline void touch_ll_set_tie_option(touch_pad_t touch_num, touch_tie_opt_t opt)
976981
{
977-
RTCIO.touch_pad[touch_num].tie_opt = opt;
982+
if (opt == TOUCH_PAD_TIE_OPT_FLOAT) {
983+
RTCIO.touch_pad[touch_num].xpd = 0;
984+
} else {
985+
RTCIO.touch_pad[touch_num].xpd = 1;
986+
RTCIO.touch_pad[touch_num].tie_opt = opt;
987+
}
978988
}
979989

980990
/**
@@ -985,7 +995,11 @@ static inline void touch_ll_set_tie_option(touch_pad_t touch_num, touch_tie_opt_
985995
*/
986996
static inline void touch_ll_get_tie_option(touch_pad_t touch_num, touch_tie_opt_t *opt)
987997
{
988-
*opt = (touch_tie_opt_t)RTCIO.touch_pad[touch_num].tie_opt;
998+
if (RTCIO.touch_pad[touch_num].xpd) {
999+
*opt = (touch_tie_opt_t)RTCIO.touch_pad[touch_num].tie_opt;
1000+
} else {
1001+
*opt = TOUCH_PAD_TIE_OPT_FLOAT;
1002+
}
9891003
}
9901004

9911005
/**

components/hal/include/hal/touch_sens_types.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ typedef enum {
108108
* @brief Touch sensor initial voltage before charging
109109
*/
110110
typedef enum {
111-
TOUCH_INIT_CHARGE_VOLT_LOW = 0, /*!< Tie the initial charge voltage to low */
112-
TOUCH_INIT_CHARGE_VOLT_HIGH = 1, /*!< Tie the initial charge voltage to high */
111+
TOUCH_INIT_CHARGE_VOLT_LOW = 0, /*!< Tie the initial charge voltage to low. */
112+
TOUCH_INIT_CHARGE_VOLT_HIGH = 1, /*!< Tie the initial charge voltage to high. */
113+
TOUCH_INIT_CHARGE_VOLT_FLOAT = 2, /*!< The initial charge voltage will be float. The touch pad will be powered off between two measurements */
114+
TOUCH_INIT_CHARGE_VOLT_DEFAULT = TOUCH_INIT_CHARGE_VOLT_FLOAT, /*!< The initial charge voltage is default to be float. */
113115
} touch_init_charge_volt_t;
114116

115117
/**

components/hal/include/hal/touch_sensor_legacy_types.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -86,7 +86,8 @@ typedef enum {
8686
typedef enum {
8787
TOUCH_PAD_TIE_OPT_LOW = 0, /*!<Initial level of charging voltage, low level */
8888
TOUCH_PAD_TIE_OPT_HIGH = 1, /*!<Initial level of charging voltage, high level */
89-
TOUCH_PAD_TIE_OPT_MAX,
89+
TOUCH_PAD_TIE_OPT_FLOAT = 2, /*!<Initial level of charging voltage, float */
90+
TOUCH_PAD_TIE_OPT_MAX, /*!<The max tie options */
9091
} touch_tie_opt_t;
9192

9293
/** Touch sensor FSM mode */
@@ -113,7 +114,7 @@ typedef enum {
113114
/********************************/
114115
#define TOUCH_PAD_BIT_MASK_ALL ((1<<SOC_TOUCH_SENSOR_NUM)-1)
115116
#define TOUCH_PAD_SLOPE_DEFAULT (TOUCH_PAD_SLOPE_7)
116-
#define TOUCH_PAD_TIE_OPT_DEFAULT (TOUCH_PAD_TIE_OPT_LOW)
117+
#define TOUCH_PAD_TIE_OPT_DEFAULT (TOUCH_PAD_TIE_OPT_FLOAT)
117118
#define TOUCH_PAD_BIT_MASK_MAX (TOUCH_PAD_BIT_MASK_ALL)
118119
#define TOUCH_PAD_HIGH_VOLTAGE_THRESHOLD (TOUCH_HVOLT_2V7)
119120
#define TOUCH_PAD_LOW_VOLTAGE_THRESHOLD (TOUCH_LVOLT_0V5)

examples/peripherals/touch_sensor/touch_sens_examples_common/touch_sens_example_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ extern "C" {
1717
#define EXAMPLE_TOUCH_CHAN_CFG_DEFAULT() { \
1818
.abs_active_thresh = {1000}, \
1919
.charge_speed = TOUCH_CHARGE_SPEED_7, \
20-
.init_charge_volt = TOUCH_INIT_CHARGE_VOLT_LOW, \
20+
.init_charge_volt = TOUCH_INIT_CHARGE_VOLT_DEFAULT, \
2121
.group = TOUCH_CHAN_TRIG_GROUP_BOTH, \
2222
}
2323
#elif SOC_TOUCH_SENSOR_VERSION == 2 // ESP32-S2 & ESP32-S3
2424
#define EXAMPLE_TOUCH_SAMPLE_CFG_DEFAULT() {TOUCH_SENSOR_V2_DEFAULT_SAMPLE_CONFIG(500, TOUCH_VOLT_LIM_L_0V5, TOUCH_VOLT_LIM_H_2V2)}
2525
#define EXAMPLE_TOUCH_CHAN_CFG_DEFAULT() { \
2626
.active_thresh = {2000}, \
2727
.charge_speed = TOUCH_CHARGE_SPEED_7, \
28-
.init_charge_volt = TOUCH_INIT_CHARGE_VOLT_LOW, \
28+
.init_charge_volt = TOUCH_INIT_CHARGE_VOLT_DEFAULT, \
2929
}
3030
#elif SOC_TOUCH_SENSOR_VERSION == 3 // ESP32-P4
3131
#define EXAMPLE_TOUCH_SAMPLE_CFG_DEFAULT() {TOUCH_SENSOR_V3_DEFAULT_SAMPLE_CONFIG2(3, 29, 8, 3),\

0 commit comments

Comments
 (0)