feat(ulp_touch): support ulp touch driver on p4

This commit is contained in:
laokaiyao
2025-02-27 15:50:58 +08:00
parent 71e4d9ec50
commit ffb8adcf49
19 changed files with 358 additions and 23 deletions

View File

@@ -584,6 +584,18 @@ static inline void touch_ll_sample_cfg_set_engaged_num(uint8_t sample_cfg_num)
LP_ANA_PERI.touch_scan_ctrl2.freq_scan_cnt_limit = sample_cfg_num ? sample_cfg_num : 1;
}
/**
* Get the engaged sample configuration number
*
* @return The engaged sample configuration number, range 0~3.
*/
static inline uint32_t touch_ll_sample_cfg_get_engaged_num(void)
{
uint32_t sample_cfg_num = LP_ANA_PERI.touch_scan_ctrl2.freq_scan_cnt_limit;
return sample_cfg_num ? sample_cfg_num : 1;
}
/**
* Set capacitance and resistance of the RC filter of the sampling frequency.
*

View File

@@ -1682,6 +1682,29 @@ static inline void touch_ll_sleep_read_data(uint32_t *raw_data)
*raw_data = SENS.sar_touch_status[touch_num - 1].touch_pad_data;
}
/**
* Get the data of the touch channel according to the types
*
* @param sample_cfg_id The sample configuration index
* @param type data type
* 0/1: TOUCH_LL_READ_RAW, the raw data of the touch channel
* 2: TOUCH_LL_READ_BENCHMARK, benchmark value of touch channel,
* the benchmark value is the maximum during the first measurement period
* 3: TOUCH_LL_READ_SMOOTH, the smoothed data that obtained by filtering the raw data.
* @param smooth_data pointer to smoothed data
*/
__attribute__((always_inline))
static inline void touch_ll_sleep_read_chan_data(uint8_t type, uint32_t *data)
{
SENS.sar_touch_conf.touch_data_sel = type;
if (type == TOUCH_LL_READ_RAW) {
uint32_t touch_num = RTCCNTL.touch_slp_thres.touch_slp_pad;
*data = SENS.sar_touch_status[touch_num - 1].touch_pad_data;
} else {
*data = SENS.sar_touch_slp_status.touch_slp_data;
}
}
/**
* Select touch sensor dbias to save power in sleep mode.
*

View File

@@ -1718,6 +1718,29 @@ static inline void touch_ll_sleep_read_data(uint32_t *raw_data)
*raw_data = SENS.sar_touch_status[touch_num - 1].touch_pad_data;
}
/**
* Get the data of the touch channel according to the types
*
* @param sample_cfg_id The sample configuration index
* @param type data type
* 0/1: TOUCH_LL_READ_RAW, the raw data of the touch channel
* 2: TOUCH_LL_READ_BENCHMARK, benchmark value of touch channel,
* the benchmark value is the maximum during the first measurement period
* 3: TOUCH_LL_READ_SMOOTH, the smoothed data that obtained by filtering the raw data.
* @param smooth_data pointer to smoothed data
*/
__attribute__((always_inline))
static inline void touch_ll_sleep_read_chan_data(uint8_t type, uint32_t *data)
{
SENS.sar_touch_conf.touch_data_sel = type;
if (type == TOUCH_LL_READ_RAW) {
uint32_t touch_num = RTCCNTL.touch_slp_thres.touch_slp_pad;
*data = SENS.sar_touch_status[touch_num - 1].touch_pad_data;
} else {
*data = SENS.sar_touch_slp_status.touch_slp_data;
}
}
/**
* Select touch sensor dbias to save power in sleep mode.