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: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-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
*/
@@ -168,11 +168,18 @@ static inline void touch_ll_get_voltage_attenuation(touch_volt_atten_t *atten)
*/
static inline void touch_ll_set_slope(touch_pad_t touch_num, touch_cnt_slope_t slope)
{
#define PAD_SLOP_MASK(val, num) ((val) << (29 - (num) * 3))
uint32_t curr_slop = 0;
if (touch_num < TOUCH_PAD_NUM10) {
SET_PERI_REG_BITS(RTC_CNTL_TOUCH_DAC_REG, RTC_CNTL_TOUCH_PAD0_DAC_V, slope, (RTC_CNTL_TOUCH_PAD0_DAC_S - touch_num * 3));
curr_slop = RTCCNTL.touch_dac.val;
curr_slop &= ~PAD_SLOP_MASK(0x07, touch_num); // clear the old value
RTCCNTL.touch_dac.val = curr_slop | PAD_SLOP_MASK(slope, touch_num);
} else {
SET_PERI_REG_BITS(RTC_CNTL_TOUCH_DAC1_REG, RTC_CNTL_TOUCH_PAD10_DAC_V, slope, (RTC_CNTL_TOUCH_PAD10_DAC_S - (touch_num - TOUCH_PAD_NUM10) * 3));
curr_slop = RTCCNTL.touch_dac1.val;
curr_slop &= ~PAD_SLOP_MASK(0x07, touch_num - TOUCH_PAD_NUM10); // clear the old value
RTCCNTL.touch_dac1.val = curr_slop | PAD_SLOP_MASK(slope, touch_num - TOUCH_PAD_NUM10);
}
#undef PAD_SLOP_MASK
}
/**
@@ -188,9 +195,9 @@ static inline void touch_ll_set_slope(touch_pad_t touch_num, touch_cnt_slope_t s
static inline void touch_ll_get_slope(touch_pad_t touch_num, touch_cnt_slope_t *slope)
{
if (touch_num < TOUCH_PAD_NUM10) {
*slope = (touch_cnt_slope_t)(GET_PERI_REG_BITS2(RTC_CNTL_TOUCH_DAC_REG, RTC_CNTL_TOUCH_PAD0_DAC_V, (RTC_CNTL_TOUCH_PAD0_DAC_S - touch_num * 3)));
*slope = (touch_cnt_slope_t)((RTCCNTL.touch_dac.val >> (29 - touch_num * 3)) & 0x07);
} else {
*slope = (touch_cnt_slope_t)(GET_PERI_REG_BITS2(RTC_CNTL_TOUCH_DAC1_REG, RTC_CNTL_TOUCH_PAD10_DAC_V, (RTC_CNTL_TOUCH_PAD10_DAC_S - (touch_num - TOUCH_PAD_NUM10) * 3)));
*slope = (touch_cnt_slope_t)((RTCCNTL.touch_dac1.val >> (29 - (touch_num - TOUCH_PAD_NUM10) * 3)) & 0x07);
}
}
@@ -222,6 +229,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;
@@ -288,6 +296,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
@@ -424,7 +433,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;
}
@@ -572,25 +582,26 @@ 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;
}
if (intr_st & RTC_CNTL_TOUCH_APPROACH_LOOP_DONE_INT_ST_M) {
if (intr_st.rtc_touch_approach_loop_done) {
intr_msk |= TOUCH_PAD_INTR_MASK_PROXI_MEAS_DONE;
}
return (intr_msk & TOUCH_PAD_INTR_MASK_ALL);
@@ -929,7 +940,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.
*
@@ -941,7 +952,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.
*
@@ -1104,7 +1115,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;
}
@@ -1112,7 +1123,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;
}
@@ -1120,7 +1131,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;
}
@@ -1177,11 +1188,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 = SENS.sar_touch_appr_status.touch_slp_approach_cnt;
*prox_cnt = SENS.sar_touch_appr_status.touch_slp_approach_cnt;
}
/**

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 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)