fix(touch): fixed tie option take no effect

This commit is contained in:
laokaiyao
2025-03-20 15:08:32 +08:00
committed by Kevin (Lao Kaiyao)
parent fe73a61b2b
commit 37cbd1e555
7 changed files with 63 additions and 18 deletions

View File

@ -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,

View File

@ -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;
}
}
/**

View File

@ -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;
}
}
/**

View File

@ -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;
}
}
/**

View File

@ -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;
/**

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
*/
@ -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)

View File

@ -17,7 +17,7 @@ extern "C" {
#define EXAMPLE_TOUCH_CHAN_CFG_DEFAULT() { \
.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 // ESP32-S2 & ESP32-S3
@ -25,7 +25,7 @@ extern "C" {
#define EXAMPLE_TOUCH_CHAN_CFG_DEFAULT() { \
.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 // ESP32-P4
#define EXAMPLE_TOUCH_SAMPLE_CFG_DEFAULT() {TOUCH_SENSOR_V3_DEFAULT_SAMPLE_CONFIG2(3, 29, 8, 3),\