refactor(touch): adjust touch channel number on P4 from 0-13 to 1-14

This commit is contained in:
laokaiyao
2025-05-22 12:11:11 +08:00
parent fe5927aee6
commit c8a6d41c27
13 changed files with 145 additions and 208 deletions

View File

@@ -133,22 +133,24 @@ esp_err_t touch_sensor_new_channel(touch_sensor_handle_t sens_handle, int chan_i
TOUCH_NULL_POINTER_CHECK(chan_cfg); TOUCH_NULL_POINTER_CHECK(chan_cfg);
TOUCH_NULL_POINTER_CHECK(ret_chan_handle); TOUCH_NULL_POINTER_CHECK(ret_chan_handle);
TOUCH_CHANNEL_CHECK(chan_id); TOUCH_CHANNEL_CHECK(chan_id);
uint32_t ch_offset = chan_id - TOUCH_MIN_CHAN_ID;
ESP_RETURN_ON_FALSE(g_touch == sens_handle, ESP_ERR_INVALID_ARG, TAG, "The input touch sensor handle is unmatched"); ESP_RETURN_ON_FALSE(g_touch == sens_handle, ESP_ERR_INVALID_ARG, TAG, "The input touch sensor handle is unmatched");
esp_err_t ret = ESP_OK; esp_err_t ret = ESP_OK;
xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); xSemaphoreTake(sens_handle->mutex, portMAX_DELAY);
ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err2, TAG, "Please disable the touch sensor first"); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err2, TAG, "Please disable the touch sensor first");
ESP_GOTO_ON_FALSE(!sens_handle->ch[chan_id], ESP_ERR_INVALID_STATE, err2, TAG, "The channel %d has been registered", chan_id); ESP_GOTO_ON_FALSE(!sens_handle->ch[ch_offset], ESP_ERR_INVALID_STATE, err2, TAG, "The channel %d has been registered", chan_id);
sens_handle->ch[chan_id] = (touch_channel_handle_t)heap_caps_calloc(1, sizeof(struct touch_channel_s), TOUCH_MEM_ALLOC_CAPS); sens_handle->ch[ch_offset] = (touch_channel_handle_t)heap_caps_calloc(1, sizeof(struct touch_channel_s), TOUCH_MEM_ALLOC_CAPS);
ESP_GOTO_ON_FALSE(sens_handle->ch[chan_id], ESP_ERR_NO_MEM, err2, TAG, "No memory for touch channel"); ESP_GOTO_ON_FALSE(sens_handle->ch[ch_offset], ESP_ERR_NO_MEM, err2, TAG, "No memory for touch channel");
sens_handle->ch[chan_id]->id = chan_id; sens_handle->ch[ch_offset]->id = chan_id;
sens_handle->ch[chan_id]->base = sens_handle; sens_handle->ch[ch_offset]->base = sens_handle;
sens_handle->ch[chan_id]->is_prox_chan = false; sens_handle->ch[ch_offset]->is_prox_chan = false;
/* Init the channel */ /* Init the channel */
ESP_GOTO_ON_ERROR(touch_priv_config_channel(sens_handle->ch[chan_id], chan_cfg), ESP_GOTO_ON_ERROR(touch_priv_config_channel(sens_handle->ch[ch_offset], chan_cfg),
err1, TAG, "Failed to configure the touch channel %d", chan_id); err1, TAG, "Failed to configure the touch channel %d", chan_id);
touch_channel_pin_init(chan_id); touch_channel_pin_init(chan_id);
TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK);
@@ -159,13 +161,13 @@ esp_err_t touch_sensor_new_channel(touch_sensor_handle_t sens_handle, int chan_i
touch_ll_set_channel_mask(sens_handle->chan_mask); touch_ll_set_channel_mask(sens_handle->chan_mask);
TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK);
*ret_chan_handle = sens_handle->ch[chan_id]; *ret_chan_handle = sens_handle->ch[ch_offset];
xSemaphoreGive(sens_handle->mutex); xSemaphoreGive(sens_handle->mutex);
return ret; return ret;
err1: err1:
free(sens_handle->ch[chan_id]); free(sens_handle->ch[ch_offset]);
sens_handle->ch[chan_id] = NULL; sens_handle->ch[ch_offset] = NULL;
err2: err2:
xSemaphoreGive(sens_handle->mutex); xSemaphoreGive(sens_handle->mutex);
return ret; return ret;
@@ -188,14 +190,15 @@ esp_err_t touch_sensor_del_channel(touch_channel_handle_t chan_handle)
ESP_GOTO_ON_ERROR(touch_sensor_config_sleep_channel(sens_handle, NULL), err, TAG, "Failed to disable sleep function on this channel"); ESP_GOTO_ON_ERROR(touch_sensor_config_sleep_channel(sens_handle, NULL), err, TAG, "Failed to disable sleep function on this channel");
} }
#endif #endif
int id = chan_handle->id; int ch_offset = chan_handle->id - TOUCH_MIN_CHAN_ID;
assert(ch_offset >= 0);
TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK);
sens_handle->chan_mask &= ~(1UL << id); sens_handle->chan_mask &= ~(1UL << chan_handle->id);
touch_ll_set_channel_mask(sens_handle->chan_mask); touch_ll_set_channel_mask(sens_handle->chan_mask);
TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK);
free(g_touch->ch[id]); free(g_touch->ch[ch_offset]);
g_touch->ch[id] = NULL; g_touch->ch[ch_offset] = NULL;
err: err:
xSemaphoreGive(sens_handle->mutex); xSemaphoreGive(sens_handle->mutex);
return ret; return ret;
@@ -358,7 +361,7 @@ esp_err_t touch_sensor_trigger_oneshot_scanning(touch_sensor_handle_t sens_handl
FOR_EACH_TOUCH_CHANNEL(i) { FOR_EACH_TOUCH_CHANNEL(i) {
if (sens_handle->ch[i]) { if (sens_handle->ch[i]) {
TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK);
touch_ll_channel_sw_measure_mask(BIT(i)); touch_ll_channel_sw_measure_mask(BIT(sens_handle->ch[i]->id));
touch_ll_trigger_oneshot_measurement(); touch_ll_trigger_oneshot_measurement();
TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK);
while (!touch_ll_is_measure_done()) { while (!touch_ll_is_measure_done()) {

View File

@@ -63,7 +63,8 @@ void IRAM_ATTR touch_priv_default_intr_handler(void *arg)
touch_ll_intr_clear(status); touch_ll_intr_clear(status);
touch_base_event_data_t data; touch_base_event_data_t data;
touch_ll_get_active_channel_mask(&data.status_mask); touch_ll_get_active_channel_mask(&data.status_mask);
data.chan = g_touch->ch[touch_ll_get_current_meas_channel()]; int ch_offset = touch_ll_get_current_meas_channel() - TOUCH_MIN_CHAN_ID;
data.chan = g_touch->ch[ch_offset];
/* If the channel is not registered, return directly */ /* If the channel is not registered, return directly */
if (!data.chan) { if (!data.chan) {
return; return;

View File

@@ -49,7 +49,7 @@ TEST_CASE("touch_sens_install_uninstall_test", "[touch]")
TEST_ESP_OK(touch_sensor_config_filter(touch, &filter_cfg)); TEST_ESP_OK(touch_sensor_config_filter(touch, &filter_cfg));
for (int i = 0; i < TOUCH_TOTAL_CHAN_NUM; i++) { for (int i = 0; i < TOUCH_TOTAL_CHAN_NUM; i++) {
TEST_ESP_OK(touch_sensor_new_channel(touch, i, &s_chan_cfg, &touch_chan[i])); TEST_ESP_OK(touch_sensor_new_channel(touch, i + TOUCH_MIN_CHAN_ID, &s_chan_cfg, &touch_chan[i]));
} }
touch_channel_handle_t fault_chan = NULL; touch_channel_handle_t fault_chan = NULL;
TEST_ASSERT(touch_sensor_new_channel(touch, TOUCH_TOTAL_CHAN_NUM, &s_chan_cfg, &fault_chan) == ESP_ERR_INVALID_ARG); TEST_ASSERT(touch_sensor_new_channel(touch, TOUCH_TOTAL_CHAN_NUM, &s_chan_cfg, &fault_chan) == ESP_ERR_INVALID_ARG);

View File

@@ -45,7 +45,7 @@ extern "C" {
#define TOUCH_LL_INTR_MASK_PROX_DONE BIT(5) #define TOUCH_LL_INTR_MASK_PROX_DONE BIT(5)
#define TOUCH_LL_INTR_MASK_ALL (0x3F) #define TOUCH_LL_INTR_MASK_ALL (0x3F)
#define TOUCH_LL_FULL_CHANNEL_MASK ((uint16_t)((1U << SOC_TOUCH_SENSOR_NUM) - 1)) #define TOUCH_LL_FULL_CHANNEL_MASK ((uint16_t)((1U << (SOC_TOUCH_SENSOR_NUM)) - 1) << SOC_TOUCH_MIN_CHAN_ID)
#define TOUCH_LL_NULL_CHANNEL (15) // Null Channel id. Used for disabling some functions like sleep/proximity/waterproof #define TOUCH_LL_NULL_CHANNEL (15) // Null Channel id. Used for disabling some functions like sleep/proximity/waterproof
#define TOUCH_LL_PAD_MEASURE_WAIT_MAX (0x7FFF) // The timer frequency is 8Mhz, the max value is 0xff #define TOUCH_LL_PAD_MEASURE_WAIT_MAX (0x7FFF) // The timer frequency is 8Mhz, the max value is 0xff
@@ -273,8 +273,7 @@ static inline void touch_ll_trigger_oneshot_measurement(void)
static inline void touch_ll_measure_channel_once(uint16_t chan_mask) static inline void touch_ll_measure_channel_once(uint16_t chan_mask)
{ {
// Channel shift workaround LP_ANA_PERI.touch_mux1.touch_start = chan_mask;
LP_ANA_PERI.touch_mux1.touch_start = chan_mask << 1;
} }
/** /**
@@ -290,8 +289,7 @@ static inline void touch_ll_measure_channel_once(uint16_t chan_mask)
static inline void touch_ll_set_chan_active_threshold(uint32_t touch_num, uint8_t sample_cfg_id, uint32_t thresh) static inline void touch_ll_set_chan_active_threshold(uint32_t touch_num, uint8_t sample_cfg_id, uint32_t thresh)
{ {
HAL_ASSERT(sample_cfg_id < SOC_TOUCH_SAMPLE_CFG_NUM); HAL_ASSERT(sample_cfg_id < SOC_TOUCH_SAMPLE_CFG_NUM);
// Channel shift workaround HAL_FORCE_MODIFY_U32_REG_FIELD(LP_ANA_PERI.touch_padx_thn[touch_num].thresh[sample_cfg_id], threshold, thresh); // codespell:ignore
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_ANA_PERI.touch_padx_thn[touch_num + 1].thresh[sample_cfg_id], threshold, thresh); // codespell:ignore
} }
/** /**
@@ -304,8 +302,8 @@ static inline void touch_ll_set_chan_active_threshold(uint32_t touch_num, uint8_
__attribute__((always_inline)) __attribute__((always_inline))
static inline void touch_ll_enable_scan_mask(uint16_t chan_mask, bool enable) static inline void touch_ll_enable_scan_mask(uint16_t chan_mask, bool enable)
{ {
// Channel shift workaround: the lowest bit takes no effect // the lowest bit takes no effect
uint16_t mask = (chan_mask << 1) & TOUCH_PAD_BIT_MASK_ALL; uint16_t mask = chan_mask & TOUCH_LL_FULL_CHANNEL_MASK;
uint16_t prev_mask = LP_ANA_PERI.touch_scan_ctrl1.touch_scan_pad_map; uint16_t prev_mask = LP_ANA_PERI.touch_scan_ctrl1.touch_scan_pad_map;
if (enable) { if (enable) {
LP_ANA_PERI.touch_scan_ctrl1.touch_scan_pad_map = prev_mask | mask; LP_ANA_PERI.touch_scan_ctrl1.touch_scan_pad_map = prev_mask | mask;
@@ -328,8 +326,8 @@ static inline void touch_ll_enable_scan_mask(uint16_t chan_mask, bool enable)
*/ */
static inline void touch_ll_set_channel_mask(uint16_t enable_mask) static inline void touch_ll_set_channel_mask(uint16_t enable_mask)
{ {
// Channel shift workaround: the lowest bit takes no effect // the lowest bit takes no effect
uint16_t mask = (enable_mask << 1) & TOUCH_PAD_BIT_MASK_ALL; uint16_t mask = enable_mask & TOUCH_LL_FULL_CHANNEL_MASK;
LP_ANA_PERI.touch_scan_ctrl1.touch_scan_pad_map = mask; LP_ANA_PERI.touch_scan_ctrl1.touch_scan_pad_map = mask;
LP_ANA_PERI.touch_filter2.touch_outen = mask; LP_ANA_PERI.touch_filter2.touch_outen = mask;
} }
@@ -342,9 +340,8 @@ static inline void touch_ll_set_channel_mask(uint16_t enable_mask)
__attribute__((always_inline)) __attribute__((always_inline))
static inline void touch_ll_channel_sw_measure_mask(uint16_t chan_mask) static inline void touch_ll_channel_sw_measure_mask(uint16_t chan_mask)
{ {
// Channel shift workaround LP_ANA_PERI.touch_mux1.touch_xpd = chan_mask;
LP_ANA_PERI.touch_mux1.touch_xpd = chan_mask << 1; LP_ANA_PERI.touch_mux1.touch_start = chan_mask;
LP_ANA_PERI.touch_mux1.touch_start = chan_mask << 1;
} }
/** /**
@@ -355,8 +352,7 @@ static inline void touch_ll_channel_sw_measure_mask(uint16_t chan_mask)
static inline void touch_ll_channel_power_off(uint16_t chan_mask) static inline void touch_ll_channel_power_off(uint16_t chan_mask)
{ {
uint32_t curr_mask = LP_ANA_PERI.touch_mux1.touch_xpd; uint32_t curr_mask = LP_ANA_PERI.touch_mux1.touch_xpd;
// Channel shift workaround LP_ANA_PERI.touch_mux1.touch_xpd = (~chan_mask) & curr_mask;
LP_ANA_PERI.touch_mux1.touch_xpd = (~(chan_mask << 1)) & curr_mask;
} }
/** /**
@@ -367,8 +363,7 @@ static inline void touch_ll_channel_power_off(uint16_t chan_mask)
__attribute__((always_inline)) __attribute__((always_inline))
static inline void touch_ll_get_active_channel_mask(uint32_t *active_mask) static inline void touch_ll_get_active_channel_mask(uint32_t *active_mask)
{ {
// Channel shift workaround *active_mask = LP_TOUCH.chn_status.pad_active;
*active_mask = (LP_TOUCH.chn_status.pad_active >> 1);
} }
/** /**
@@ -400,8 +395,7 @@ static inline void touch_ll_read_chan_data(uint32_t touch_num, uint8_t sample_cf
HAL_ASSERT(type == TOUCH_LL_READ_BENCHMARK || type == TOUCH_LL_READ_SMOOTH); HAL_ASSERT(type == TOUCH_LL_READ_BENCHMARK || type == TOUCH_LL_READ_SMOOTH);
LP_ANA_PERI.touch_mux0.touch_freq_sel = sample_cfg_id; LP_ANA_PERI.touch_mux0.touch_freq_sel = sample_cfg_id;
LP_ANA_PERI.touch_mux0.touch_data_sel = type; LP_ANA_PERI.touch_mux0.touch_data_sel = type;
// Channel shift workaround *data = HAL_FORCE_READ_U32_REG_FIELD(LP_TOUCH.chn_data[touch_num], pad_data);
*data = LP_TOUCH.chn_data[touch_num + 1].pad_data;
} }
/** /**
@@ -416,11 +410,6 @@ static inline bool touch_ll_is_measure_done(void)
return (bool)LP_TOUCH.chn_status.meas_done; return (bool)LP_TOUCH.chn_status.meas_done;
} }
static inline uint32_t touch_ll_get_current_measure_channel(void)
{
// Channel shift workaround
return (uint32_t)(LP_TOUCH.chn_status.scan_curr - 1);
}
/** /**
* Select the counting mode of the binarized touch out wave * Select the counting mode of the binarized touch out wave
* *
@@ -493,8 +482,11 @@ static inline void touch_ll_set_idle_channel_connect(touch_pad_conn_type_t type)
__attribute__((always_inline)) __attribute__((always_inline))
static inline uint32_t touch_ll_get_current_meas_channel(void) static inline uint32_t touch_ll_get_current_meas_channel(void)
{ {
// Channel shift workaround uint32_t curr_chan = LP_TOUCH.chn_status.scan_curr;
return (uint32_t)(LP_TOUCH.chn_status.scan_curr - 1); HAL_ASSERT(curr_chan < 14);
// Workaround: the curr channel read 0 when the actual channel is 14
curr_chan = curr_chan == 0 ? 14 : curr_chan;
return curr_chan;
} }
/** /**
@@ -770,8 +762,7 @@ static inline void touch_ll_force_update_benchmark(uint32_t benchmark)
*/ */
static inline void touch_ll_waterproof_set_guard_chan(uint32_t pad_num) static inline void touch_ll_waterproof_set_guard_chan(uint32_t pad_num)
{ {
// Channel shift workaround LP_ANA_PERI.touch_scan_ctrl2.touch_out_ring = pad_num;
LP_ANA_PERI.touch_scan_ctrl2.touch_out_ring = pad_num == TOUCH_LL_NULL_CHANNEL ? TOUCH_LL_NULL_CHANNEL : pad_num + 1;
} }
/** /**
@@ -794,8 +785,7 @@ static inline void touch_ll_waterproof_enable(bool enable)
*/ */
static inline void touch_ll_waterproof_set_shield_chan_mask(uint32_t mask) static inline void touch_ll_waterproof_set_shield_chan_mask(uint32_t mask)
{ {
// Channel shift workaround LP_ANA_PERI.touch_mux0.touch_bufsel = mask;
LP_ANA_PERI.touch_mux0.touch_bufsel = mask << 1;
} }
/** /**
@@ -821,16 +811,13 @@ static inline void touch_ll_set_proximity_sensing_channel(uint8_t prox_chan, uin
{ {
switch (prox_chan) { switch (prox_chan) {
case 0: case 0:
// Channel shift workaround LP_ANA_PERI.touch_approach.touch_approach_pad0 = touch_num;
LP_ANA_PERI.touch_approach.touch_approach_pad0 = touch_num + 1;
break; break;
case 1: case 1:
// Channel shift workaround LP_ANA_PERI.touch_approach.touch_approach_pad1 = touch_num;
LP_ANA_PERI.touch_approach.touch_approach_pad1 = touch_num + 1;
break; break;
case 2: case 2:
// Channel shift workaround LP_ANA_PERI.touch_approach.touch_approach_pad2 = touch_num;
LP_ANA_PERI.touch_approach.touch_approach_pad2 = touch_num + 1;
break; break;
default: default:
// invalid proximity channel // invalid proximity channel
@@ -921,8 +908,7 @@ static inline bool touch_ll_is_proximity_sensing_channel(uint32_t touch_num)
*/ */
static inline void touch_ll_sleep_set_channel_num(uint32_t touch_num) static inline void touch_ll_sleep_set_channel_num(uint32_t touch_num)
{ {
// Channel shift workaround LP_ANA_PERI.touch_slp0.touch_slp_pad = touch_num;
LP_ANA_PERI.touch_slp0.touch_slp_pad = touch_num + 1;
} }
/** /**

View File

@@ -1,49 +1,41 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _SOC_TOUCH_CHANNEL_H #ifndef _SOC_TOUCH_CHANNEL_H
#define _SOC_TOUCH_CHANNEL_H #define _SOC_TOUCH_CHANNEL_H
//Touch channels //Touch channels
#define TOUCH_PAD_GPIO4_CHANNEL TOUCH_PAD_NUM0 #define TOUCH_PAD_GPIO4_CHANNEL 0
#define TOUCH_PAD_NUM0_GPIO_NUM 4 #define TOUCH_PAD_NUM0_GPIO_NUM 4
#define TOUCH_PAD_GPIO0_CHANNEL TOUCH_PAD_NUM1 #define TOUCH_PAD_GPIO0_CHANNEL 1
#define TOUCH_PAD_NUM1_GPIO_NUM 0 #define TOUCH_PAD_NUM1_GPIO_NUM 0
#define TOUCH_PAD_GPIO2_CHANNEL TOUCH_PAD_NUM2 #define TOUCH_PAD_GPIO2_CHANNEL 2
#define TOUCH_PAD_NUM2_GPIO_NUM 2 #define TOUCH_PAD_NUM2_GPIO_NUM 2
#define TOUCH_PAD_GPIO15_CHANNEL TOUCH_PAD_NUM3 #define TOUCH_PAD_GPIO15_CHANNEL 3
#define TOUCH_PAD_NUM3_GPIO_NUM 15 #define TOUCH_PAD_NUM3_GPIO_NUM 15
#define TOUCH_PAD_GPIO13_CHANNEL TOUCH_PAD_NUM4 #define TOUCH_PAD_GPIO13_CHANNEL 4
#define TOUCH_PAD_NUM4_GPIO_NUM 13 #define TOUCH_PAD_NUM4_GPIO_NUM 13
#define TOUCH_PAD_GPIO12_CHANNEL TOUCH_PAD_NUM5 #define TOUCH_PAD_GPIO12_CHANNEL 5
#define TOUCH_PAD_NUM5_GPIO_NUM 12 #define TOUCH_PAD_NUM5_GPIO_NUM 12
#define TOUCH_PAD_GPIO14_CHANNEL TOUCH_PAD_NUM6 #define TOUCH_PAD_GPIO14_CHANNEL 6
#define TOUCH_PAD_NUM6_GPIO_NUM 14 #define TOUCH_PAD_NUM6_GPIO_NUM 14
#define TOUCH_PAD_GPIO27_CHANNEL TOUCH_PAD_NUM7 #define TOUCH_PAD_GPIO27_CHANNEL 7
#define TOUCH_PAD_NUM7_GPIO_NUM 27 #define TOUCH_PAD_NUM7_GPIO_NUM 27
#define TOUCH_PAD_GPIO33_CHANNEL TOUCH_PAD_NUM8 #define TOUCH_PAD_GPIO33_CHANNEL 8
#define TOUCH_PAD_NUM8_GPIO_NUM 33 #define TOUCH_PAD_NUM8_GPIO_NUM 33
#define TOUCH_PAD_GPIO32_CHANNEL TOUCH_PAD_NUM9 #define TOUCH_PAD_GPIO32_CHANNEL 9
#define TOUCH_PAD_NUM9_GPIO_NUM 32 #define TOUCH_PAD_NUM9_GPIO_NUM 32
#endif #endif

View File

@@ -1699,6 +1699,14 @@ config SOC_TOUCH_SENSOR_NUM
int int
default 14 default 14
config SOC_TOUCH_MIN_CHAN_ID
int
default 1
config SOC_TOUCH_MAX_CHAN_ID
int
default 14
config SOC_TOUCH_SUPPORT_SLEEP_WAKEUP config SOC_TOUCH_SUPPORT_SLEEP_WAKEUP
bool bool
default y default y

View File

@@ -629,6 +629,8 @@
/*-------------------------- TOUCH SENSOR CAPS -------------------------------*/ /*-------------------------- TOUCH SENSOR CAPS -------------------------------*/
#define SOC_TOUCH_SENSOR_VERSION (3) /*!< Hardware version of touch sensor */ #define SOC_TOUCH_SENSOR_VERSION (3) /*!< Hardware version of touch sensor */
#define SOC_TOUCH_SENSOR_NUM (14) /*!< Touch available channel number. Actually there are 15 Touch channels, but channel 14 is not pinned out, limit to 14 channels */ #define SOC_TOUCH_SENSOR_NUM (14) /*!< Touch available channel number. Actually there are 15 Touch channels, but channel 14 is not pinned out, limit to 14 channels */
#define SOC_TOUCH_MIN_CHAN_ID (1U) /*!< Touch minimum channel number */
#define SOC_TOUCH_MAX_CHAN_ID (14) /*!< Touch maximum channel number */
/* Touch Sensor Features */ /* Touch Sensor Features */
#define SOC_TOUCH_SUPPORT_SLEEP_WAKEUP (1) /*!< Touch sensor supports sleep awake */ #define SOC_TOUCH_SUPPORT_SLEEP_WAKEUP (1) /*!< Touch sensor supports sleep awake */

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 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -10,44 +10,44 @@
/* Note: T14 is an internal channel that does not have a corresponding external GPIO. */ /* Note: T14 is an internal channel that does not have a corresponding external GPIO. */
#define TOUCH_PAD_GPIO2_CHANNEL TOUCH_PAD_NUM0 #define TOUCH_PAD_GPIO2_CHANNEL 1
#define TOUCH_PAD_NUM0_GPIO_NUM 2 #define TOUCH_PAD_NUM1_GPIO_NUM 2
#define TOUCH_PAD_GPIO3_CHANNEL TOUCH_PAD_NUM1 #define TOUCH_PAD_GPIO3_CHANNEL 2
#define TOUCH_PAD_NUM1_GPIO_NUM 3 #define TOUCH_PAD_NUM2_GPIO_NUM 3
#define TOUCH_PAD_GPIO4_CHANNEL TOUCH_PAD_NUM2 #define TOUCH_PAD_GPIO4_CHANNEL 3
#define TOUCH_PAD_NUM2_GPIO_NUM 4 #define TOUCH_PAD_NUM3_GPIO_NUM 4
#define TOUCH_PAD_GPIO5_CHANNEL TOUCH_PAD_NUM3 #define TOUCH_PAD_GPIO5_CHANNEL 4
#define TOUCH_PAD_NUM3_GPIO_NUM 5 #define TOUCH_PAD_NUM4_GPIO_NUM 5
#define TOUCH_PAD_GPIO6_CHANNEL TOUCH_PAD_NUM4 #define TOUCH_PAD_GPIO6_CHANNEL 5
#define TOUCH_PAD_NUM4_GPIO_NUM 6 #define TOUCH_PAD_NUM5_GPIO_NUM 6
#define TOUCH_PAD_GPIO7_CHANNEL TOUCH_PAD_NUM5 #define TOUCH_PAD_GPIO7_CHANNEL 6
#define TOUCH_PAD_NUM5_GPIO_NUM 7 #define TOUCH_PAD_NUM6_GPIO_NUM 7
#define TOUCH_PAD_GPIO8_CHANNEL TOUCH_PAD_NUM6 #define TOUCH_PAD_GPIO8_CHANNEL 7
#define TOUCH_PAD_NUM6_GPIO_NUM 8 #define TOUCH_PAD_NUM7_GPIO_NUM 8
#define TOUCH_PAD_GPIO9_CHANNEL TOUCH_PAD_NUM7 #define TOUCH_PAD_GPIO9_CHANNEL 8
#define TOUCH_PAD_NUM7_GPIO_NUM 9 #define TOUCH_PAD_NUM8_GPIO_NUM 9
#define TOUCH_PAD_GPIO10_CHANNEL TOUCH_PAD_NUM8 #define TOUCH_PAD_GPIO10_CHANNEL 9
#define TOUCH_PAD_NUM8_GPIO_NUM 10 #define TOUCH_PAD_NUM9_GPIO_NUM 10
#define TOUCH_PAD_GPIO11_CHANNEL TOUCH_PAD_NUM9 #define TOUCH_PAD_GPIO11_CHANNEL 10
#define TOUCH_PAD_NUM9_GPIO_NUM 11 #define TOUCH_PAD_NUM10_GPIO_NUM 11
#define TOUCH_PAD_GPIO12_CHANNEL TOUCH_PAD_NUM10 #define TOUCH_PAD_GPIO12_CHANNEL 11
#define TOUCH_PAD_NUM10_GPIO_NUM 12 #define TOUCH_PAD_NUM11_GPIO_NUM 12
#define TOUCH_PAD_GPIO13_CHANNEL TOUCH_PAD_NUM11 #define TOUCH_PAD_GPIO13_CHANNEL 12
#define TOUCH_PAD_NUM11_GPIO_NUM 13 #define TOUCH_PAD_NUM12_GPIO_NUM 13
#define TOUCH_PAD_GPIO14_CHANNEL TOUCH_PAD_NUM12 #define TOUCH_PAD_GPIO14_CHANNEL 13
#define TOUCH_PAD_NUM12_GPIO_NUM 14 #define TOUCH_PAD_NUM13_GPIO_NUM 14
#define TOUCH_PAD_GPIO15_CHANNEL TOUCH_PAD_NUM13 #define TOUCH_PAD_GPIO15_CHANNEL 14
#define TOUCH_PAD_NUM13_GPIO_NUM 15 #define TOUCH_PAD_NUM14_GPIO_NUM 15

View File

@@ -7,9 +7,9 @@
#include "soc/touch_sensor_channel.h" #include "soc/touch_sensor_channel.h"
/* Store IO number corresponding to the Touch Sensor channel number. */ /* Store IO number corresponding to the Touch Sensor channel number. */
/* Note: T14 is an internal channel that does not have a corresponding external GPIO. */ /* Note: T0 is an internal channel that does not have a corresponding external GPIO. */
const int touch_sensor_channel_io_map[] = { const int touch_sensor_channel_io_map[] = {
TOUCH_PAD_NUM0_GPIO_NUM, -1,
TOUCH_PAD_NUM1_GPIO_NUM, TOUCH_PAD_NUM1_GPIO_NUM,
TOUCH_PAD_NUM2_GPIO_NUM, TOUCH_PAD_NUM2_GPIO_NUM,
TOUCH_PAD_NUM3_GPIO_NUM, TOUCH_PAD_NUM3_GPIO_NUM,
@@ -23,5 +23,5 @@ const int touch_sensor_channel_io_map[] = {
TOUCH_PAD_NUM11_GPIO_NUM, TOUCH_PAD_NUM11_GPIO_NUM,
TOUCH_PAD_NUM12_GPIO_NUM, TOUCH_PAD_NUM12_GPIO_NUM,
TOUCH_PAD_NUM13_GPIO_NUM, TOUCH_PAD_NUM13_GPIO_NUM,
-1, TOUCH_PAD_NUM14_GPIO_NUM,
}; };

View File

@@ -1,16 +1,8 @@
// Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2010-2025 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// You may obtain a copy of the License at */
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _SOC_TOUCH_CHANNEL_H #ifndef _SOC_TOUCH_CHANNEL_H
#define _SOC_TOUCH_CHANNEL_H #define _SOC_TOUCH_CHANNEL_H
@@ -19,46 +11,46 @@
/* Note: T0 is an internal channel that does not have a corresponding external GPIO. */ /* Note: T0 is an internal channel that does not have a corresponding external GPIO. */
#define TOUCH_PAD_GPIO1_CHANNEL TOUCH_PAD_NUM1 #define TOUCH_PAD_GPIO1_CHANNEL 1
#define TOUCH_PAD_NUM1_GPIO_NUM 1 #define TOUCH_PAD_NUM1_GPIO_NUM 1
#define TOUCH_PAD_GPIO2_CHANNEL TOUCH_PAD_NUM2 #define TOUCH_PAD_GPIO2_CHANNEL 2
#define TOUCH_PAD_NUM2_GPIO_NUM 2 #define TOUCH_PAD_NUM2_GPIO_NUM 2
#define TOUCH_PAD_GPIO3_CHANNEL TOUCH_PAD_NUM3 #define TOUCH_PAD_GPIO3_CHANNEL 3
#define TOUCH_PAD_NUM3_GPIO_NUM 3 #define TOUCH_PAD_NUM3_GPIO_NUM 3
#define TOUCH_PAD_GPIO4_CHANNEL TOUCH_PAD_NUM4 #define TOUCH_PAD_GPIO4_CHANNEL 4
#define TOUCH_PAD_NUM4_GPIO_NUM 4 #define TOUCH_PAD_NUM4_GPIO_NUM 4
#define TOUCH_PAD_GPIO5_CHANNEL TOUCH_PAD_NUM5 #define TOUCH_PAD_GPIO5_CHANNEL 5
#define TOUCH_PAD_NUM5_GPIO_NUM 5 #define TOUCH_PAD_NUM5_GPIO_NUM 5
#define TOUCH_PAD_GPIO6_CHANNEL TOUCH_PAD_NUM6 #define TOUCH_PAD_GPIO6_CHANNEL 6
#define TOUCH_PAD_NUM6_GPIO_NUM 6 #define TOUCH_PAD_NUM6_GPIO_NUM 6
#define TOUCH_PAD_GPIO7_CHANNEL TOUCH_PAD_NUM7 #define TOUCH_PAD_GPIO7_CHANNEL 7
#define TOUCH_PAD_NUM7_GPIO_NUM 7 #define TOUCH_PAD_NUM7_GPIO_NUM 7
#define TOUCH_PAD_GPIO8_CHANNEL TOUCH_PAD_NUM8 #define TOUCH_PAD_GPIO8_CHANNEL 8
#define TOUCH_PAD_NUM8_GPIO_NUM 8 #define TOUCH_PAD_NUM8_GPIO_NUM 8
#define TOUCH_PAD_GPIO9_CHANNEL TOUCH_PAD_NUM9 #define TOUCH_PAD_GPIO9_CHANNEL 9
#define TOUCH_PAD_NUM9_GPIO_NUM 9 #define TOUCH_PAD_NUM9_GPIO_NUM 9
#define TOUCH_PAD_GPIO10_CHANNEL TOUCH_PAD_NUM10 #define TOUCH_PAD_GPIO10_CHANNEL 10
#define TOUCH_PAD_NUM10_GPIO_NUM 10 #define TOUCH_PAD_NUM10_GPIO_NUM 10
#define TOUCH_PAD_GPIO11_CHANNEL TOUCH_PAD_NUM11 #define TOUCH_PAD_GPIO11_CHANNEL 11
#define TOUCH_PAD_NUM11_GPIO_NUM 11 #define TOUCH_PAD_NUM11_GPIO_NUM 11
#define TOUCH_PAD_GPIO12_CHANNEL TOUCH_PAD_NUM12 #define TOUCH_PAD_GPIO12_CHANNEL 12
#define TOUCH_PAD_NUM12_GPIO_NUM 12 #define TOUCH_PAD_NUM12_GPIO_NUM 12
#define TOUCH_PAD_GPIO13_CHANNEL TOUCH_PAD_NUM13 #define TOUCH_PAD_GPIO13_CHANNEL 13
#define TOUCH_PAD_NUM13_GPIO_NUM 13 #define TOUCH_PAD_NUM13_GPIO_NUM 13
#define TOUCH_PAD_GPIO14_CHANNEL TOUCH_PAD_NUM14 #define TOUCH_PAD_GPIO14_CHANNEL 14
#define TOUCH_PAD_NUM14_GPIO_NUM 14 #define TOUCH_PAD_NUM14_GPIO_NUM 14
#endif #endif

View File

@@ -1,46 +0,0 @@
// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
//Touch channels
#define TOUCH_PAD_GPIO4_CHANNEL TOUCH_PAD_NUM0
#define TOUCH_PAD_NUM0_GPIO_NUM 4
#define TOUCH_PAD_GPIO0_CHANNEL TOUCH_PAD_NUM1
#define TOUCH_PAD_NUM1_GPIO_NUM 0
#define TOUCH_PAD_GPIO2_CHANNEL TOUCH_PAD_NUM2
#define TOUCH_PAD_NUM2_GPIO_NUM 2
#define TOUCH_PAD_GPIO15_CHANNEL TOUCH_PAD_NUM3
#define TOUCH_PAD_NUM3_GPIO_NUM 15
#define TOUCH_PAD_GPIO13_CHANNEL TOUCH_PAD_NUM4
#define TOUCH_PAD_NUM4_GPIO_NUM 13
#define TOUCH_PAD_GPIO12_CHANNEL TOUCH_PAD_NUM5
#define TOUCH_PAD_NUM5_GPIO_NUM 12
#define TOUCH_PAD_GPIO14_CHANNEL TOUCH_PAD_NUM6
#define TOUCH_PAD_NUM6_GPIO_NUM 14
#define TOUCH_PAD_GPIO27_CHANNEL TOUCH_PAD_NUM7
#define TOUCH_PAD_NUM7_GPIO_NUM 27
#define TOUCH_PAD_GPIO33_CHANNEL TOUCH_PAD_NUM8
#define TOUCH_PAD_NUM8_GPIO_NUM 33
#define TOUCH_PAD_GPIO32_CHANNEL TOUCH_PAD_NUM9
#define TOUCH_PAD_NUM9_GPIO_NUM 32

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -10,44 +10,44 @@
/* Note: T0 is an internal channel that does not have a corresponding external GPIO. */ /* Note: T0 is an internal channel that does not have a corresponding external GPIO. */
#define TOUCH_PAD_GPIO1_CHANNEL TOUCH_PAD_NUM1 #define TOUCH_PAD_GPIO1_CHANNEL 1
#define TOUCH_PAD_NUM1_GPIO_NUM 1 #define TOUCH_PAD_NUM1_GPIO_NUM 1
#define TOUCH_PAD_GPIO2_CHANNEL TOUCH_PAD_NUM2 #define TOUCH_PAD_GPIO2_CHANNEL 2
#define TOUCH_PAD_NUM2_GPIO_NUM 2 #define TOUCH_PAD_NUM2_GPIO_NUM 2
#define TOUCH_PAD_GPIO3_CHANNEL TOUCH_PAD_NUM3 #define TOUCH_PAD_GPIO3_CHANNEL 3
#define TOUCH_PAD_NUM3_GPIO_NUM 3 #define TOUCH_PAD_NUM3_GPIO_NUM 3
#define TOUCH_PAD_GPIO4_CHANNEL TOUCH_PAD_NUM4 #define TOUCH_PAD_GPIO4_CHANNEL 4
#define TOUCH_PAD_NUM4_GPIO_NUM 4 #define TOUCH_PAD_NUM4_GPIO_NUM 4
#define TOUCH_PAD_GPIO5_CHANNEL TOUCH_PAD_NUM5 #define TOUCH_PAD_GPIO5_CHANNEL 5
#define TOUCH_PAD_NUM5_GPIO_NUM 5 #define TOUCH_PAD_NUM5_GPIO_NUM 5
#define TOUCH_PAD_GPIO6_CHANNEL TOUCH_PAD_NUM6 #define TOUCH_PAD_GPIO6_CHANNEL 6
#define TOUCH_PAD_NUM6_GPIO_NUM 6 #define TOUCH_PAD_NUM6_GPIO_NUM 6
#define TOUCH_PAD_GPIO7_CHANNEL TOUCH_PAD_NUM7 #define TOUCH_PAD_GPIO7_CHANNEL 7
#define TOUCH_PAD_NUM7_GPIO_NUM 7 #define TOUCH_PAD_NUM7_GPIO_NUM 7
#define TOUCH_PAD_GPIO8_CHANNEL TOUCH_PAD_NUM8 #define TOUCH_PAD_GPIO8_CHANNEL 8
#define TOUCH_PAD_NUM8_GPIO_NUM 8 #define TOUCH_PAD_NUM8_GPIO_NUM 8
#define TOUCH_PAD_GPIO9_CHANNEL TOUCH_PAD_NUM9 #define TOUCH_PAD_GPIO9_CHANNEL 9
#define TOUCH_PAD_NUM9_GPIO_NUM 9 #define TOUCH_PAD_NUM9_GPIO_NUM 9
#define TOUCH_PAD_GPIO10_CHANNEL TOUCH_PAD_NUM10 #define TOUCH_PAD_GPIO10_CHANNEL 10
#define TOUCH_PAD_NUM10_GPIO_NUM 10 #define TOUCH_PAD_NUM10_GPIO_NUM 10
#define TOUCH_PAD_GPIO11_CHANNEL TOUCH_PAD_NUM11 #define TOUCH_PAD_GPIO11_CHANNEL 11
#define TOUCH_PAD_NUM11_GPIO_NUM 11 #define TOUCH_PAD_NUM11_GPIO_NUM 11
#define TOUCH_PAD_GPIO12_CHANNEL TOUCH_PAD_NUM12 #define TOUCH_PAD_GPIO12_CHANNEL 12
#define TOUCH_PAD_NUM12_GPIO_NUM 12 #define TOUCH_PAD_NUM12_GPIO_NUM 12
#define TOUCH_PAD_GPIO13_CHANNEL TOUCH_PAD_NUM13 #define TOUCH_PAD_GPIO13_CHANNEL 13
#define TOUCH_PAD_NUM13_GPIO_NUM 13 #define TOUCH_PAD_NUM13_GPIO_NUM 13
#define TOUCH_PAD_GPIO14_CHANNEL TOUCH_PAD_NUM14 #define TOUCH_PAD_GPIO14_CHANNEL 14
#define TOUCH_PAD_NUM14_GPIO_NUM 14 #define TOUCH_PAD_NUM14_GPIO_NUM 14

View File

@@ -533,7 +533,6 @@ components/soc/esp32s2/include/soc/gpio_sig_map.h
components/soc/esp32s2/include/soc/memprot_defs.h components/soc/esp32s2/include/soc/memprot_defs.h
components/soc/esp32s2/include/soc/nrx_reg.h components/soc/esp32s2/include/soc/nrx_reg.h
components/soc/esp32s2/include/soc/soc_ulp.h components/soc/esp32s2/include/soc/soc_ulp.h
components/soc/esp32s2/include/soc/touch_sensor_channel.h
components/soc/esp32s2/include/soc/touch_sensor_pins.h components/soc/esp32s2/include/soc/touch_sensor_pins.h
components/soc/esp32s2/include/soc/uart_pins.h components/soc/esp32s2/include/soc/uart_pins.h
components/soc/esp32s2/include/soc/wdev_reg.h components/soc/esp32s2/include/soc/wdev_reg.h