From 79da851a4ce31c1d0e2d819aac0e04440a3cc893 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Thu, 22 May 2025 12:11:11 +0800 Subject: [PATCH] refactor(touch): adjust touch channel number on P4 from 0-13 to 1-14 --- .../common/touch_sens_common.c | 32 +++++----- .../hw_ver3/touch_version_specific.c | 3 +- .../touch_sens/main/test_touch_sens_common.c | 8 +-- .../hal/esp32p4/include/hal/touch_sensor_ll.h | 63 +++++++------------ .../esp32/include/soc/touch_sensor_channel.h | 38 +++++------ .../esp32p4/include/soc/Kconfig.soc_caps.in | 4 +- components/soc/esp32p4/include/soc/soc_caps.h | 4 +- .../include/soc/touch_sensor_channel.h | 58 ++++++++--------- components/soc/esp32p4/touch_sensor_periph.c | 6 +- .../include/soc/touch_sensor_channel.h | 56 +++++++---------- .../soc/esp32s3/include/soc/touch_channel.h | 46 -------------- .../include/soc/touch_sensor_channel.h | 40 ++++++------ .../peripherals/cap_touch_sens/esp32p4.inc | 30 ++++----- .../peripherals/cap_touch_sens/esp32p4.inc | 30 ++++----- tools/ci/check_copyright_ignore.txt | 2 - 15 files changed, 172 insertions(+), 248 deletions(-) delete mode 100644 components/soc/esp32s3/include/soc/touch_channel.h diff --git a/components/esp_driver_touch_sens/common/touch_sens_common.c b/components/esp_driver_touch_sens/common/touch_sens_common.c index f996073a92..7198657ac5 100644 --- a/components/esp_driver_touch_sens/common/touch_sens_common.c +++ b/components/esp_driver_touch_sens/common/touch_sens_common.c @@ -135,6 +135,7 @@ 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(ret_chan_handle); 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"); @@ -142,31 +143,31 @@ esp_err_t touch_sensor_new_channel(touch_sensor_handle_t sens_handle, int chan_i xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); TOUCH_GOTO_ON_FALSE_FSM(!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); - ESP_GOTO_ON_FALSE(sens_handle->ch[chan_id], ESP_ERR_NO_MEM, err2, TAG, "No memory for touch channel"); - sens_handle->ch[chan_id]->id = chan_id; - sens_handle->ch[chan_id]->base = sens_handle; + 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[ch_offset], ESP_ERR_NO_MEM, err2, TAG, "No memory for touch channel"); + sens_handle->ch[ch_offset]->id = chan_id; + sens_handle->ch[ch_offset]->base = sens_handle; #if SOC_TOUCH_SUPPORT_PROX_SENSING - sens_handle->ch[chan_id]->prox_id = 0; + sens_handle->ch[ch_offset]->prox_id = 0; #endif /* 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); touch_channel_pin_init(chan_id); TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); sens_handle->chan_mask |= 1 << chan_id; TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); - *ret_chan_handle = sens_handle->ch[chan_id]; + *ret_chan_handle = sens_handle->ch[ch_offset]; xSemaphoreGiveRecursive(sens_handle->mutex); return ret; err1: - free(sens_handle->ch[chan_id]); - sens_handle->ch[chan_id] = NULL; + free(sens_handle->ch[ch_offset]); + sens_handle->ch[ch_offset] = NULL; err2: xSemaphoreGiveRecursive(sens_handle->mutex); return ret; @@ -204,13 +205,14 @@ esp_err_t touch_sensor_del_channel(touch_channel_handle_t chan_handle) TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); } #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); - sens_handle->chan_mask &= ~(1UL << id); + sens_handle->chan_mask &= ~(1UL << chan_handle->id); TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); - free(g_touch->ch[id]); - g_touch->ch[id] = NULL; + free(g_touch->ch[ch_offset]); + g_touch->ch[ch_offset] = NULL; err: xSemaphoreGiveRecursive(sens_handle->mutex); return ret; @@ -375,7 +377,7 @@ esp_err_t touch_sensor_trigger_oneshot_scanning(touch_sensor_handle_t sens_handl FOR_EACH_TOUCH_CHANNEL(i) { if (sens_handle->ch[i]) { 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_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); while (!touch_ll_is_measure_done()) { diff --git a/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c b/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c index 67e7337033..360bcd4fd2 100644 --- a/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c +++ b/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c @@ -62,7 +62,8 @@ void IRAM_ATTR touch_priv_default_intr_handler(void *arg) touch_ll_interrupt_clear(status); touch_base_event_data_t data; 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 (!data.chan) { return; 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 b6f783dc5f..6ef420f5b8 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 @@ -61,20 +61,20 @@ TEST_CASE("touch_sens_install_uninstall_test", "[touch]") touch_sensor_filter_config_t filter_cfg = TOUCH_SENSOR_DEFAULT_FILTER_CONFIG(); TEST_ESP_OK(touch_sensor_config_filter(touch, &filter_cfg)); - for (int i = TOUCH_MIN_CHAN_ID; i <= TOUCH_MAX_CHAN_ID; i++) { - TEST_ESP_OK(touch_sensor_new_channel(touch, i, &s_chan_cfg, &touch_chan[i])); + for (int i = 0; i < TOUCH_TOTAL_CHAN_NUM; 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; 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_MIN_CHAN_ID, &s_chan_cfg, &fault_chan) == ESP_ERR_INVALID_STATE); TEST_ESP_OK(touch_sensor_enable(touch)); - TEST_ASSERT(touch_sensor_del_channel(touch_chan[TOUCH_MIN_CHAN_ID]) == ESP_ERR_INVALID_STATE); + TEST_ASSERT(touch_sensor_del_channel(touch_chan[0]) == ESP_ERR_INVALID_STATE); TEST_ESP_OK(touch_sensor_disable(touch)); TEST_ASSERT(touch_sensor_del_controller(touch) == ESP_ERR_INVALID_STATE); - for (int i = TOUCH_MIN_CHAN_ID; i <= TOUCH_MAX_CHAN_ID; i++) { + for (int i = 0; i < TOUCH_TOTAL_CHAN_NUM; i++) { TEST_ESP_OK(touch_sensor_del_channel(touch_chan[i])); } TEST_ESP_OK(touch_sensor_del_controller(touch)); diff --git a/components/hal/esp32p4/include/hal/touch_sensor_ll.h b/components/hal/esp32p4/include/hal/touch_sensor_ll.h index 95592ad332..292f88693e 100644 --- a/components/hal/esp32p4/include/hal/touch_sensor_ll.h +++ b/components/hal/esp32p4/include/hal/touch_sensor_ll.h @@ -45,7 +45,7 @@ extern "C" { #define TOUCH_LL_INTR_MASK_PROX_DONE BIT(5) #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_PAD_MEASURE_WAIT_MAX (0x7FFF) // The timer frequency is 8Mhz, the max value is 0xff @@ -262,8 +262,7 @@ static inline void touch_ll_trigger_oneshot_measurement(void) static inline void touch_ll_measure_channel_once(uint16_t chan_mask) { - // Channel shift workaround - LP_ANA_PERI.touch_mux1.touch_start = chan_mask << 1; + LP_ANA_PERI.touch_mux1.touch_start = chan_mask; } /** @@ -279,8 +278,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) { 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 + 1].thresh[sample_cfg_id], threshold, thresh); // codespell:ignore + HAL_FORCE_MODIFY_U32_REG_FIELD(LP_ANA_PERI.touch_padx_thn[touch_num].thresh[sample_cfg_id], threshold, thresh); // codespell:ignore } /** @@ -297,8 +295,7 @@ static inline void touch_ll_set_chan_active_threshold(uint32_t touch_num, uint8_ static inline uint32_t touch_ll_get_chan_active_threshold(uint32_t touch_num, uint8_t sample_cfg_id) { HAL_ASSERT(sample_cfg_id < SOC_TOUCH_SAMPLE_CFG_NUM); - // Channel shift workaround - return HAL_FORCE_READ_U32_REG_FIELD(LP_ANA_PERI.touch_padx_thn[touch_num + 1].thresh[sample_cfg_id], threshold); // codespell:ignore + return HAL_FORCE_READ_U32_REG_FIELD(LP_ANA_PERI.touch_padx_thn[touch_num].thresh[sample_cfg_id], threshold); // codespell:ignore } /** @@ -311,8 +308,8 @@ static inline uint32_t touch_ll_get_chan_active_threshold(uint32_t touch_num, ui __attribute__((always_inline)) static inline void touch_ll_enable_scan_mask(uint16_t chan_mask, bool enable) { - // Channel shift workaround: the lowest bit takes no effect - uint16_t mask = (chan_mask << 1) & TOUCH_LL_FULL_CHANNEL_MASK; + // the lowest bit takes no effect + uint16_t mask = chan_mask & TOUCH_LL_FULL_CHANNEL_MASK; uint16_t prev_mask = LP_ANA_PERI.touch_scan_ctrl1.touch_scan_pad_map; if (enable) { LP_ANA_PERI.touch_scan_ctrl1.touch_scan_pad_map = prev_mask | mask; @@ -335,8 +332,8 @@ static inline void touch_ll_enable_scan_mask(uint16_t chan_mask, bool enable) */ static inline void touch_ll_enable_channel_mask(uint16_t enable_mask) { - // Channel shift workaround: the lowest bit takes no effect - uint16_t mask = (enable_mask << 1) & TOUCH_LL_FULL_CHANNEL_MASK; + // the lowest bit takes no effect + 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_filter2.touch_outen = mask; } @@ -349,9 +346,8 @@ static inline void touch_ll_enable_channel_mask(uint16_t enable_mask) __attribute__((always_inline)) 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 << 1; - LP_ANA_PERI.touch_mux1.touch_start = chan_mask << 1; + LP_ANA_PERI.touch_mux1.touch_xpd = chan_mask; + LP_ANA_PERI.touch_mux1.touch_start = chan_mask; } /** @@ -362,8 +358,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) { uint32_t curr_mask = LP_ANA_PERI.touch_mux1.touch_xpd; - // Channel shift workaround - LP_ANA_PERI.touch_mux1.touch_xpd = (~(chan_mask << 1)) & curr_mask; + LP_ANA_PERI.touch_mux1.touch_xpd = (~chan_mask) & curr_mask; } /** @@ -374,8 +369,7 @@ static inline void touch_ll_channel_power_off(uint16_t chan_mask) __attribute__((always_inline)) static inline void touch_ll_get_active_channel_mask(uint32_t *active_mask) { - // Channel shift workaround - *active_mask = (LP_TOUCH.chn_status.pad_active >> 1); + *active_mask = LP_TOUCH.chn_status.pad_active; } /** @@ -407,8 +401,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); LP_ANA_PERI.touch_mux0.touch_freq_sel = sample_cfg_id; 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 + 1], pad_data); + *data = HAL_FORCE_READ_U32_REG_FIELD(LP_TOUCH.chn_data[touch_num], pad_data); } /** @@ -423,11 +416,6 @@ static inline bool touch_ll_is_measure_done(void) 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 * @@ -500,8 +488,11 @@ static inline void touch_ll_set_idle_channel_connect(touch_idle_conn_t type) __attribute__((always_inline)) static inline uint32_t touch_ll_get_current_meas_channel(void) { - // Channel shift workaround - return (uint32_t)(LP_TOUCH.chn_status.scan_curr - 1); + uint32_t curr_chan = LP_TOUCH.chn_status.scan_curr; + 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; } /** @@ -784,8 +775,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) { - // Channel shift workaround - LP_ANA_PERI.touch_scan_ctrl2.touch_out_ring = pad_num == TOUCH_LL_NULL_CHANNEL ? TOUCH_LL_NULL_CHANNEL : pad_num + 1; + LP_ANA_PERI.touch_scan_ctrl2.touch_out_ring = pad_num; } /** @@ -808,8 +798,7 @@ static inline void touch_ll_waterproof_enable(bool enable) */ static inline void touch_ll_waterproof_set_shield_chan_mask(uint32_t mask) { - // Channel shift workaround - LP_ANA_PERI.touch_mux0.touch_bufsel = mask << 1; + LP_ANA_PERI.touch_mux0.touch_bufsel = mask; } /** @@ -835,16 +824,13 @@ static inline void touch_ll_set_proximity_sensing_channel(uint8_t prox_chan, uin { switch (prox_chan) { case 0: - // Channel shift workaround - LP_ANA_PERI.touch_approach.touch_approach_pad0 = touch_num + 1; + LP_ANA_PERI.touch_approach.touch_approach_pad0 = touch_num; break; case 1: - // Channel shift workaround - LP_ANA_PERI.touch_approach.touch_approach_pad1 = touch_num + 1; + LP_ANA_PERI.touch_approach.touch_approach_pad1 = touch_num; break; case 2: - // Channel shift workaround - LP_ANA_PERI.touch_approach.touch_approach_pad2 = touch_num + 1; + LP_ANA_PERI.touch_approach.touch_approach_pad2 = touch_num; break; default: // invalid proximity channel @@ -935,8 +921,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) { - // Channel shift workaround - LP_ANA_PERI.touch_slp0.touch_slp_pad = touch_num + 1; + LP_ANA_PERI.touch_slp0.touch_slp_pad = touch_num; } /** diff --git a/components/soc/esp32/include/soc/touch_sensor_channel.h b/components/soc/esp32/include/soc/touch_sensor_channel.h index 02b712ae4a..fb53842370 100644 --- a/components/soc/esp32/include/soc/touch_sensor_channel.h +++ b/components/soc/esp32/include/soc/touch_sensor_channel.h @@ -1,49 +1,41 @@ -// Copyright 2019 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. +/* + * SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _SOC_TOUCH_CHANNEL_H #define _SOC_TOUCH_CHANNEL_H //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_GPIO0_CHANNEL TOUCH_PAD_NUM1 +#define TOUCH_PAD_GPIO0_CHANNEL 1 #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_GPIO15_CHANNEL TOUCH_PAD_NUM3 +#define TOUCH_PAD_GPIO15_CHANNEL 3 #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_GPIO12_CHANNEL TOUCH_PAD_NUM5 +#define TOUCH_PAD_GPIO12_CHANNEL 5 #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_GPIO27_CHANNEL TOUCH_PAD_NUM7 +#define TOUCH_PAD_GPIO27_CHANNEL 7 #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_GPIO32_CHANNEL TOUCH_PAD_NUM9 +#define TOUCH_PAD_GPIO32_CHANNEL 9 #define TOUCH_PAD_NUM9_GPIO_NUM 32 #endif diff --git a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in index 765055e011..3e880b3787 100644 --- a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in @@ -1741,11 +1741,11 @@ config SOC_TOUCH_SENSOR_NUM config SOC_TOUCH_MIN_CHAN_ID int - default 0 + default 1 config SOC_TOUCH_MAX_CHAN_ID int - default 13 + default 14 config SOC_TOUCH_SUPPORT_SLEEP_WAKEUP bool diff --git a/components/soc/esp32p4/include/soc/soc_caps.h b/components/soc/esp32p4/include/soc/soc_caps.h index 185e31c1c9..86dad09568 100644 --- a/components/soc/esp32p4/include/soc/soc_caps.h +++ b/components/soc/esp32p4/include/soc/soc_caps.h @@ -639,8 +639,8 @@ /*-------------------------- TOUCH SENSOR CAPS -------------------------------*/ #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_MIN_CHAN_ID (0U) /*!< Touch minimum channel number */ -#define SOC_TOUCH_MAX_CHAN_ID (13) /*!< Touch maximum channel number */ +#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 */ #define SOC_TOUCH_SUPPORT_SLEEP_WAKEUP (1) /*!< Touch sensor supports sleep awake */ diff --git a/components/soc/esp32p4/include/soc/touch_sensor_channel.h b/components/soc/esp32p4/include/soc/touch_sensor_channel.h index 77643a5742..ff009b31ed 100644 --- a/components/soc/esp32p4/include/soc/touch_sensor_channel.h +++ b/components/soc/esp32p4/include/soc/touch_sensor_channel.h @@ -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 */ @@ -10,44 +10,44 @@ /* 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_NUM0_GPIO_NUM 2 +#define TOUCH_PAD_GPIO2_CHANNEL 1 +#define TOUCH_PAD_NUM1_GPIO_NUM 2 -#define TOUCH_PAD_GPIO3_CHANNEL TOUCH_PAD_NUM1 -#define TOUCH_PAD_NUM1_GPIO_NUM 3 +#define TOUCH_PAD_GPIO3_CHANNEL 2 +#define TOUCH_PAD_NUM2_GPIO_NUM 3 -#define TOUCH_PAD_GPIO4_CHANNEL TOUCH_PAD_NUM2 -#define TOUCH_PAD_NUM2_GPIO_NUM 4 +#define TOUCH_PAD_GPIO4_CHANNEL 3 +#define TOUCH_PAD_NUM3_GPIO_NUM 4 -#define TOUCH_PAD_GPIO5_CHANNEL TOUCH_PAD_NUM3 -#define TOUCH_PAD_NUM3_GPIO_NUM 5 +#define TOUCH_PAD_GPIO5_CHANNEL 4 +#define TOUCH_PAD_NUM4_GPIO_NUM 5 -#define TOUCH_PAD_GPIO6_CHANNEL TOUCH_PAD_NUM4 -#define TOUCH_PAD_NUM4_GPIO_NUM 6 +#define TOUCH_PAD_GPIO6_CHANNEL 5 +#define TOUCH_PAD_NUM5_GPIO_NUM 6 -#define TOUCH_PAD_GPIO7_CHANNEL TOUCH_PAD_NUM5 -#define TOUCH_PAD_NUM5_GPIO_NUM 7 +#define TOUCH_PAD_GPIO7_CHANNEL 6 +#define TOUCH_PAD_NUM6_GPIO_NUM 7 -#define TOUCH_PAD_GPIO8_CHANNEL TOUCH_PAD_NUM6 -#define TOUCH_PAD_NUM6_GPIO_NUM 8 +#define TOUCH_PAD_GPIO8_CHANNEL 7 +#define TOUCH_PAD_NUM7_GPIO_NUM 8 -#define TOUCH_PAD_GPIO9_CHANNEL TOUCH_PAD_NUM7 -#define TOUCH_PAD_NUM7_GPIO_NUM 9 +#define TOUCH_PAD_GPIO9_CHANNEL 8 +#define TOUCH_PAD_NUM8_GPIO_NUM 9 -#define TOUCH_PAD_GPIO10_CHANNEL TOUCH_PAD_NUM8 -#define TOUCH_PAD_NUM8_GPIO_NUM 10 +#define TOUCH_PAD_GPIO10_CHANNEL 9 +#define TOUCH_PAD_NUM9_GPIO_NUM 10 -#define TOUCH_PAD_GPIO11_CHANNEL TOUCH_PAD_NUM9 -#define TOUCH_PAD_NUM9_GPIO_NUM 11 +#define TOUCH_PAD_GPIO11_CHANNEL 10 +#define TOUCH_PAD_NUM10_GPIO_NUM 11 -#define TOUCH_PAD_GPIO12_CHANNEL TOUCH_PAD_NUM10 -#define TOUCH_PAD_NUM10_GPIO_NUM 12 +#define TOUCH_PAD_GPIO12_CHANNEL 11 +#define TOUCH_PAD_NUM11_GPIO_NUM 12 -#define TOUCH_PAD_GPIO13_CHANNEL TOUCH_PAD_NUM11 -#define TOUCH_PAD_NUM11_GPIO_NUM 13 +#define TOUCH_PAD_GPIO13_CHANNEL 12 +#define TOUCH_PAD_NUM12_GPIO_NUM 13 -#define TOUCH_PAD_GPIO14_CHANNEL TOUCH_PAD_NUM12 -#define TOUCH_PAD_NUM12_GPIO_NUM 14 +#define TOUCH_PAD_GPIO14_CHANNEL 13 +#define TOUCH_PAD_NUM13_GPIO_NUM 14 -#define TOUCH_PAD_GPIO15_CHANNEL TOUCH_PAD_NUM13 -#define TOUCH_PAD_NUM13_GPIO_NUM 15 +#define TOUCH_PAD_GPIO15_CHANNEL 14 +#define TOUCH_PAD_NUM14_GPIO_NUM 15 diff --git a/components/soc/esp32p4/touch_sensor_periph.c b/components/soc/esp32p4/touch_sensor_periph.c index 0cd872effe..1cba03337b 100644 --- a/components/soc/esp32p4/touch_sensor_periph.c +++ b/components/soc/esp32p4/touch_sensor_periph.c @@ -7,9 +7,9 @@ #include "soc/touch_sensor_channel.h" /* 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[] = { - TOUCH_PAD_NUM0_GPIO_NUM, + -1, TOUCH_PAD_NUM1_GPIO_NUM, TOUCH_PAD_NUM2_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_NUM12_GPIO_NUM, TOUCH_PAD_NUM13_GPIO_NUM, - -1, + TOUCH_PAD_NUM14_GPIO_NUM, }; diff --git a/components/soc/esp32s2/include/soc/touch_sensor_channel.h b/components/soc/esp32s2/include/soc/touch_sensor_channel.h index a405a6bd1c..61197c92c4 100644 --- a/components/soc/esp32s2/include/soc/touch_sensor_channel.h +++ b/components/soc/esp32s2/include/soc/touch_sensor_channel.h @@ -1,16 +1,8 @@ -// Copyright 2010-2016 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. +/* + * SPDX-FileCopyrightText: 2010-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _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. */ -#define TOUCH_PAD_GPIO1_CHANNEL TOUCH_PAD_NUM1 +#define TOUCH_PAD_GPIO1_CHANNEL 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_GPIO3_CHANNEL TOUCH_PAD_NUM3 +#define TOUCH_PAD_GPIO3_CHANNEL 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_GPIO5_CHANNEL TOUCH_PAD_NUM5 +#define TOUCH_PAD_GPIO5_CHANNEL 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_GPIO7_CHANNEL TOUCH_PAD_NUM7 +#define TOUCH_PAD_GPIO7_CHANNEL 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_GPIO9_CHANNEL TOUCH_PAD_NUM9 +#define TOUCH_PAD_GPIO9_CHANNEL 9 #define TOUCH_PAD_NUM9_GPIO_NUM 9 -#define TOUCH_PAD_GPIO10_CHANNEL TOUCH_PAD_NUM10 -#define TOUCH_PAD_NUM10_GPIO_NUM 10 +#define TOUCH_PAD_GPIO10_CHANNEL 10 +#define TOUCH_PAD_NUM10_GPIO_NUM 10 -#define TOUCH_PAD_GPIO11_CHANNEL TOUCH_PAD_NUM11 -#define TOUCH_PAD_NUM11_GPIO_NUM 11 +#define TOUCH_PAD_GPIO11_CHANNEL 11 +#define TOUCH_PAD_NUM11_GPIO_NUM 11 -#define TOUCH_PAD_GPIO12_CHANNEL TOUCH_PAD_NUM12 -#define TOUCH_PAD_NUM12_GPIO_NUM 12 +#define TOUCH_PAD_GPIO12_CHANNEL 12 +#define TOUCH_PAD_NUM12_GPIO_NUM 12 -#define TOUCH_PAD_GPIO13_CHANNEL TOUCH_PAD_NUM13 -#define TOUCH_PAD_NUM13_GPIO_NUM 13 +#define TOUCH_PAD_GPIO13_CHANNEL 13 +#define TOUCH_PAD_NUM13_GPIO_NUM 13 -#define TOUCH_PAD_GPIO14_CHANNEL TOUCH_PAD_NUM14 -#define TOUCH_PAD_NUM14_GPIO_NUM 14 +#define TOUCH_PAD_GPIO14_CHANNEL 14 +#define TOUCH_PAD_NUM14_GPIO_NUM 14 #endif diff --git a/components/soc/esp32s3/include/soc/touch_channel.h b/components/soc/esp32s3/include/soc/touch_channel.h deleted file mode 100644 index d0921c59ae..0000000000 --- a/components/soc/esp32s3/include/soc/touch_channel.h +++ /dev/null @@ -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 diff --git a/components/soc/esp32s3/include/soc/touch_sensor_channel.h b/components/soc/esp32s3/include/soc/touch_sensor_channel.h index d5065eac4f..88d58d66b9 100644 --- a/components/soc/esp32s3/include/soc/touch_sensor_channel.h +++ b/components/soc/esp32s3/include/soc/touch_sensor_channel.h @@ -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 */ @@ -10,44 +10,44 @@ /* 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_GPIO2_CHANNEL TOUCH_PAD_NUM2 +#define TOUCH_PAD_GPIO2_CHANNEL 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_GPIO4_CHANNEL TOUCH_PAD_NUM4 +#define TOUCH_PAD_GPIO4_CHANNEL 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_GPIO6_CHANNEL TOUCH_PAD_NUM6 +#define TOUCH_PAD_GPIO6_CHANNEL 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_GPIO8_CHANNEL TOUCH_PAD_NUM8 +#define TOUCH_PAD_GPIO8_CHANNEL 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_GPIO10_CHANNEL TOUCH_PAD_NUM10 -#define TOUCH_PAD_NUM10_GPIO_NUM 10 +#define TOUCH_PAD_GPIO10_CHANNEL 10 +#define TOUCH_PAD_NUM10_GPIO_NUM 10 -#define TOUCH_PAD_GPIO11_CHANNEL TOUCH_PAD_NUM11 -#define TOUCH_PAD_NUM11_GPIO_NUM 11 +#define TOUCH_PAD_GPIO11_CHANNEL 11 +#define TOUCH_PAD_NUM11_GPIO_NUM 11 -#define TOUCH_PAD_GPIO12_CHANNEL TOUCH_PAD_NUM12 -#define TOUCH_PAD_NUM12_GPIO_NUM 12 +#define TOUCH_PAD_GPIO12_CHANNEL 12 +#define TOUCH_PAD_NUM12_GPIO_NUM 12 -#define TOUCH_PAD_GPIO13_CHANNEL TOUCH_PAD_NUM13 -#define TOUCH_PAD_NUM13_GPIO_NUM 13 +#define TOUCH_PAD_GPIO13_CHANNEL 13 +#define TOUCH_PAD_NUM13_GPIO_NUM 13 -#define TOUCH_PAD_GPIO14_CHANNEL TOUCH_PAD_NUM14 -#define TOUCH_PAD_NUM14_GPIO_NUM 14 +#define TOUCH_PAD_GPIO14_CHANNEL 14 +#define TOUCH_PAD_NUM14_GPIO_NUM 14 diff --git a/docs/en/api-reference/peripherals/cap_touch_sens/esp32p4.inc b/docs/en/api-reference/peripherals/cap_touch_sens/esp32p4.inc index e02da617bb..44fbcba435 100644 --- a/docs/en/api-reference/peripherals/cap_touch_sens/esp32p4.inc +++ b/docs/en/api-reference/peripherals/cap_touch_sens/esp32p4.inc @@ -16,49 +16,49 @@ * - Channel - GPIO - * - CH0 + * - CH1 - IO2 - * - CH1 + * - CH2 - IO3 - * - CH2 + * - CH3 - IO4 - * - CH3 + * - CH4 - IO5 - * - CH4 + * - CH5 - IO6 - * - CH5 + * - CH6 - IO7 - * - CH6 + * - CH7 - IO8 - * - CH7 + * - CH8 - IO9 - * - CH8 + * - CH9 - IO10 - * - CH9 + * - CH10 - IO11 - * - CH10 + * - CH11 - IO12 - * - CH11 + * - CH12 - IO13 - * - CH12 + * - CH13 - IO14 - * - CH13 + * - CH14 - IO15 - * - CH14 + * - CH15 - Internal --- diff --git a/docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32p4.inc b/docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32p4.inc index dcaf2a6ba7..4a84bed720 100644 --- a/docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32p4.inc +++ b/docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32p4.inc @@ -16,49 +16,49 @@ * - 通道 - GPIO - * - CH0 + * - CH1 - IO2 - * - CH1 + * - CH2 - IO3 - * - CH2 + * - CH3 - IO4 - * - CH3 + * - CH4 - IO5 - * - CH4 + * - CH5 - IO6 - * - CH5 + * - CH6 - IO7 - * - CH6 + * - CH7 - IO8 - * - CH7 + * - CH8 - IO9 - * - CH8 + * - CH9 - IO10 - * - CH9 + * - CH10 - IO11 - * - CH10 + * - CH11 - IO12 - * - CH11 + * - CH12 - IO13 - * - CH12 + * - CH13 - IO14 - * - CH13 + * - CH14 - IO15 - * - CH14 + * - CH15 - 未引出 --- diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 8d469123c2..b28ec6748a 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -508,12 +508,10 @@ components/soc/esp32/include/soc/gpio_sig_map.h components/soc/esp32/include/soc/reset_reasons.h components/soc/esp32/include/soc/sdmmc_pins.h components/soc/esp32/include/soc/soc_ulp.h -components/soc/esp32/include/soc/touch_sensor_channel.h components/soc/esp32s2/include/soc/fe_reg.h components/soc/esp32s2/include/soc/memprot_defs.h components/soc/esp32s2/include/soc/nrx_reg.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/spi_flash/include/spi_flash_chip_generic.h components/spi_flash/spi_flash_chip_boya.c