Merge branch 'feature/support_touch_on_p4_eco5' into 'master'

feat(touch): support touch sensor on p4 eco5

Closes IDF-13423 and IDF-13424

See merge request espressif/esp-idf!41802
This commit is contained in:
Kevin (Lao Kaiyao)
2025-09-16 10:06:44 +08:00
11 changed files with 204 additions and 59 deletions

View File

@@ -25,6 +25,7 @@
#include "soc/pmu_struct.h"
#include "soc/soc_caps.h"
#include "hal/touch_sens_types.h"
#include "hal/config.h"
#ifdef __cplusplus
extern "C" {
@@ -586,6 +587,18 @@ static inline uint32_t touch_ll_sample_cfg_get_engaged_num(void)
return sample_cfg_num ? sample_cfg_num : 1;
}
/**
* Set the number of trigger rise count (only available since P4 ver3)
*
* @param rise_cnt Configure the number of hit frequency points that need to be determined for touch
* in frequency hopping mode.
*/
static inline void touch_ll_sample_cfg_set_trigger_rise_cnt(uint8_t rise_cnt)
{
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
LP_ANA_PERI.touch_ctrl.freq_scan_cnt_rise = rise_cnt;
#endif
}
/**
* Set capacitance and resistance of the RC filter of the sampling frequency.
@@ -615,18 +628,6 @@ static inline void touch_ll_sample_cfg_set_driver(uint8_t sample_cfg_id, uint32_
LP_ANA_PERI.touch_freq_scan_para[sample_cfg_id].touch_freq_drv_hs = hs_drv;
}
/**
* Bypass the shield channel output for the specify sample configuration
*
* @param sample_cfg_id The sample configuration index
* @param enable Set true to bypass the shield channel output for the current channel
*/
static inline void touch_ll_sample_cfg_bypass_shield_output(uint8_t sample_cfg_id, bool enable)
{
HAL_ASSERT(sample_cfg_id < SOC_TOUCH_SAMPLE_CFG_NUM);
LP_ANA_PERI.touch_freq_scan_para[sample_cfg_id].touch_bypass_shield = enable;
}
/**
* Set the touch internal LDO bias voltage of the sampling frequency
*
@@ -753,13 +754,19 @@ static inline void touch_ll_filter_enable(bool enable)
}
/**
* Force the update the benchmark by software
* Force the update the benchmark by software (only available since P4 ver3)
* @note This benchmark will be applied to all enabled channel and all sampling frequency
*
* @param pad_num The pad number, range [1-14]
* @param sample_cfg_id The sample configuration index, range [0-2]
* @param benchmark The benchmark specified by software
*/
static inline void touch_ll_force_update_benchmark(uint32_t benchmark)
static inline void touch_ll_force_update_benchmark(uint32_t pad_num, uint8_t sample_cfg_id, uint32_t benchmark)
{
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
LP_ANA_PERI.touch_ctrl.touch_update_benchmark_pad_sel = pad_num;
LP_ANA_PERI.touch_ctrl.touch_update_benchmark_freq_sel = sample_cfg_id;
#endif
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_ANA_PERI.touch_filter3, touch_benchmark_sw, benchmark);
LP_ANA_PERI.touch_filter3.touch_update_benchmark_sw = 1;
// waiting for update