fix(touch): fixed tie option take no effect

This commit is contained in:
laokaiyao
2025-04-21 15:03:53 +08:00
parent be96ad682b
commit 781ccfbd0c
4 changed files with 40 additions and 12 deletions

View File

@ -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
*/
@ -208,7 +208,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;
}
}
/**
@ -220,7 +225,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;
}
}
/**

View File

@ -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
*/
@ -194,7 +194,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;
}
}
/**
@ -205,7 +210,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;
}
}
/**

View File

@ -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
*/
@ -209,7 +209,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;
}
}
/**
@ -220,7 +225,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;
}
}
/**

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 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, /*!<Initial level of charging voltage, low level */
TOUCH_PAD_TIE_OPT_HIGH = 1, /*!<Initial level of charging voltage, high level */
TOUCH_PAD_TIE_OPT_MAX,
TOUCH_PAD_TIE_OPT_FLOAT = 2, /*!<Initial level of charging voltage, float */
TOUCH_PAD_TIE_OPT_MAX, /*!<The max tie options */
} touch_tie_opt_t;
/** Touch sensor FSM mode */
@ -113,7 +114,7 @@ typedef enum {
/********************************/
#define TOUCH_PAD_BIT_MASK_ALL ((1<<SOC_TOUCH_SENSOR_NUM)-1)
#define TOUCH_PAD_SLOPE_DEFAULT (TOUCH_PAD_SLOPE_7)
#define TOUCH_PAD_TIE_OPT_DEFAULT (TOUCH_PAD_TIE_OPT_LOW)
#define TOUCH_PAD_TIE_OPT_DEFAULT (TOUCH_PAD_TIE_OPT_FLOAT)
#define TOUCH_PAD_BIT_MASK_MAX (TOUCH_PAD_BIT_MASK_ALL)
#define TOUCH_PAD_HIGH_VOLTAGE_THRESHOLD (TOUCH_HVOLT_2V7)
#define TOUCH_PAD_LOW_VOLTAGE_THRESHOLD (TOUCH_LVOLT_0V5)