mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-03 20:35:33 +02:00
refactor(touch): clean up touch sensor caps
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "esp_log.h"
|
||||
#include "sys/lock.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/soc_caps_full.h"
|
||||
#include "soc/periph_defs.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
@@ -51,8 +52,8 @@ static SemaphoreHandle_t rtc_touch_mux = NULL;
|
||||
|
||||
static __attribute__((unused)) const char *TOUCH_TAG = "TOUCH_SENSOR";
|
||||
|
||||
#define TOUCH_CHANNEL_CHECK(channel) ESP_RETURN_ON_FALSE(channel < SOC_TOUCH_SENSOR_NUM, ESP_ERR_INVALID_ARG, TOUCH_TAG, "Touch channel error");
|
||||
#define TOUCH_CHANNEL_CHECK_ISR(channel) ESP_RETURN_ON_FALSE_ISR(channel < SOC_TOUCH_SENSOR_NUM, ESP_ERR_INVALID_ARG, TOUCH_TAG, "Touch channel error");
|
||||
#define TOUCH_CHANNEL_CHECK(channel) ESP_RETURN_ON_FALSE(channel < SOC_MODULE_ATTR(TOUCH, CHAN_NUM), ESP_ERR_INVALID_ARG, TOUCH_TAG, "Touch channel error");
|
||||
#define TOUCH_CHANNEL_CHECK_ISR(channel) ESP_RETURN_ON_FALSE_ISR(channel < SOC_MODULE_ATTR(TOUCH, CHAN_NUM), ESP_ERR_INVALID_ARG, TOUCH_TAG, "Touch channel error");
|
||||
#define TOUCH_NULL_POINTER_CHECK(p, name) ESP_RETURN_ON_FALSE((p), ESP_ERR_INVALID_ARG, TOUCH_TAG, "input param '"name"' is NULL")
|
||||
#define TOUCH_NULL_POINTER_CHECK_ISR(p, name) ESP_RETURN_ON_FALSE_ISR((p), ESP_ERR_INVALID_ARG, TOUCH_TAG, "input param '"name"' is NULL")
|
||||
#define TOUCH_PARAM_CHECK_STR(s) ""s" parameter error"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2016-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "esp_log.h"
|
||||
#include "sys/lock.h"
|
||||
#include "soc/soc_pins.h"
|
||||
#include "soc/soc_caps_full.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
@@ -39,7 +40,7 @@
|
||||
static __attribute__((unused)) const char *TOUCH_TAG = "TOUCH_SENSOR";
|
||||
|
||||
#define TOUCH_CHANNEL_CHECK(channel) do { \
|
||||
ESP_RETURN_ON_FALSE(channel < SOC_TOUCH_SENSOR_NUM && channel >= 0, ESP_ERR_INVALID_ARG, TOUCH_TAG, "Touch channel error"); \
|
||||
ESP_RETURN_ON_FALSE(channel < SOC_MODULE_ATTR(TOUCH, CHAN_NUM) && channel >= 0, ESP_ERR_INVALID_ARG, TOUCH_TAG, "Touch channel error"); \
|
||||
ESP_RETURN_ON_FALSE(channel != SOC_TOUCH_DENOISE_CHANNEL, ESP_ERR_INVALID_ARG, TOUCH_TAG, "TOUCH0 is internal denoise channel"); \
|
||||
} while (0);
|
||||
#define TOUCH_CH_MASK_CHECK(mask) ESP_RETURN_ON_FALSE((mask <= TOUCH_PAD_BIT_MASK_ALL), ESP_ERR_INVALID_ARG, TOUCH_TAG, "touch channel bitmask error");
|
||||
@@ -101,7 +102,7 @@ esp_err_t touch_pad_isr_register(intr_handler_t fn, void *arg, touch_pad_intr_ma
|
||||
if (intr_mask & TOUCH_PAD_INTR_MASK_TIMEOUT) {
|
||||
en_msk |= RTC_CNTL_TOUCH_TIMEOUT_INT_ST_M;
|
||||
}
|
||||
#if SOC_TOUCH_PROXIMITY_MEAS_DONE_SUPPORTED
|
||||
#if TOUCH_LL_SUPPORT_PROX_DONE
|
||||
if (intr_mask & TOUCH_PAD_INTR_MASK_PROXI_MEAS_DONE) {
|
||||
en_msk |= RTC_CNTL_TOUCH_APPROACH_LOOP_DONE_INT_ST_M;
|
||||
}
|
||||
@@ -472,7 +473,7 @@ esp_err_t touch_pad_denoise_read_data(uint32_t *data)
|
||||
esp_err_t touch_pad_waterproof_set_config(const touch_pad_waterproof_t *waterproof)
|
||||
{
|
||||
TOUCH_NULL_POINTER_CHECK(waterproof, "waterproof");
|
||||
ESP_RETURN_ON_FALSE(waterproof->guard_ring_pad < SOC_TOUCH_SENSOR_NUM, ESP_ERR_INVALID_ARG, TOUCH_TAG, TOUCH_PARAM_CHECK_STR("pad"));
|
||||
ESP_RETURN_ON_FALSE(waterproof->guard_ring_pad < SOC_MODULE_ATTR(TOUCH, CHAN_NUM), ESP_ERR_INVALID_ARG, TOUCH_TAG, TOUCH_PARAM_CHECK_STR("pad"));
|
||||
ESP_RETURN_ON_FALSE(waterproof->shield_driver < TOUCH_PAD_SHIELD_DRV_MAX, ESP_ERR_INVALID_ARG, TOUCH_TAG, TOUCH_PARAM_CHECK_STR("shield_driver"));
|
||||
|
||||
TOUCH_ENTER_CRITICAL();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2016-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "esp_log.h"
|
||||
#include "sys/lock.h"
|
||||
#include "soc/soc_pins.h"
|
||||
#include "soc/soc_caps_full.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
@@ -39,7 +40,7 @@
|
||||
static __attribute__((unused)) const char *TOUCH_TAG = "TOUCH_SENSOR";
|
||||
|
||||
#define TOUCH_CHANNEL_CHECK(channel) do { \
|
||||
ESP_RETURN_ON_FALSE(channel < SOC_TOUCH_SENSOR_NUM && channel >= 0, ESP_ERR_INVALID_ARG, TOUCH_TAG, "Touch channel error"); \
|
||||
ESP_RETURN_ON_FALSE(channel < SOC_MODULE_ATTR(TOUCH, CHAN_NUM) && channel >= 0, ESP_ERR_INVALID_ARG, TOUCH_TAG, "Touch channel error"); \
|
||||
ESP_RETURN_ON_FALSE(channel != SOC_TOUCH_DENOISE_CHANNEL, ESP_ERR_INVALID_ARG, TOUCH_TAG, "TOUCH0 is internal denoise channel"); \
|
||||
} while (0);
|
||||
#define TOUCH_CH_MASK_CHECK(mask) ESP_RETURN_ON_FALSE((mask <= TOUCH_PAD_BIT_MASK_ALL), ESP_ERR_INVALID_ARG, TOUCH_TAG, "touch channel bitmask error");
|
||||
@@ -80,7 +81,7 @@ esp_err_t touch_pad_isr_register(intr_handler_t fn, void *arg, touch_pad_intr_ma
|
||||
if (intr_mask & TOUCH_PAD_INTR_MASK_TIMEOUT) {
|
||||
en_msk |= RTC_CNTL_TOUCH_TIMEOUT_INT_ST_M;
|
||||
}
|
||||
#if SOC_TOUCH_PROXIMITY_MEAS_DONE_SUPPORTED
|
||||
#if TOUCH_LL_SUPPORT_PROX_DONE
|
||||
if (intr_mask & TOUCH_PAD_INTR_MASK_PROXI_MEAS_DONE) {
|
||||
en_msk |= RTC_CNTL_TOUCH_APPROACH_LOOP_DONE_INT_ST_M;
|
||||
}
|
||||
@@ -445,7 +446,7 @@ esp_err_t touch_pad_denoise_read_data(uint32_t *data)
|
||||
esp_err_t touch_pad_waterproof_set_config(const touch_pad_waterproof_t *waterproof)
|
||||
{
|
||||
TOUCH_NULL_POINTER_CHECK(waterproof, "waterproof");
|
||||
ESP_RETURN_ON_FALSE(waterproof->guard_ring_pad < SOC_TOUCH_SENSOR_NUM, ESP_ERR_INVALID_ARG, TOUCH_TAG, TOUCH_PARAM_CHECK_STR("pad"));
|
||||
ESP_RETURN_ON_FALSE(waterproof->guard_ring_pad < SOC_MODULE_ATTR(TOUCH, CHAN_NUM), ESP_ERR_INVALID_ARG, TOUCH_TAG, TOUCH_PARAM_CHECK_STR("pad"));
|
||||
ESP_RETURN_ON_FALSE(waterproof->shield_driver < TOUCH_PAD_SHIELD_DRV_MAX, ESP_ERR_INVALID_ARG, TOUCH_TAG, TOUCH_PARAM_CHECK_STR("shield_driver"));
|
||||
|
||||
TOUCH_ENTER_CRITICAL();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2016-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "esp_log.h"
|
||||
#include "sys/lock.h"
|
||||
#include "soc/soc_pins.h"
|
||||
#include "soc/soc_caps_full.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/timers.h"
|
||||
@@ -29,18 +30,18 @@ static const char *TOUCH_TAG = "TOUCH_SENSOR";
|
||||
})
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#define TOUCH_CHANNEL_CHECK(channel) do { \
|
||||
TOUCH_CHECK(channel < SOC_TOUCH_SENSOR_NUM && channel >= 0, "Touch channel error", ESP_ERR_INVALID_ARG); \
|
||||
TOUCH_CHECK(channel < SOC_MODULE_ATTR(TOUCH, CHAN_NUM) && channel >= 0, "Touch channel error", ESP_ERR_INVALID_ARG); \
|
||||
} while (0);
|
||||
#else // !CONFIG_IDF_TARGET_ESP32
|
||||
#define TOUCH_CHANNEL_CHECK(channel) do { \
|
||||
TOUCH_CHECK(channel < SOC_TOUCH_SENSOR_NUM && channel >= 0, "Touch channel error", ESP_ERR_INVALID_ARG); \
|
||||
TOUCH_CHECK(channel < SOC_MODULE_ATTR(TOUCH, CHAN_NUM) && channel >= 0, "Touch channel error", ESP_ERR_INVALID_ARG); \
|
||||
TOUCH_CHECK(channel != SOC_TOUCH_DENOISE_CHANNEL, "TOUCH0 is internal denoise channel", ESP_ERR_INVALID_ARG); \
|
||||
} while (0);
|
||||
#endif // CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#define TOUCH_GET_IO_NUM(channel) (touch_sensor_channel_io_map[channel])
|
||||
|
||||
_Static_assert(TOUCH_PAD_MAX == SOC_TOUCH_SENSOR_NUM, "Touch sensor channel number not equal to chip capabilities");
|
||||
_Static_assert(TOUCH_PAD_MAX == SOC_MODULE_ATTR(TOUCH, CHAN_NUM), "Touch sensor channel number not equal to chip capabilities");
|
||||
|
||||
extern portMUX_TYPE rtc_spinlock; //TODO: Will be placed in the appropriate position after the rtc module is finished.
|
||||
#define TOUCH_ENTER_CRITICAL() portENTER_CRITICAL(&rtc_spinlock)
|
||||
@@ -87,7 +88,7 @@ esp_err_t touch_pad_get_voltage(touch_high_volt_t *refh, touch_low_volt_t *refl,
|
||||
|
||||
esp_err_t touch_pad_set_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t slope, touch_tie_opt_t opt)
|
||||
{
|
||||
TOUCH_CHECK(touch_num < SOC_TOUCH_SENSOR_NUM, "Touch channel error", ESP_ERR_INVALID_ARG);
|
||||
TOUCH_CHECK(touch_num < SOC_MODULE_ATTR(TOUCH, CHAN_NUM), "Touch channel error", ESP_ERR_INVALID_ARG);
|
||||
TOUCH_CHECK(slope < TOUCH_PAD_SLOPE_MAX, "touch slope error", ESP_ERR_INVALID_ARG);
|
||||
TOUCH_CHECK(opt < TOUCH_PAD_TIE_OPT_MAX, "touch opt error", ESP_ERR_INVALID_ARG);
|
||||
|
||||
@@ -104,7 +105,7 @@ esp_err_t touch_pad_set_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t slope,
|
||||
|
||||
esp_err_t touch_pad_get_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t *slope, touch_tie_opt_t *opt)
|
||||
{
|
||||
TOUCH_CHECK(touch_num < SOC_TOUCH_SENSOR_NUM, "Touch channel error", ESP_ERR_INVALID_ARG);
|
||||
TOUCH_CHECK(touch_num < SOC_MODULE_ATTR(TOUCH, CHAN_NUM), "Touch channel error", ESP_ERR_INVALID_ARG);
|
||||
|
||||
touch_hal_meas_mode_t meas = {0};
|
||||
TOUCH_ENTER_CRITICAL();
|
||||
|
||||
@@ -84,7 +84,7 @@ extern portMUX_TYPE g_touch_spinlock;
|
||||
*
|
||||
*/
|
||||
struct touch_sensor_s {
|
||||
touch_channel_handle_t ch[SOC_TOUCH_SENSOR_NUM]; /*!< Touch sensor channel handles, will be NULL if the channel is not registered */
|
||||
touch_channel_handle_t ch[SOC_MODULE_ATTR(TOUCH, CHAN_NUM)]; /*!< Touch sensor channel handles, will be NULL if the channel is not registered */
|
||||
uint32_t chan_mask; /*!< Enabled channel mask, corresponding bit will be set if the channel is registered */
|
||||
uint32_t src_freq_hz; /*!< Source clock frequency */
|
||||
uint32_t interval_freq_hz; /*!< Frequency of the interval clock */
|
||||
|
||||
@@ -68,7 +68,7 @@ void IRAM_ATTR touch_priv_default_intr_handler(void *arg)
|
||||
return;
|
||||
}
|
||||
/* It actually won't be out of range in the real environment, but limit the range to pass the coverity check */
|
||||
uint32_t curr_chan_offset = (curr_chan >= SOC_TOUCH_SENSOR_NUM ? SOC_TOUCH_SENSOR_NUM - 1 : curr_chan) - TOUCH_MIN_CHAN_ID;
|
||||
uint32_t curr_chan_offset = (curr_chan >= SOC_MODULE_ATTR(TOUCH, CHAN_NUM) ? SOC_MODULE_ATTR(TOUCH, CHAN_NUM) - 1 : curr_chan) - TOUCH_MIN_CHAN_ID;
|
||||
data.chan = g_touch->ch[curr_chan_offset];
|
||||
/* If the channel is not registered, return directly */
|
||||
if (!data.chan) {
|
||||
@@ -77,7 +77,7 @@ void IRAM_ATTR touch_priv_default_intr_handler(void *arg)
|
||||
data.chan_id = data.chan->id;
|
||||
|
||||
if (status & TOUCH_LL_INTR_MASK_DONE) {
|
||||
#if !SOC_TOUCH_PROXIMITY_MEAS_DONE_SUPPORTED
|
||||
#if !TOUCH_LL_SUPPORT_PROX_DONE
|
||||
/* For the target like ESP32-S2 that don't support proximity done interrupt,
|
||||
Simulate the interrupt by software by judge the scan times. */
|
||||
if (data.chan->prox_id > 0 &&
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "soc/rtc_io_struct.h"
|
||||
#include "soc/rtc_cntl_struct.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/soc_caps_full.h"
|
||||
#include "hal/touch_sens_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -33,7 +34,7 @@ extern "C" {
|
||||
#define TOUCH_LL_BIT_SWAP(data, n, m) (((data >> n) & 0x1) == ((data >> m) & 0x1) ? (data) : ((data) ^ ((0x1 <<n) | (0x1 << m))))
|
||||
#define TOUCH_LL_BITS_SWAP(v) TOUCH_LL_BIT_SWAP(v, 8, 9)
|
||||
#define TOUCH_LL_CHAN_SWAP(chan) ((chan) == 8 ? 9 : ((chan) == 9 ? 8 : (chan)))
|
||||
#define TOUCH_LL_FULL_CHANNEL_MASK ((uint16_t)((1U << SOC_TOUCH_SENSOR_NUM) - 1))
|
||||
#define TOUCH_LL_FULL_CHANNEL_MASK ((uint16_t)((1U << SOC_MODULE_ATTR(TOUCH, CHAN_NUM)) - 1))
|
||||
#define TOUCH_LL_READ_RAW 0x0
|
||||
|
||||
#define TOUCH_LL_CHARGE_DURATION_MAX (0xFFFF)
|
||||
@@ -429,7 +430,7 @@ __attribute__((always_inline))
|
||||
static inline void touch_ll_read_chan_data(uint32_t touch_num, uint8_t type, uint32_t *data)
|
||||
{
|
||||
HAL_ASSERT(type == TOUCH_LL_READ_RAW);
|
||||
HAL_ASSERT(touch_num < SOC_TOUCH_SENSOR_NUM);
|
||||
HAL_ASSERT(touch_num < SOC_MODULE_ATTR(TOUCH, CHAN_NUM));
|
||||
touch_num = TOUCH_LL_CHAN_SWAP(touch_num);
|
||||
if (touch_num & 0x1) {
|
||||
*data = HAL_FORCE_READ_U32_REG_FIELD(SENS.touch_meas[touch_num >> 1], l_val);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "soc/touch_struct.h"
|
||||
#include "soc/pmu_struct.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/soc_caps_full.h"
|
||||
#include "hal/touch_sens_types.h"
|
||||
#include "hal/config.h"
|
||||
|
||||
@@ -46,7 +47,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) << SOC_TOUCH_MIN_CHAN_ID)
|
||||
#define TOUCH_LL_FULL_CHANNEL_MASK ((uint16_t)((1U << (SOC_MODULE_ATTR(TOUCH, CHAN_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
|
||||
@@ -55,6 +56,8 @@ extern "C" {
|
||||
#define TOUCH_LL_TIMEOUT_MAX (0xFFFF) // Max timeout value
|
||||
#define TOUCH_LL_SLP_MEASURE_WAIT_MAX (0x1FF) // Max wait ticks to wait PMU entering HP SLEEP status during the sleep.
|
||||
|
||||
#define TOUCH_LL_SUPPORT_PROX_DONE (1)
|
||||
|
||||
/**
|
||||
* Enable/disable clock gate of touch sensor.
|
||||
*
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "hal/assert.h"
|
||||
#include "soc/touch_sensor_periph.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/soc_caps_full.h"
|
||||
#include "soc/sens_struct.h"
|
||||
#include "soc/rtc_cntl_struct.h"
|
||||
#include "soc/rtc_io_struct.h"
|
||||
@@ -53,7 +54,7 @@ extern "C" {
|
||||
TOUCH_LL_INTR_MASK_INACTIVE | \
|
||||
TOUCH_LL_INTR_MASK_TIMEOUT)
|
||||
|
||||
#define TOUCH_LL_FULL_CHANNEL_MASK ((uint16_t)((1U << SOC_TOUCH_SENSOR_NUM) - 1))
|
||||
#define TOUCH_LL_FULL_CHANNEL_MASK ((uint16_t)((1U << SOC_MODULE_ATTR(TOUCH, CHAN_NUM)) - 1))
|
||||
#define TOUCH_LL_NULL_CHANNEL (0) // Null Channel id. Used for disabling some functions like sleep/proximity/waterproof
|
||||
|
||||
#define TOUCH_LL_PAD_MEASURE_WAIT_MAX (0xFF) // The timer frequency is 8Mhz, the max value is 0xff
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "soc/rtc_io_struct.h"
|
||||
#include "soc/sens_struct.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/soc_caps_full.h"
|
||||
#include "hal/touch_sens_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -49,12 +50,13 @@ extern "C" {
|
||||
TOUCH_LL_INTR_MASK_TIMEOUT | \
|
||||
TOUCH_LL_INTR_MASK_PROX_DONE)
|
||||
|
||||
#define TOUCH_LL_FULL_CHANNEL_MASK ((uint16_t)((1U << SOC_TOUCH_SENSOR_NUM) - 1))
|
||||
#define TOUCH_LL_FULL_CHANNEL_MASK ((uint16_t)((1U << SOC_MODULE_ATTR(TOUCH, CHAN_NUM)) - 1))
|
||||
#define TOUCH_LL_NULL_CHANNEL (0) // Null Channel id. Used for disabling some functions like sleep/proximity/waterproof
|
||||
|
||||
#define TOUCH_LL_PAD_MEASURE_WAIT_MAX (0xFF) // The timer frequency is 8Mhz, the max value is 0xff
|
||||
#define TOUCH_LL_ACTIVE_THRESH_MAX (0x3FFFFF) // Max channel active threshold
|
||||
#define TOUCH_LL_TIMEOUT_MAX (0x3FFFFF) // Max timeout value
|
||||
#define TOUCH_LL_SUPPORT_PROX_DONE (1)
|
||||
|
||||
/**
|
||||
* Enable/disable clock gate of touch sensor.
|
||||
|
||||
@@ -28,7 +28,7 @@ typedef enum {
|
||||
TOUCH_PAD_NUM7, /*!< Touch pad channel 7 is GPIO27(ESP32) / GPIO7(ESP32-S2) */
|
||||
TOUCH_PAD_NUM8, /*!< Touch pad channel 8 is GPIO33(ESP32) / GPIO8(ESP32-S2) */
|
||||
TOUCH_PAD_NUM9, /*!< Touch pad channel 9 is GPIO32(ESP32) / GPIO9(ESP32-S2) */
|
||||
#if SOC_TOUCH_SENSOR_NUM > 10
|
||||
#if !SOC_IS(ESP32)
|
||||
TOUCH_PAD_NUM10, /*!< Touch channel 10 is GPIO10(ESP32-S2) */
|
||||
TOUCH_PAD_NUM11, /*!< Touch channel 11 is GPIO11(ESP32-S2) */
|
||||
TOUCH_PAD_NUM12, /*!< Touch channel 12 is GPIO12(ESP32-S2) */
|
||||
@@ -111,7 +111,16 @@ typedef enum {
|
||||
} touch_trigger_src_t;
|
||||
|
||||
/********************************/
|
||||
#define TOUCH_PAD_BIT_MASK_ALL ((1<<SOC_TOUCH_SENSOR_NUM)-1)
|
||||
#if SOC_TOUCH_SENSOR_VERSION == 1
|
||||
#define TOUCH_PAD_THRESHOLD_MAX (0) /*!< If set touch threshold max value, The touch sensor can't be in touched status */
|
||||
#define TOUCH_PAD_BIT_MASK_ALL (0x03FF)
|
||||
#elif SOC_TOUCH_SENSOR_VERSION == 2
|
||||
#define TOUCH_PAD_THRESHOLD_MAX (0x1FFFFF) /*!< If set touch threshold max value, The touch sensor can't be in touched status */
|
||||
#define TOUCH_PAD_BIT_MASK_ALL (0x7FFF)
|
||||
#elif SOC_TOUCH_SENSOR_VERSION == 3
|
||||
#define TOUCH_PAD_THRESHOLD_MAX (0xFFFF) /*!< If set touch threshold max value, The touch sensor can't be in touched status */
|
||||
#define TOUCH_PAD_BIT_MASK_ALL (0x3FFF)
|
||||
#endif
|
||||
#define TOUCH_PAD_SLOPE_DEFAULT (TOUCH_PAD_SLOPE_7)
|
||||
#define TOUCH_PAD_TIE_OPT_DEFAULT (TOUCH_PAD_TIE_OPT_FLOAT)
|
||||
#define TOUCH_PAD_BIT_MASK_MAX (TOUCH_PAD_BIT_MASK_ALL)
|
||||
@@ -119,13 +128,6 @@ typedef enum {
|
||||
#define TOUCH_PAD_LOW_VOLTAGE_THRESHOLD (TOUCH_LVOLT_0V5)
|
||||
#define TOUCH_PAD_ATTEN_VOLTAGE_THRESHOLD (TOUCH_HVOLT_ATTEN_0V5)
|
||||
#define TOUCH_PAD_IDLE_CH_CONNECT_DEFAULT (TOUCH_PAD_CONN_GND)
|
||||
#if SOC_TOUCH_SENSOR_VERSION == 1
|
||||
#define TOUCH_PAD_THRESHOLD_MAX (0) /*!< If set touch threshold max value, The touch sensor can't be in touched status */
|
||||
#elif SOC_TOUCH_SENSOR_VERSION == 2
|
||||
#define TOUCH_PAD_THRESHOLD_MAX (0x1FFFFF) /*!< If set touch threshold max value, The touch sensor can't be in touched status */
|
||||
#elif SOC_TOUCH_SENSOR_VERSION == 3
|
||||
#define TOUCH_PAD_THRESHOLD_MAX (0xFFFF) /*!< If set touch threshold max value, The touch sensor can't be in touched status */
|
||||
#endif
|
||||
|
||||
#if SOC_IS(ESP32)
|
||||
|
||||
@@ -159,7 +161,7 @@ typedef enum {
|
||||
TOUCH_PAD_INTR_MASK_INACTIVE = BIT(2), /*!<Inactive for one of the enabled channels. */
|
||||
TOUCH_PAD_INTR_MASK_SCAN_DONE = BIT(3), /*!<Measurement done for all the enabled channels. */
|
||||
TOUCH_PAD_INTR_MASK_TIMEOUT = BIT(4), /*!<Timeout for one of the enabled channels. */
|
||||
#if SOC_TOUCH_PROXIMITY_MEAS_DONE_SUPPORTED
|
||||
#if SOC_TOUCH_SENSOR_VERSION > 1 && !SOC_IS(ESP32S2)
|
||||
TOUCH_PAD_INTR_MASK_PROXI_MEAS_DONE = BIT(5), /*!<For proximity sensor, when the number of measurements reaches the set count of measurements, an interrupt will be generated. */
|
||||
TOUCH_PAD_INTR_MASK_MAX
|
||||
#define TOUCH_PAD_INTR_MASK_ALL (TOUCH_PAD_INTR_MASK_TIMEOUT \
|
||||
|
||||
@@ -81,14 +81,14 @@ static void s_touch_hal_apply_sleep_config(void)
|
||||
/* Apply the particular configuration for deep sleep */
|
||||
if (s_touch_slp_obj.apply_slp_cfg) {
|
||||
/* Save the current channel threshold first, because they will be reset by hardware after the recofniguration */
|
||||
uint32_t chan_thresh[SOC_TOUCH_SENSOR_NUM] = {};
|
||||
for (int i = 0; i < SOC_TOUCH_SENSOR_NUM; i++) {
|
||||
uint32_t chan_thresh[SOC_MODULE_ATTR(TOUCH, CHAN_NUM)] = {};
|
||||
for (int i = 0; i < SOC_MODULE_ATTR(TOUCH, CHAN_NUM); i++) {
|
||||
chan_thresh[i] = touch_ll_get_chan_active_threshold(i);
|
||||
}
|
||||
/* Reconfigure the touch sensor to use the sleep configuration */
|
||||
touch_hal_config_controller(&s_touch_slp_obj.slp_cfg);
|
||||
/* Restore the channel threshold */
|
||||
for (int i = 0; i < SOC_TOUCH_SENSOR_NUM; i++) {
|
||||
for (int i = 0; i < SOC_MODULE_ATTR(TOUCH, CHAN_NUM); i++) {
|
||||
touch_ll_set_chan_active_threshold(i, chan_thresh[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -639,10 +639,6 @@ config SOC_TOUCH_SENSOR_VERSION
|
||||
int
|
||||
default 1
|
||||
|
||||
config SOC_TOUCH_SENSOR_NUM
|
||||
int
|
||||
default 10
|
||||
|
||||
config SOC_TOUCH_MIN_CHAN_ID
|
||||
int
|
||||
default 0
|
||||
|
||||
@@ -312,7 +312,6 @@
|
||||
|
||||
/*-------------------------- TOUCH SENSOR CAPS -------------------------------*/
|
||||
#define SOC_TOUCH_SENSOR_VERSION (1U) /*!<Hardware version of touch sensor */
|
||||
#define SOC_TOUCH_SENSOR_NUM (10)
|
||||
#define SOC_TOUCH_MIN_CHAN_ID (0U) /*!< Touch minimum channel number */
|
||||
#define SOC_TOUCH_MAX_CHAN_ID (9) /*!< Touch maximum channel number */
|
||||
#define SOC_TOUCH_SUPPORT_SLEEP_WAKEUP (1)
|
||||
|
||||
@@ -36,3 +36,6 @@
|
||||
#define _SOC_CAPS_I2S_MAX_DATA_WIDTH 24 // Maximum data line width of I2S
|
||||
#define _SOC_CAPS_I2S_TRANS_SIZE_ALIGN_WORD 1 // I2S DMA transfer size must be aligned to word
|
||||
#define _SOC_CAPS_I2S_SUPPORT_ADC_DAC 1 // I2S supports to connect to ADC / DAC converters
|
||||
|
||||
/*------------------------------- Touch Sensor ------------------------------------*/
|
||||
#define _SOC_CAPS_TOUCH_CHAN_NUM 10 // Number of touch sensor channels
|
||||
|
||||
@@ -1663,10 +1663,6 @@ config SOC_TOUCH_SENSOR_VERSION
|
||||
int
|
||||
default 3
|
||||
|
||||
config SOC_TOUCH_SENSOR_NUM
|
||||
int
|
||||
default 14
|
||||
|
||||
config SOC_TOUCH_MIN_CHAN_ID
|
||||
int
|
||||
default 1
|
||||
@@ -1695,14 +1691,6 @@ config SOC_TOUCH_PROXIMITY_CHANNEL_NUM
|
||||
int
|
||||
default 3
|
||||
|
||||
config SOC_TOUCH_PROXIMITY_MEAS_DONE_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_TOUCH_SUPPORT_FREQ_HOP
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_TOUCH_SAMPLE_CFG_NUM
|
||||
int
|
||||
default 3
|
||||
|
||||
@@ -623,7 +623,6 @@
|
||||
|
||||
/*-------------------------- 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 (1U) /*!< Touch minimum channel number */
|
||||
#define SOC_TOUCH_MAX_CHAN_ID (14) /*!< Touch maximum channel number */
|
||||
|
||||
@@ -633,8 +632,6 @@
|
||||
#define SOC_TOUCH_SUPPORT_WATERPROOF (1) /*!< Touch sensor supports waterproof */
|
||||
#define SOC_TOUCH_SUPPORT_PROX_SENSING (1) /*!< Touch sensor supports proximity sensing */
|
||||
#define SOC_TOUCH_PROXIMITY_CHANNEL_NUM (3) /*!< Support touch proximity channel number. */
|
||||
#define SOC_TOUCH_PROXIMITY_MEAS_DONE_SUPPORTED (1) /*!< Support touch proximity channel measure done interrupt type. */
|
||||
#define SOC_TOUCH_SUPPORT_FREQ_HOP (1) /*!< Touch sensor supports frequency hopping */
|
||||
#define SOC_TOUCH_SAMPLE_CFG_NUM (3) /*!< The sample configurations number in total, each sampler can be used to sample on one frequency */
|
||||
|
||||
/*-------------------------- TWAI CAPS ---------------------------------------*/
|
||||
|
||||
@@ -44,3 +44,6 @@
|
||||
/*------------------------------- I2S ---------------------------------------*/
|
||||
// helper macros to access module attributes
|
||||
#define _SOC_CAPS_I2S_INST_NUM 3 // Number of I2S instances
|
||||
|
||||
/*------------------------------- Touch Sensor ------------------------------------*/
|
||||
#define _SOC_CAPS_TOUCH_CHAN_NUM 14 // Number of touch sensor channels
|
||||
|
||||
@@ -727,10 +727,6 @@ config SOC_TOUCH_SENSOR_VERSION
|
||||
int
|
||||
default 2
|
||||
|
||||
config SOC_TOUCH_SENSOR_NUM
|
||||
int
|
||||
default 15
|
||||
|
||||
config SOC_TOUCH_MIN_CHAN_ID
|
||||
int
|
||||
default 1
|
||||
|
||||
@@ -323,7 +323,6 @@
|
||||
|
||||
/*-------------------------- TOUCH SENSOR CAPS -------------------------------*/
|
||||
#define SOC_TOUCH_SENSOR_VERSION (2) /*!< Hardware version of touch sensor */
|
||||
#define SOC_TOUCH_SENSOR_NUM (15) /*!< 15 Touch channels */
|
||||
#define SOC_TOUCH_MIN_CHAN_ID (1U) /*!< Touch minimum channel number, (0 is internal denoise channel) */
|
||||
#define SOC_TOUCH_MAX_CHAN_ID (14) /*!< Touch maximum channel number */
|
||||
#define SOC_TOUCH_SUPPORT_BENCHMARK (1) /*!< Touch sensor supports benchmark configuration */
|
||||
|
||||
@@ -39,3 +39,6 @@
|
||||
#define _SOC_CAPS_I2S_INST_NUM 1 // Number of I2S instances
|
||||
#define _SOC_CAPS_I2S_MAX_DATA_WIDTH 24
|
||||
#define _SOC_CAPS_I2S_SUPPORT_DMA_EQUAL 1
|
||||
|
||||
/*------------------------------- Touch Sensor ------------------------------------*/
|
||||
#define _SOC_CAPS_TOUCH_CHAN_NUM 15 // Number of touch sensor channels
|
||||
|
||||
@@ -955,10 +955,6 @@ config SOC_TOUCH_SENSOR_VERSION
|
||||
int
|
||||
default 2
|
||||
|
||||
config SOC_TOUCH_SENSOR_NUM
|
||||
int
|
||||
default 15
|
||||
|
||||
config SOC_TOUCH_MIN_CHAN_ID
|
||||
int
|
||||
default 1
|
||||
@@ -991,10 +987,6 @@ config SOC_TOUCH_PROXIMITY_CHANNEL_NUM
|
||||
int
|
||||
default 3
|
||||
|
||||
config SOC_TOUCH_PROXIMITY_MEAS_DONE_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_TOUCH_SAMPLE_CFG_NUM
|
||||
int
|
||||
default 1
|
||||
|
||||
@@ -379,7 +379,6 @@
|
||||
|
||||
/*-------------------------- TOUCH SENSOR CAPS -------------------------------*/
|
||||
#define SOC_TOUCH_SENSOR_VERSION (2) /*!< Hardware version of touch sensor */
|
||||
#define SOC_TOUCH_SENSOR_NUM (15) /*!< 15 Touch channels */
|
||||
#define SOC_TOUCH_MIN_CHAN_ID (1U) /*!< Touch minimum channel number, (0 is internal denoise channel) */
|
||||
#define SOC_TOUCH_MAX_CHAN_ID (14) /*!< Touch maximum channel number */
|
||||
#define SOC_TOUCH_SUPPORT_BENCHMARK (1) /*!< Touch sensor supports benchmark configuration */
|
||||
@@ -388,7 +387,6 @@
|
||||
#define SOC_TOUCH_SUPPORT_PROX_SENSING (1) /*!< Touch sensor supports proximity sensing */
|
||||
#define SOC_TOUCH_SUPPORT_DENOISE_CHAN (1) /*!< Touch sensor supports denoise channel */
|
||||
#define SOC_TOUCH_PROXIMITY_CHANNEL_NUM (3) /*!< Support touch proximity sensing channel number. */
|
||||
#define SOC_TOUCH_PROXIMITY_MEAS_DONE_SUPPORTED (1) /*!< Support touch proximity sensing measure done interrupt type. */
|
||||
|
||||
#define SOC_TOUCH_SAMPLE_CFG_NUM (1U) /*!< The sample configuration number in total, each sampler can be used to sample on one frequency */
|
||||
|
||||
|
||||
@@ -37,3 +37,6 @@
|
||||
/*------------------------------- I2S ---------------------------------------*/
|
||||
// helper macros to access module attributes
|
||||
#define _SOC_CAPS_I2S_INST_NUM 2 // Number of I2S instances
|
||||
|
||||
/*------------------------------- Touch Sensor ------------------------------------*/
|
||||
#define _SOC_CAPS_TOUCH_CHAN_NUM 15 // Number of touch sensor channels
|
||||
|
||||
Reference in New Issue
Block a user