Merge branch 'feature/touch_driver_ng_on_p4_v5.3' into 'release/v5.3'

feat(touch_sensor): touch driver ng on p4 (v5.3)

See merge request espressif/esp-idf!31624
This commit is contained in:
Jiang Jiang Jian
2024-07-26 11:42:27 +08:00
81 changed files with 4288 additions and 402 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -26,7 +26,7 @@ extern "C" {
/**
* Reset the whole of touch module.
*
* @note Call this funtion after `touch_pad_fsm_stop`,
* @note Call this function after `touch_pad_fsm_stop`,
*/
#define touch_hal_reset() touch_ll_reset()
@@ -385,7 +385,7 @@ void touch_hal_denoise_enable(void);
#define touch_hal_waterproof_get_guard_pad(pad_num) touch_ll_waterproof_get_guard_pad(pad_num)
/**
* Set max equivalent capacitance for sheild channel.
* Set max equivalent capacitance for shield channel.
* The equivalent capacitance of the shielded channel can be calculated
* from the reading of denoise channel.
*
@@ -394,7 +394,7 @@ void touch_hal_denoise_enable(void);
#define touch_hal_waterproof_set_sheild_driver(driver_level) touch_ll_waterproof_set_sheild_driver(driver_level)
/**
* Get max equivalent capacitance for sheild channel.
* Get max equivalent capacitance for shield channel.
* The equivalent capacitance of the shielded channel can be calculated
* from the reading of denoise channel.
*
@@ -551,12 +551,12 @@ void touch_hal_sleep_channel_enable(touch_pad_t pad_num, bool enable);
/**
* Enable proximity function for sleep pad.
*/
#define touch_hal_sleep_enable_approach() touch_ll_sleep_enable_approach()
#define touch_hal_sleep_enable_approach() touch_ll_sleep_enable_proximity_sensing()
/**
* Disable proximity function for sleep pad.
*/
#define touch_hal_sleep_disable_approach() touch_ll_sleep_disable_approach()
#define touch_hal_sleep_disable_approach() touch_ll_sleep_disable_proximity_sensing()
/**
* Read benchmark of touch sensor for sleep pad.

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -214,6 +214,7 @@ static inline void touch_ll_get_tie_option(touch_pad_t touch_num, touch_tie_opt_
*
* @param mode FSM mode.
*/
__attribute__((always_inline))
static inline void touch_ll_set_fsm_mode(touch_fsm_mode_t mode)
{
RTCCNTL.touch_ctrl2.touch_start_force = mode;
@@ -280,6 +281,7 @@ static inline void touch_ll_start_fsm(void)
* Stop touch sensor FSM timer.
* The measurement action can be triggered by the hardware timer, as well as by the software instruction.
*/
__attribute__((always_inline))
static inline void touch_ll_stop_fsm(void)
{
RTCCNTL.touch_ctrl2.touch_start_en = 0; //stop touch fsm
@@ -416,7 +418,8 @@ static inline uint32_t IRAM_ATTR touch_ll_read_raw_data(touch_pad_t touch_num)
* @return
* - If touch sensors measure done.
*/
static inline bool touch_ll_meas_is_done(void)
__attribute__((always_inline))
static inline bool touch_ll_is_measure_done(void)
{
return (bool)SENS.sar_touch_chn_st.touch_meas_done;
}
@@ -555,22 +558,23 @@ static inline void touch_ll_intr_clear(touch_pad_intr_mask_t int_mask)
*/
static inline uint32_t touch_ll_read_intr_status_mask(void)
{
uint32_t intr_st = RTCCNTL.int_st.val;
typeof(RTCCNTL.int_st) intr_st;
intr_st.val = RTCCNTL.int_st.val;
uint32_t intr_msk = 0;
if (intr_st & RTC_CNTL_TOUCH_DONE_INT_ST_M) {
if (intr_st.rtc_touch_done) {
intr_msk |= TOUCH_PAD_INTR_MASK_DONE;
}
if (intr_st & RTC_CNTL_TOUCH_ACTIVE_INT_ST_M) {
if (intr_st.rtc_touch_active) {
intr_msk |= TOUCH_PAD_INTR_MASK_ACTIVE;
}
if (intr_st & RTC_CNTL_TOUCH_INACTIVE_INT_ST_M) {
if (intr_st.rtc_touch_inactive) {
intr_msk |= TOUCH_PAD_INTR_MASK_INACTIVE;
}
if (intr_st & RTC_CNTL_TOUCH_SCAN_DONE_INT_ST_M) {
if (intr_st.rtc_touch_scan_done) {
intr_msk |= TOUCH_PAD_INTR_MASK_SCAN_DONE;
}
if (intr_st & RTC_CNTL_TOUCH_TIMEOUT_INT_ST_M) {
if (intr_st.rtc_touch_timeout) {
intr_msk |= TOUCH_PAD_INTR_MASK_TIMEOUT;
}
return (intr_msk & TOUCH_PAD_INTR_MASK_ALL);
@@ -909,7 +913,7 @@ static inline void touch_ll_waterproof_get_guard_pad(touch_pad_t *pad_num)
}
/**
* Set max equivalent capacitance for sheild channel.
* Set max equivalent capacitance for shield channel.
* The equivalent capacitance of the shielded channel can be calculated
* from the reading of denoise channel.
*
@@ -921,7 +925,7 @@ static inline void touch_ll_waterproof_set_sheild_driver(touch_pad_shield_driver
}
/**
* Get max equivalent capacitance for sheild channel.
* Get max equivalent capacitance for shield channel.
* The equivalent capacitance of the shielded channel can be calculated
* from the reading of denoise channel.
*
@@ -1084,7 +1088,7 @@ static inline void touch_ll_sleep_get_threshold(uint32_t *touch_thres)
/**
* Enable proximity function for sleep pad.
*/
static inline void touch_ll_sleep_enable_approach(void)
static inline void touch_ll_sleep_enable_proximity_sensing(void)
{
RTCCNTL.touch_slp_thres.touch_slp_approach_en = 1;
}
@@ -1092,7 +1096,7 @@ static inline void touch_ll_sleep_enable_approach(void)
/**
* Disable proximity function for sleep pad.
*/
static inline void touch_ll_sleep_disable_approach(void)
static inline void touch_ll_sleep_disable_proximity_sensing(void)
{
RTCCNTL.touch_slp_thres.touch_slp_approach_en = 0;
}
@@ -1100,7 +1104,7 @@ static inline void touch_ll_sleep_disable_approach(void)
/**
* Get proximity function status for sleep pad.
*/
static inline bool touch_ll_sleep_get_approach_status(void)
static inline bool touch_ll_sleep_is_proximity_enabled(void)
{
return (bool)RTCCNTL.touch_slp_thres.touch_slp_approach_en;
}
@@ -1157,11 +1161,11 @@ static inline void touch_ll_sleep_read_debounce(uint32_t *debounce)
/**
* Read proximity count of touch sensor for sleep pad.
* @param proximity_cnt Pointer to accept touch sensor proximity count value.
* @param prox_cnt Pointer to accept touch sensor proximity count value.
*/
static inline void touch_ll_sleep_read_proximity_cnt(uint32_t *approach_cnt)
static inline void touch_ll_sleep_read_proximity_cnt(uint32_t *prox_cnt)
{
*approach_cnt = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_slp_approach_cnt);
*prox_cnt = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_slp_approach_cnt);
}
/**

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -53,7 +53,7 @@ void touch_hal_deinit(void)
touch_pad_t prox_pad[SOC_TOUCH_PROXIMITY_CHANNEL_NUM] = {[0 ... (SOC_TOUCH_PROXIMITY_CHANNEL_NUM - 1)] = 0};
touch_ll_proximity_set_channel_num((const touch_pad_t *)prox_pad);
touch_ll_sleep_set_channel_num(0);
touch_ll_sleep_disable_approach();
touch_ll_sleep_disable_proximity_sensing();
touch_ll_reset(); // Reset the touch sensor FSM.
}
@@ -152,7 +152,7 @@ void touch_hal_sleep_channel_enable(touch_pad_t pad_num, bool enable)
void touch_hal_sleep_channel_get_config(touch_pad_sleep_channel_t *slp_config)
{
touch_ll_sleep_get_channel_num(&slp_config->touch_num);
slp_config->en_proximity = touch_ll_sleep_get_approach_status();
slp_config->en_proximity = touch_ll_sleep_is_proximity_enabled();
}
void touch_hal_sleep_channel_set_work_time(uint16_t sleep_cycle, uint16_t meas_times)