driver(touch): fix touch sensor driver redundancy

This commit is contained in:
fuzhibo 2020-07-30 15:44:59 +08:00
parent 95083233c5
commit 67a48580fa
12 changed files with 191 additions and 339 deletions

View File

@ -21,7 +21,7 @@ extern "C" {
/**
* @brief Set touch sensor FSM start
* @note Start FSM after the touch sensor FSM mode is set.
* @note Call this function will reset beseline of all touch channels.
* @note Call this function will reset benchmark of all touch channels.
* @return
* - ESP_OK on success
*/
@ -97,7 +97,7 @@ esp_err_t touch_pad_get_inactive_connect(touch_pad_conn_type_t *type);
/**
* @brief Set the trigger threshold of touch sensor.
* The threshold determines the sensitivity of the touch sensor.
* The threshold is the original value of the trigger state minus the baseline value.
* The threshold is the original value of the trigger state minus the benchmark value.
* @note If set "TOUCH_PAD_THRESHOLD_MAX", the touch is never be trigered.
* @param touch_num touch pad index
* @param threshold threshold of touch sensor. Should be less than the max change value of touch.
@ -236,24 +236,24 @@ esp_err_t touch_pad_isr_register(intr_handler_t fn, void* arg, touch_pad_intr_ma
esp_err_t touch_pad_read_raw_data(touch_pad_t touch_num, uint32_t *raw_data);
/**
* @brief get baseline of touch sensor.
* @note After initialization, the baseline value is the maximum during the first measurement period.
* @brief get benchmark of touch sensor.
* @note After initialization, the benchmark value is the maximum during the first measurement period.
* @param touch_num touch pad index
* @param touch_value pointer to accept touch sensor value
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Touch channel 0 havent this parameter.
*/
esp_err_t touch_pad_filter_read_baseline(touch_pad_t touch_num, uint32_t *basedata);
esp_err_t touch_pad_filter_read_benchmark(touch_pad_t touch_num, uint32_t *basedata);
/**
* @brief Force reset baseline to raw data of touch sensor.
* @brief Force reset benchmark to raw data of touch sensor.
* @param touch_num touch pad index
* - TOUCH_PAD_MAX Reset basaline of all channels
* @return
* - ESP_OK Success
*/
esp_err_t touch_pad_filter_reset_baseline(touch_pad_t touch_num);
esp_err_t touch_pad_reset_benchmark(touch_pad_t touch_num);
/**
* @brief set parameter of touch sensor filter and detection algorithm.
@ -282,7 +282,7 @@ esp_err_t touch_pad_filter_get_config(touch_filter_config_t *filter_info);
esp_err_t touch_pad_filter_enable(void);
/**
* @brief diaable touch sensor filter for detection algorithm.
* @brief disable touch sensor filter for detection algorithm.
* For more details on the detection algorithm, please refer to the application documentation.
* @return
* - ESP_OK Success
@ -339,11 +339,12 @@ esp_err_t touch_pad_denoise_read_data(uint32_t *data);
/**
* @brief set parameter of waterproof function.
*
* The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel.
* The shielded channel outputs the same signal as the channel being measured.
* Guard pad is used to detect the large area of water covering the touch panel.
* Shield pad is used to shield the influence of water droplets covering the touch panel.
* It is generally designed as a grid and is placed around the touch buttons.
* The shielded channel does not follow the measurement signal of the protection channel.
* So that the guard channel can detect a large area of water.
*
* @param waterproof parameter of waterproof
* @return
* - ESP_OK Success
@ -360,23 +361,14 @@ esp_err_t touch_pad_waterproof_get_config(touch_pad_waterproof_t *waterproof);
/**
* @brief Enable parameter of waterproof function.
* The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel.
* The shielded channel outputs the same signal as the channel being measured.
* It is generally designed as a grid and is placed around the touch buttons.
* The shielded channel does not follow the measurement signal of the protection channel.
* So that the guard channel can detect a large area of water.
* Should be called after function ``touch_pad_waterproof_set_config``.
* @return
* - ESP_OK Success
*/
esp_err_t touch_pad_waterproof_enable(void);
/**
* @brief Enable parameter of waterproof function.
* The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel.
* The shielded channel outputs the same signal as the channel being measured.
* It is generally designed as a grid and is placed around the touch buttons.
* The shielded channel does not follow the measurement signal of the protection channel.
* So that the guard channel can detect a large area of water.
* @brief Disable parameter of waterproof function.
* @return
* - ESP_OK Success
*/
@ -434,13 +426,13 @@ esp_err_t touch_pad_proximity_data_get(touch_pad_t touch_num, uint32_t *measure_
esp_err_t touch_pad_sleep_channel_config(touch_pad_sleep_channel_t *slp_config);
/**
* @brief Read baseline of touch sensor in sleep mode.
* @param baseline pointer to accept touch sensor baseline value
* @brief Read benchmark of touch sensor in sleep mode.
* @param benchmark pointer to accept touch sensor benchmark value
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG parameter is NULL
*/
esp_err_t touch_pad_sleep_channel_read_baseline(uint32_t *baseline);
esp_err_t touch_pad_sleep_channel_read_benchmark(uint32_t *benchmark);
/**
* @brief Read debounce of touch sensor in sleep mode.

View File

@ -237,19 +237,19 @@ esp_err_t IRAM_ATTR touch_pad_read_raw_data(touch_pad_t touch_num, uint32_t *raw
return ESP_OK;
}
esp_err_t IRAM_ATTR touch_pad_filter_read_baseline(touch_pad_t touch_num, uint32_t *basedata)
esp_err_t IRAM_ATTR touch_pad_filter_read_benchmark(touch_pad_t touch_num, uint32_t *basedata)
{
TOUCH_CHANNEL_CHECK(touch_num);
touch_hal_filter_read_baseline(touch_num, basedata);
touch_hal_filter_read_benchmark(touch_num, basedata);
return ESP_OK;
}
/* Should be call after clk enable and filter enable. */
esp_err_t touch_pad_filter_reset_baseline(touch_pad_t touch_num)
esp_err_t touch_pad_reset_benchmark(touch_pad_t touch_num)
{
TOUCH_CHECK(touch_num <= TOUCH_PAD_MAX && touch_num >= 0, "Touch channel error", ESP_ERR_INVALID_ARG);
TOUCH_ENTER_CRITICAL();
touch_hal_filter_reset_baseline(touch_num);
touch_hal_filter_reset_benchmark(touch_num);
TOUCH_EXIT_CRITICAL();
return ESP_OK;
}
@ -258,10 +258,7 @@ esp_err_t touch_pad_filter_set_config(touch_filter_config_t *filter_info)
{
TOUCH_CHECK(filter_info->mode < TOUCH_PAD_FILTER_MAX, TOUCH_PARAM_CHECK_STR("mode"), ESP_ERR_INVALID_ARG);
TOUCH_CHECK(filter_info->debounce_cnt <= TOUCH_DEBOUNCE_CNT_MAX, TOUCH_PARAM_CHECK_STR("debounce"), ESP_ERR_INVALID_ARG);
TOUCH_CHECK(filter_info->hysteresis_thr <= TOUCH_HYSTERESIS_THR_MAX, TOUCH_PARAM_CHECK_STR("hysteresis"), ESP_ERR_INVALID_ARG);
TOUCH_CHECK(filter_info->noise_thr <= TOUCH_NOISE_THR_MAX, TOUCH_PARAM_CHECK_STR("noise"), ESP_ERR_INVALID_ARG);
TOUCH_CHECK(filter_info->noise_neg_thr <= TOUCH_NOISE_NEG_THR_MAX, TOUCH_PARAM_CHECK_STR("noise"), ESP_ERR_INVALID_ARG);
TOUCH_CHECK(filter_info->neg_noise_limit <= TOUCH_NEG_NOISE_CNT_LIMIT, TOUCH_PARAM_CHECK_STR("noise_limit"), ESP_ERR_INVALID_ARG);
TOUCH_CHECK(filter_info->jitter_step <= TOUCH_JITTER_STEP_MAX, TOUCH_PARAM_CHECK_STR("jitter_step"), ESP_ERR_INVALID_ARG);
TOUCH_ENTER_CRITICAL();
@ -410,7 +407,7 @@ esp_err_t touch_pad_proximity_read_meas_cnt(touch_pad_t touch_num, uint32_t *cnt
esp_err_t touch_pad_proximity_data_get(touch_pad_t touch_num, uint32_t *measure_out)
{
TOUCH_CHECK(touch_hal_proximity_pad_check(touch_num), "touch_num is not proximity", ESP_ERR_INVALID_ARG);
touch_hal_filter_read_baseline(touch_num, measure_out);
touch_hal_filter_read_benchmark(touch_num, measure_out);
return ESP_OK;
}
@ -426,9 +423,9 @@ esp_err_t touch_pad_sleep_channel_config(touch_pad_sleep_channel_t *slp_config)
return ESP_OK;
}
esp_err_t touch_pad_sleep_channel_read_baseline(uint32_t *baseline)
esp_err_t touch_pad_sleep_channel_read_benchmark(uint32_t *benchmark)
{
touch_hal_sleep_read_baseline(baseline);
touch_hal_sleep_read_benchmark(benchmark);
return ESP_OK;
}

View File

@ -119,32 +119,32 @@ void touch_hal_filter_set_config(const touch_filter_config_t *filter_info);
void touch_hal_filter_get_config(touch_filter_config_t *filter_info);
/**
* Get baseline value of touch sensor.
* Get benchmark value of touch sensor.
*
* @note After initialization, the baseline value is the maximum during the first measurement period.
* @note After initialization, the benchmark value is the maximum during the first measurement period.
* @param touch_num touch pad index
* @param touch_value pointer to accept touch sensor value
*/
#define touch_hal_filter_read_baseline(touch_num, basedata) touch_ll_filter_read_baseline(touch_num, basedata)
#define touch_hal_filter_read_benchmark(touch_num, basedata) touch_ll_filter_read_benchmark(touch_num, basedata)
/**
* Force reset baseline to raw data of touch sensor.
* Force reset benchmark to raw data of touch sensor.
*
* @param touch_num touch pad index
* - TOUCH_PAD_MAX Reset basaline of all channels.
*/
#define touch_hal_filter_reset_baseline(touch_num) touch_ll_filter_reset_baseline(touch_num)
#define touch_hal_filter_reset_benchmark(touch_num) touch_ll_filter_reset_benchmark(touch_num)
/**
* Set filter mode. The input to the filter is raw data and the output is the baseline value.
* Larger filter coefficients increase the stability of the baseline.
* Set filter mode. The input to the filter is raw data and the output is the benchmark value.
* Larger filter coefficients increase the stability of the benchmark.
*
* @param mode Filter mode type. Refer to `touch_filter_mode_t`.
*/
#define touch_hal_filter_set_filter_mode(mode) touch_ll_filter_set_filter_mode(mode)
/**
* Get filter mode. The input to the filter is raw data and the output is the baseline value.
* Get filter mode. The input to the filter is raw data and the output is the benchmark value.
*
* @param mode Filter mode type. Refer to `touch_filter_mode_t`.
*/
@ -165,30 +165,10 @@ void touch_hal_filter_get_config(touch_filter_config_t *filter_info);
*/
#define touch_hal_filter_get_debounce(dbc_cnt) touch_ll_filter_get_debounce(dbc_cnt)
/**
* Set hysteresis threshold coefficient. hysteresis = hysteresis_thr * touch_threshold.
* If (raw data - baseline) > (touch threshold + hysteresis), the touch channel be touched.
* If (raw data - baseline) < (touch threshold - hysteresis), the touch channel be released.
* Range: 0 ~ 3. The coefficient is 0: 1/8; 1: 3/32; 2: 1/16; 3: 1/32
*
* @param hys_thr hysteresis coefficient.
*/
#define touch_hal_filter_set_hysteresis(hys_thr) touch_ll_filter_set_hysteresis(hys_thr)
/**
* Get hysteresis threshold coefficient. hysteresis = hysteresis_thr * touch_threshold.
* If (raw data - baseline) > (touch threshold + hysteresis), the touch channel be touched.
* If (raw data - baseline) < (touch threshold - hysteresis), the touch channel be released.
* Range: 0 ~ 3. The coefficient is 0: 1/8; 1: 3/32; 2: 1/16; 3: 1/32
*
* @param hys_thr hysteresis coefficient.
*/
#define touch_hal_filter_get_hysteresis(hys_thr) touch_ll_filter_get_hysteresis(hys_thr)
/**
* Set noise threshold coefficient. noise = noise_thr * touch threshold.
* If (raw data - baseline) > (noise), the baseline stop updating.
* If (raw data - baseline) < (noise), the baseline start updating.
* If (raw data - benchmark) > (noise), the benchmark stop updating.
* If (raw data - benchmark) < (noise), the benchmark start updating.
* Range: 0 ~ 3. The coefficient is 0: 1/2; 1: 3/8; 2: 1/4; 3: 1/8;
*
* @param hys_thr Noise threshold coefficient.
@ -197,8 +177,8 @@ void touch_hal_filter_get_config(touch_filter_config_t *filter_info);
/**
* Get noise threshold coefficient. noise = noise_thr * touch threshold.
* If (raw data - baseline) > (noise), the baseline stop updating.
* If (raw data - baseline) < (noise), the baseline start updating.
* If (raw data - benchmark) > (noise), the benchmark stop updating.
* If (raw data - benchmark) < (noise), the benchmark start updating.
* Range: 0 ~ 3. The coefficient is 0: 1/2; 1: 3/8; 2: 1/4; 3: 1/8;
*
* @param noise_thr Noise threshold coefficient.
@ -206,49 +186,29 @@ void touch_hal_filter_get_config(touch_filter_config_t *filter_info);
#define touch_hal_filter_get_noise_thres(noise_thr) touch_ll_filter_get_noise_thres(noise_thr)
/**
* Set negative noise threshold coefficient. negative noise = noise_neg_thr * touch threshold.
* If (baseline - raw data) > (negative noise), the baseline restart reset process(refer to `baseline_reset`).
* If (baseline - raw data) < (negative noise), the baseline stop reset process(refer to `baseline_reset`).
* Range: 0 ~ 3. The coefficient is 0: 1/2; 1: 3/8; 2: 1/4; 3: 1/8;
*
* @param noise_thr Negative threshold coefficient.
*/
#define touch_hal_filter_set_neg_noise_thres(noise_thr) touch_ll_filter_set_neg_noise_thres(noise_thr)
/**
* Get negative noise threshold coefficient. negative noise = noise_neg_thr * touch threshold.
* If (baseline - raw data) > (negative noise), the baseline restart reset process(refer to `baseline_reset`).
* If (baseline - raw data) < (negative noise), the baseline stop reset process(refer to `baseline_reset`).
* Range: 0 ~ 3. The coefficient is 0: 1/2; 1: 3/8; 2: 1/4; 3: 1/8;
*
* @param noise_thr Negative noise threshold coefficient.
*/
#define touch_hal_filter_get_neg_noise_thres(noise_thr) touch_ll_filter_get_neg_noise_thres(noise_thr)
/**
* Set the cumulative number of baseline reset processes. such as `n`. If the measured values continue to exceed
* the negative noise threshold for `n` times, the baseline reset to raw data.
* Set the cumulative number of benchmark reset processes. such as `n`. If the measured values continue to exceed
* the negative noise threshold for `n` times, the benchmark reset to raw data.
* Range: 0 ~ 15
*
* @param reset_cnt The cumulative number of baseline reset processes.
* @param reset_cnt The cumulative number of benchmark reset processes.
*/
#define touch_hal_filter_set_baseline_reset(reset_cnt) touch_ll_filter_set_baseline_reset(reset_cnt)
#define touch_hal_filter_set_benchmark_reset(reset_cnt) touch_ll_filter_set_benchmark_reset(reset_cnt)
/**
* Get the cumulative number of baseline reset processes. such as `n`. If the measured values continue to exceed
* the negative noise threshold for `n` times, the baseline reset to raw data.
* Get the cumulative number of benchmark reset processes. such as `n`. If the measured values continue to exceed
* the negative noise threshold for `n` times, the benchmark reset to raw data.
* Range: 0 ~ 15
*
* @param reset_cnt The cumulative number of baseline reset processes.
* @param reset_cnt The cumulative number of benchmark reset processes.
*/
#define touch_hal_filter_get_baseline_reset(reset_cnt) touch_ll_filter_get_baseline_reset(reset_cnt)
#define touch_hal_filter_get_benchmark_reset(reset_cnt) touch_ll_filter_get_benchmark_reset(reset_cnt)
/**
* Set jitter filter step size.
* If filter mode is jitter, should set filter step for jitter.
* Range: 0 ~ 15
*
* @param step The step size of the data change when the baseline is updated.
* @param step The step size of the data change when the benchmark is updated.
*/
#define touch_hal_filter_set_jitter_step(step) touch_ll_filter_set_jitter_step(step)
@ -257,7 +217,7 @@ void touch_hal_filter_get_config(touch_filter_config_t *filter_info);
* If filter mode is jitter, should set filter step for jitter.
* Range: 0 ~ 15
*
* @param step The step size of the data change when the baseline is updated.
* @param step The step size of the data change when the benchmark is updated.
*/
#define touch_hal_filter_get_jitter_step(step) touch_ll_filter_get_jitter_step(step)
@ -519,7 +479,7 @@ void touch_hal_sleep_channel_config(const touch_pad_sleep_channel_t *slp_config)
/**
* Set the trigger threshold of touch sensor in deep sleep.
* The threshold determines the sensitivity of the touch sensor.
* The threshold is the original value of the trigger state minus the baseline value.
* The threshold is the original value of the trigger state minus the benchmark value.
*
* @note The threshold at sleep is the same as the threshold before sleep.
*/
@ -528,7 +488,7 @@ void touch_hal_sleep_channel_config(const touch_pad_sleep_channel_t *slp_config)
/**
* Get the trigger threshold of touch sensor in deep sleep.
* The threshold determines the sensitivity of the touch sensor.
* The threshold is the original value of the trigger state minus the baseline value.
* The threshold is the original value of the trigger state minus the benchmark value.
*
* @note The threshold at sleep is the same as the threshold before sleep.
*/
@ -545,11 +505,11 @@ void touch_hal_sleep_channel_config(const touch_pad_sleep_channel_t *slp_config)
#define touch_hal_sleep_disable_approach() touch_ll_sleep_disable_approach()
/**
* Read baseline of touch sensor for sleep pad.
* Read benchmark of touch sensor for sleep pad.
*
* @param baseline Pointer to accept touch sensor baseline value.
* @param benchmark Pointer to accept touch sensor benchmark value.
*/
#define touch_hal_sleep_read_baseline(baseline) touch_ll_sleep_read_baseline(baseline)
#define touch_hal_sleep_read_benchmark(benchmark) touch_ll_sleep_read_benchmark(benchmark)
/**
* Read debounce of touch sensor for sleep pad.

View File

@ -264,7 +264,7 @@ static inline void touch_ll_start_sw_meas(void)
/**
* Set the trigger threshold of touch sensor.
* The threshold determines the sensitivity of the touch sensor.
* The threshold is the original value of the trigger state minus the baseline value.
* The threshold is the original value of the trigger state minus the benchmark value.
*
* @note If set "TOUCH_PAD_THRESHOLD_MAX", the touch is never be trigered.
* @param touch_num touch pad index
@ -278,7 +278,7 @@ static inline void touch_ll_set_threshold(touch_pad_t touch_num, uint32_t thresh
/**
* Get the trigger threshold of touch sensor.
* The threshold determines the sensitivity of the touch sensor.
* The threshold is the original value of the trigger state minus the baseline value.
* The threshold is the original value of the trigger state minus the benchmark value.
*
* @param touch_num touch pad index.
* @param threshold pointer to accept threshold.
@ -521,24 +521,24 @@ static inline uint32_t touch_ll_read_intr_status_mask(void)
/************************ Filter register setting ************************/
/**
* Get baseline value of touch sensor.
* Get benchmark value of touch sensor.
*
* @note After initialization, the baseline value is the maximum during the first measurement period.
* @note After initialization, the benchmark value is the maximum during the first measurement period.
* @param touch_num touch pad index
* @param touch_value pointer to accept touch sensor value
*/
static inline void touch_ll_filter_read_baseline(touch_pad_t touch_num, uint32_t *basedata)
static inline void touch_ll_filter_read_benchmark(touch_pad_t touch_num, uint32_t *basedata)
{
*basedata = SENS.sar_touch_status[touch_num - 1].touch_pad_baseline;
*basedata = SENS.sar_touch_status[touch_num - 1].touch_pad_benchmark;
}
/**
* Force reset baseline to raw data of touch sensor.
* Force reset benchmark to raw data of touch sensor.
*
* @param touch_num touch pad index
* - TOUCH_PAD_MAX Reset basaline of all channels.
*/
static inline void touch_ll_filter_reset_baseline(touch_pad_t touch_num)
static inline void touch_ll_filter_reset_benchmark(touch_pad_t touch_num)
{
if (touch_num == TOUCH_PAD_MAX) {
SENS.sar_touch_chn_st.touch_channel_clr = SOC_TOUCH_SENSOR_BIT_MASK_MAX;
@ -548,8 +548,8 @@ static inline void touch_ll_filter_reset_baseline(touch_pad_t touch_num)
}
/**
* Set filter mode. The input to the filter is raw data and the output is the baseline value.
* Larger filter coefficients increase the stability of the baseline.
* Set filter mode. The input to the filter is raw data and the output is the benchmark value.
* Larger filter coefficients increase the stability of the benchmark.
*
* @param mode Filter mode type. Refer to `touch_filter_mode_t`.
*/
@ -559,7 +559,7 @@ static inline void touch_ll_filter_set_filter_mode(touch_filter_mode_t mode)
}
/**
* Get filter mode. The input to the filter is raw data and the output is the baseline value.
* Get filter mode. The input to the filter is raw data and the output is the benchmark value.
*
* @param mode Filter mode type. Refer to `touch_filter_mode_t`.
*/
@ -589,36 +589,10 @@ static inline void touch_ll_filter_get_debounce(uint32_t *dbc_cnt)
*dbc_cnt = RTCCNTL.touch_filter_ctrl.touch_debounce;
}
/**
* Set hysteresis threshold coefficient. hysteresis = hysteresis_thr * touch_threshold.
* If (raw data - baseline) > (touch threshold + hysteresis), the touch channel be touched.
* If (raw data - baseline) < (touch threshold - hysteresis), the touch channel be released.
* Range: 0 ~ 3. The coefficient is 0: 1/8; 1: 3/32; 2: 1/16; 3: 1/32
*
* @param hys_thr hysteresis coefficient.
*/
static inline void touch_ll_filter_set_hysteresis(uint32_t hys_thr)
{
RTCCNTL.touch_filter_ctrl.touch_hysteresis = hys_thr;
}
/**
* Get hysteresis threshold coefficient. hysteresis = hysteresis_thr * touch_threshold.
* If (raw data - baseline) > (touch threshold + hysteresis), the touch channel be touched.
* If (raw data - baseline) < (touch threshold - hysteresis), the touch channel be released.
* Range: 0 ~ 3. The coefficient is 0: 1/8; 1: 3/32; 2: 1/16; 3: 1/32
*
* @param hys_thr hysteresis coefficient.
*/
static inline void touch_ll_filter_get_hysteresis(uint32_t *hys_thr)
{
*hys_thr = RTCCNTL.touch_filter_ctrl.touch_hysteresis;
}
/**
* Set noise threshold coefficient. noise = noise_thr * touch threshold.
* If (raw data - baseline) > (noise), the baseline stop updating.
* If (raw data - baseline) < (noise), the baseline start updating.
* If (raw data - benchmark) > (noise), the benchmark stop updating.
* If (raw data - benchmark) < (noise), the benchmark start updating.
* Range: 0 ~ 3. The coefficient is 0: 1/2; 1: 3/8; 2: 1/4; 3: 1/8;
*
* @param hys_thr Noise threshold coefficient.
@ -626,12 +600,15 @@ static inline void touch_ll_filter_get_hysteresis(uint32_t *hys_thr)
static inline void touch_ll_filter_set_noise_thres(uint32_t noise_thr)
{
RTCCNTL.touch_filter_ctrl.touch_noise_thres = noise_thr;
RTCCNTL.touch_filter_ctrl.config2 = noise_thr;
RTCCNTL.touch_filter_ctrl.config1 = 0xF;
RTCCNTL.touch_filter_ctrl.config3 = 2;
}
/**
* Get noise threshold coefficient. noise = noise_thr * touch threshold.
* If (raw data - baseline) > (noise), the baseline stop updating.
* If (raw data - baseline) < (noise), the baseline start updating.
* If (raw data - benchmark) > (noise), the benchmark stop updating.
* If (raw data - benchmark) < (noise), the benchmark start updating.
* Range: 0 ~ 3. The coefficient is 0: 1/2; 1: 3/8; 2: 1/4; 3: 1/8;
*
* @param noise_thr Noise threshold coefficient.
@ -641,62 +618,12 @@ static inline void touch_ll_filter_get_noise_thres(uint32_t *noise_thr)
*noise_thr = RTCCNTL.touch_filter_ctrl.touch_noise_thres;
}
/**
* Set negative noise threshold coefficient. negative noise = noise_neg_thr * touch threshold.
* If (baseline - raw data) > (negative noise), the baseline restart reset process(refer to `baseline_reset`).
* If (baseline - raw data) < (negative noise), the baseline stop reset process(refer to `baseline_reset`).
* Range: 0 ~ 3. The coefficient is 0: 1/2; 1: 3/8; 2: 1/4; 3: 1/8;
*
* @param noise_thr Negative threshold coefficient.
*/
static inline void touch_ll_filter_set_neg_noise_thres(uint32_t noise_thr)
{
RTCCNTL.touch_filter_ctrl.touch_neg_noise_thres = noise_thr;
}
/**
* Get negative noise threshold coefficient. negative noise = noise_neg_thr * touch threshold.
* If (baseline - raw data) > (negative noise), the baseline restart reset process(refer to `baseline_reset`).
* If (baseline - raw data) < (negative noise), the baseline stop reset process(refer to `baseline_reset`).
* Range: 0 ~ 3. The coefficient is 0: 1/2; 1: 3/8; 2: 1/4; 3: 1/8;
*
* @param noise_thr Negative noise threshold coefficient.
*/
static inline void touch_ll_filter_get_neg_noise_thres(uint32_t *noise_thr)
{
*noise_thr = RTCCNTL.touch_filter_ctrl.touch_neg_noise_thres;
}
/**
* Set the cumulative number of baseline reset processes. such as `n`. If the measured values continue to exceed
* the negative noise threshold for `n` times, the baseline reset to raw data.
* Range: 0 ~ 15
*
* @param reset_cnt The cumulative number of baseline reset processes.
*/
static inline void touch_ll_filter_set_baseline_reset(uint32_t reset_cnt)
{
RTCCNTL.touch_filter_ctrl.touch_neg_noise_limit = reset_cnt;
}
/**
* Get the cumulative number of baseline reset processes. such as `n`. If the measured values continue to exceed
* the negative noise threshold for `n` times, the baseline reset to raw data.
* Range: 0 ~ 15
*
* @param reset_cnt The cumulative number of baseline reset processes.
*/
static inline void touch_ll_filter_get_baseline_reset(uint32_t *reset_cnt)
{
*reset_cnt = RTCCNTL.touch_filter_ctrl.touch_neg_noise_limit;
}
/**
* Set jitter filter step size.
* If filter mode is jitter, should set filter step for jitter.
* Range: 0 ~ 15
*
* @param step The step size of the data change when the baseline is updated.
* @param step The step size of the data change when the benchmark is updated.
*/
static inline void touch_ll_filter_set_jitter_step(uint32_t step)
{
@ -708,7 +635,7 @@ static inline void touch_ll_filter_set_jitter_step(uint32_t step)
* If filter mode is jitter, should set filter step for jitter.
* Range: 0 ~ 15
*
* @param step The step size of the data change when the baseline is updated.
* @param step The step size of the data change when the benchmark is updated.
*/
static inline void touch_ll_filter_get_jitter_step(uint32_t *step)
{
@ -996,7 +923,7 @@ static inline void touch_ll_sleep_get_channel_num(touch_pad_t *touch_num)
/**
* Set the trigger threshold of touch sensor in deep sleep.
* The threshold determines the sensitivity of the touch sensor.
* The threshold is the original value of the trigger state minus the baseline value.
* The threshold is the original value of the trigger state minus the benchmark value.
*
* @note The threshold at sleep is the same as the threshold before sleep.
*/
@ -1008,7 +935,7 @@ static inline void touch_ll_sleep_set_threshold(uint32_t touch_thres)
/**
* Get the trigger threshold of touch sensor in deep sleep.
* The threshold determines the sensitivity of the touch sensor.
* The threshold is the original value of the trigger state minus the baseline value.
* The threshold is the original value of the trigger state minus the benchmark value.
*
* @note The threshold at sleep is the same as the threshold before sleep.
*/
@ -1034,13 +961,13 @@ static inline void touch_ll_sleep_disable_approach(void)
}
/**
* Read baseline of touch sensor for sleep pad.
* Read benchmark of touch sensor for sleep pad.
*
* @param baseline Pointer to accept touch sensor baseline value.
* @param benchmark Pointer to accept touch sensor benchmark value.
*/
static inline void touch_ll_sleep_read_baseline(uint32_t *baseline)
static inline void touch_ll_sleep_read_benchmark(uint32_t *benchmark)
{
*baseline = REG_GET_FIELD(SENS_SAR_TOUCH_SLP_STATUS_REG, SENS_TOUCH_SLP_BASELINE);
*benchmark = REG_GET_FIELD(SENS_SAR_TOUCH_SLP_STATUS_REG, SENS_TOUCH_SLP_BENCHMARK);
}
/**

View File

@ -3040,30 +3040,30 @@ extern "C" {
#define RTC_CNTL_TOUCH_DEBOUNCE_M ((RTC_CNTL_TOUCH_DEBOUNCE_V)<<(RTC_CNTL_TOUCH_DEBOUNCE_S))
#define RTC_CNTL_TOUCH_DEBOUNCE_V 0x7
#define RTC_CNTL_TOUCH_DEBOUNCE_S 26
/* RTC_CNTL_TOUCH_HYSTERESIS : R/W ;bitpos:[25:24] ;default: 2'd1 ; */
/* RTC_CNTL_TOUCH_CONFIG3 : R/W ;bitpos:[25:24] ;default: 2'd1 ; */
/*description: */
#define RTC_CNTL_TOUCH_HYSTERESIS 0x00000003
#define RTC_CNTL_TOUCH_HYSTERESIS_M ((RTC_CNTL_TOUCH_HYSTERESIS_V)<<(RTC_CNTL_TOUCH_HYSTERESIS_S))
#define RTC_CNTL_TOUCH_HYSTERESIS_V 0x3
#define RTC_CNTL_TOUCH_HYSTERESIS_S 24
#define RTC_CNTL_TOUCH_CONFIG3 0x00000003
#define RTC_CNTL_TOUCH_CONFIG3_M ((RTC_CNTL_TOUCH_CONFIG3_V)<<(RTC_CNTL_TOUCH_CONFIG3_S))
#define RTC_CNTL_TOUCH_CONFIG3_V 0x3
#define RTC_CNTL_TOUCH_CONFIG3_S 24
/* RTC_CNTL_TOUCH_NOISE_THRES : R/W ;bitpos:[23:22] ;default: 2'd1 ; */
/*description: */
#define RTC_CNTL_TOUCH_NOISE_THRES 0x00000003
#define RTC_CNTL_TOUCH_NOISE_THRES_M ((RTC_CNTL_TOUCH_NOISE_THRES_V)<<(RTC_CNTL_TOUCH_NOISE_THRES_S))
#define RTC_CNTL_TOUCH_NOISE_THRES_V 0x3
#define RTC_CNTL_TOUCH_NOISE_THRES_S 22
/* RTC_CNTL_TOUCH_NEG_NOISE_THRES : R/W ;bitpos:[21:20] ;default: 2'd1 ; */
/* RTC_CNTL_TOUCH_CONFIG2 : R/W ;bitpos:[21:20] ;default: 2'd1 ; */
/*description: */
#define RTC_CNTL_TOUCH_NEG_NOISE_THRES 0x00000003
#define RTC_CNTL_TOUCH_NEG_NOISE_THRES_M ((RTC_CNTL_TOUCH_NEG_NOISE_THRES_V)<<(RTC_CNTL_TOUCH_NEG_NOISE_THRES_S))
#define RTC_CNTL_TOUCH_NEG_NOISE_THRES_V 0x3
#define RTC_CNTL_TOUCH_NEG_NOISE_THRES_S 20
/* RTC_CNTL_TOUCH_NEG_NOISE_LIMIT : R/W ;bitpos:[19:16] ;default: 4'd5 ; */
#define RTC_CNTL_TOUCH_CONFIG2 0x00000003
#define RTC_CNTL_TOUCH_CONFIG2_M ((RTC_CNTL_TOUCH_CONFIG2_V)<<(RTC_CNTL_TOUCH_CONFIG2_S))
#define RTC_CNTL_TOUCH_CONFIG2_V 0x3
#define RTC_CNTL_TOUCH_CONFIG2_S 20
/* RTC_CNTL_TOUCH_CONFIG1 : R/W ;bitpos:[19:16] ;default: 4'd5 ; */
/*description: negative threshold counter limit*/
#define RTC_CNTL_TOUCH_NEG_NOISE_LIMIT 0x0000000F
#define RTC_CNTL_TOUCH_NEG_NOISE_LIMIT_M ((RTC_CNTL_TOUCH_NEG_NOISE_LIMIT_V)<<(RTC_CNTL_TOUCH_NEG_NOISE_LIMIT_S))
#define RTC_CNTL_TOUCH_NEG_NOISE_LIMIT_V 0xF
#define RTC_CNTL_TOUCH_NEG_NOISE_LIMIT_S 16
#define RTC_CNTL_TOUCH_CONFIG1 0x0000000F
#define RTC_CNTL_TOUCH_CONFIG1_M ((RTC_CNTL_TOUCH_CONFIG1_V)<<(RTC_CNTL_TOUCH_CONFIG1_S))
#define RTC_CNTL_TOUCH_CONFIG1_V 0xF
#define RTC_CNTL_TOUCH_CONFIG1_S 16
/* RTC_CNTL_TOUCH_JITTER_STEP : R/W ;bitpos:[15:12] ;default: 4'd1 ; */
/*description: touch jitter step*/
#define RTC_CNTL_TOUCH_JITTER_STEP 0x0000000F

View File

@ -791,10 +791,10 @@ typedef volatile struct {
struct {
uint32_t reserved0: 12;
uint32_t touch_jitter_step: 4; /*touch jitter step*/
uint32_t touch_neg_noise_limit: 4; /*negative threshold counter limit*/
uint32_t touch_neg_noise_thres: 2;
uint32_t config1: 4;
uint32_t config2: 2;
uint32_t touch_noise_thres: 2;
uint32_t touch_hysteresis: 2;
uint32_t config3: 2;
uint32_t touch_debounce: 3; /*debounce counter*/
uint32_t touch_filter_mode: 2; /*0: IIR ? 1: IIR ? 2: IIR 1/8 3: Jitter*/
uint32_t touch_filter_en: 1; /*touch filter enable*/

View File

@ -961,12 +961,12 @@ extern "C" {
#define SENS_TOUCH_PAD1_DEBOUNCE_M ((SENS_TOUCH_PAD1_DEBOUNCE_V)<<(SENS_TOUCH_PAD1_DEBOUNCE_S))
#define SENS_TOUCH_PAD1_DEBOUNCE_V 0x7
#define SENS_TOUCH_PAD1_DEBOUNCE_S 29
/* SENS_TOUCH_PAD1_BASELINE : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/* SENS_TOUCH_PAD1_BENCHMARK : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/*description: */
#define SENS_TOUCH_PAD1_BASELINE 0x003FFFFF
#define SENS_TOUCH_PAD1_BASELINE_M ((SENS_TOUCH_PAD1_BASELINE_V)<<(SENS_TOUCH_PAD1_BASELINE_S))
#define SENS_TOUCH_PAD1_BASELINE_V 0x3FFFFF
#define SENS_TOUCH_PAD1_BASELINE_S 0
#define SENS_TOUCH_PAD1_BENCHMARK 0x003FFFFF
#define SENS_TOUCH_PAD1_BENCHMARK_M ((SENS_TOUCH_PAD1_BENCHMARK_V)<<(SENS_TOUCH_PAD1_BENCHMARK_S))
#define SENS_TOUCH_PAD1_BENCHMARK_V 0x3FFFFF
#define SENS_TOUCH_PAD1_BENCHMARK_S 0
#define SENS_SAR_TOUCH_STATUS2_REG (DR_REG_SENS_BASE + 0x00e0)
/* SENS_TOUCH_PAD2_DEBOUNCE : RO ;bitpos:[31:29] ;default: 3'd0 ; */
@ -975,12 +975,12 @@ extern "C" {
#define SENS_TOUCH_PAD2_DEBOUNCE_M ((SENS_TOUCH_PAD2_DEBOUNCE_V)<<(SENS_TOUCH_PAD2_DEBOUNCE_S))
#define SENS_TOUCH_PAD2_DEBOUNCE_V 0x7
#define SENS_TOUCH_PAD2_DEBOUNCE_S 29
/* SENS_TOUCH_PAD2_BASELINE : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/* SENS_TOUCH_PAD2_BENCHMARK : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/*description: */
#define SENS_TOUCH_PAD2_BASELINE 0x003FFFFF
#define SENS_TOUCH_PAD2_BASELINE_M ((SENS_TOUCH_PAD2_BASELINE_V)<<(SENS_TOUCH_PAD2_BASELINE_S))
#define SENS_TOUCH_PAD2_BASELINE_V 0x3FFFFF
#define SENS_TOUCH_PAD2_BASELINE_S 0
#define SENS_TOUCH_PAD2_BENCHMARK 0x003FFFFF
#define SENS_TOUCH_PAD2_BENCHMARK_M ((SENS_TOUCH_PAD2_BENCHMARK_V)<<(SENS_TOUCH_PAD2_BENCHMARK_S))
#define SENS_TOUCH_PAD2_BENCHMARK_V 0x3FFFFF
#define SENS_TOUCH_PAD2_BENCHMARK_S 0
#define SENS_SAR_TOUCH_STATUS3_REG (DR_REG_SENS_BASE + 0x00e4)
/* SENS_TOUCH_PAD3_DEBOUNCE : RO ;bitpos:[31:29] ;default: 3'd0 ; */
@ -989,12 +989,12 @@ extern "C" {
#define SENS_TOUCH_PAD3_DEBOUNCE_M ((SENS_TOUCH_PAD3_DEBOUNCE_V)<<(SENS_TOUCH_PAD3_DEBOUNCE_S))
#define SENS_TOUCH_PAD3_DEBOUNCE_V 0x7
#define SENS_TOUCH_PAD3_DEBOUNCE_S 29
/* SENS_TOUCH_PAD3_BASELINE : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/* SENS_TOUCH_PAD3_BENCHMARK : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/*description: */
#define SENS_TOUCH_PAD3_BASELINE 0x003FFFFF
#define SENS_TOUCH_PAD3_BASELINE_M ((SENS_TOUCH_PAD3_BASELINE_V)<<(SENS_TOUCH_PAD3_BASELINE_S))
#define SENS_TOUCH_PAD3_BASELINE_V 0x3FFFFF
#define SENS_TOUCH_PAD3_BASELINE_S 0
#define SENS_TOUCH_PAD3_BENCHMARK 0x003FFFFF
#define SENS_TOUCH_PAD3_BENCHMARK_M ((SENS_TOUCH_PAD3_BENCHMARK_V)<<(SENS_TOUCH_PAD3_BENCHMARK_S))
#define SENS_TOUCH_PAD3_BENCHMARK_V 0x3FFFFF
#define SENS_TOUCH_PAD3_BENCHMARK_S 0
#define SENS_SAR_TOUCH_STATUS4_REG (DR_REG_SENS_BASE + 0x00e8)
/* SENS_TOUCH_PAD4_DEBOUNCE : RO ;bitpos:[31:29] ;default: 3'd0 ; */
@ -1003,12 +1003,12 @@ extern "C" {
#define SENS_TOUCH_PAD4_DEBOUNCE_M ((SENS_TOUCH_PAD4_DEBOUNCE_V)<<(SENS_TOUCH_PAD4_DEBOUNCE_S))
#define SENS_TOUCH_PAD4_DEBOUNCE_V 0x7
#define SENS_TOUCH_PAD4_DEBOUNCE_S 29
/* SENS_TOUCH_PAD4_BASELINE : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/* SENS_TOUCH_PAD4_BENCHMARK : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/*description: */
#define SENS_TOUCH_PAD4_BASELINE 0x003FFFFF
#define SENS_TOUCH_PAD4_BASELINE_M ((SENS_TOUCH_PAD4_BASELINE_V)<<(SENS_TOUCH_PAD4_BASELINE_S))
#define SENS_TOUCH_PAD4_BASELINE_V 0x3FFFFF
#define SENS_TOUCH_PAD4_BASELINE_S 0
#define SENS_TOUCH_PAD4_BENCHMARK 0x003FFFFF
#define SENS_TOUCH_PAD4_BENCHMARK_M ((SENS_TOUCH_PAD4_BENCHMARK_V)<<(SENS_TOUCH_PAD4_BENCHMARK_S))
#define SENS_TOUCH_PAD4_BENCHMARK_V 0x3FFFFF
#define SENS_TOUCH_PAD4_BENCHMARK_S 0
#define SENS_SAR_TOUCH_STATUS5_REG (DR_REG_SENS_BASE + 0x00ec)
/* SENS_TOUCH_PAD5_DEBOUNCE : RO ;bitpos:[31:29] ;default: 3'd0 ; */
@ -1017,12 +1017,12 @@ extern "C" {
#define SENS_TOUCH_PAD5_DEBOUNCE_M ((SENS_TOUCH_PAD5_DEBOUNCE_V)<<(SENS_TOUCH_PAD5_DEBOUNCE_S))
#define SENS_TOUCH_PAD5_DEBOUNCE_V 0x7
#define SENS_TOUCH_PAD5_DEBOUNCE_S 29
/* SENS_TOUCH_PAD5_BASELINE : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/* SENS_TOUCH_PAD5_BENCHMARK : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/*description: */
#define SENS_TOUCH_PAD5_BASELINE 0x003FFFFF
#define SENS_TOUCH_PAD5_BASELINE_M ((SENS_TOUCH_PAD5_BASELINE_V)<<(SENS_TOUCH_PAD5_BASELINE_S))
#define SENS_TOUCH_PAD5_BASELINE_V 0x3FFFFF
#define SENS_TOUCH_PAD5_BASELINE_S 0
#define SENS_TOUCH_PAD5_BENCHMARK 0x003FFFFF
#define SENS_TOUCH_PAD5_BENCHMARK_M ((SENS_TOUCH_PAD5_BENCHMARK_V)<<(SENS_TOUCH_PAD5_BENCHMARK_S))
#define SENS_TOUCH_PAD5_BENCHMARK_V 0x3FFFFF
#define SENS_TOUCH_PAD5_BENCHMARK_S 0
#define SENS_SAR_TOUCH_STATUS6_REG (DR_REG_SENS_BASE + 0x00f0)
/* SENS_TOUCH_PAD6_DEBOUNCE : RO ;bitpos:[31:29] ;default: 3'd0 ; */
@ -1031,12 +1031,12 @@ extern "C" {
#define SENS_TOUCH_PAD6_DEBOUNCE_M ((SENS_TOUCH_PAD6_DEBOUNCE_V)<<(SENS_TOUCH_PAD6_DEBOUNCE_S))
#define SENS_TOUCH_PAD6_DEBOUNCE_V 0x7
#define SENS_TOUCH_PAD6_DEBOUNCE_S 29
/* SENS_TOUCH_PAD6_BASELINE : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/* SENS_TOUCH_PAD6_BENCHMARK : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/*description: */
#define SENS_TOUCH_PAD6_BASELINE 0x003FFFFF
#define SENS_TOUCH_PAD6_BASELINE_M ((SENS_TOUCH_PAD6_BASELINE_V)<<(SENS_TOUCH_PAD6_BASELINE_S))
#define SENS_TOUCH_PAD6_BASELINE_V 0x3FFFFF
#define SENS_TOUCH_PAD6_BASELINE_S 0
#define SENS_TOUCH_PAD6_BENCHMARK 0x003FFFFF
#define SENS_TOUCH_PAD6_BENCHMARK_M ((SENS_TOUCH_PAD6_BENCHMARK_V)<<(SENS_TOUCH_PAD6_BENCHMARK_S))
#define SENS_TOUCH_PAD6_BENCHMARK_V 0x3FFFFF
#define SENS_TOUCH_PAD6_BENCHMARK_S 0
#define SENS_SAR_TOUCH_STATUS7_REG (DR_REG_SENS_BASE + 0x00f4)
/* SENS_TOUCH_PAD7_DEBOUNCE : RO ;bitpos:[31:29] ;default: 3'd0 ; */
@ -1045,12 +1045,12 @@ extern "C" {
#define SENS_TOUCH_PAD7_DEBOUNCE_M ((SENS_TOUCH_PAD7_DEBOUNCE_V)<<(SENS_TOUCH_PAD7_DEBOUNCE_S))
#define SENS_TOUCH_PAD7_DEBOUNCE_V 0x7
#define SENS_TOUCH_PAD7_DEBOUNCE_S 29
/* SENS_TOUCH_PAD7_BASELINE : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/* SENS_TOUCH_PAD7_BENCHMARK : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/*description: */
#define SENS_TOUCH_PAD7_BASELINE 0x003FFFFF
#define SENS_TOUCH_PAD7_BASELINE_M ((SENS_TOUCH_PAD7_BASELINE_V)<<(SENS_TOUCH_PAD7_BASELINE_S))
#define SENS_TOUCH_PAD7_BASELINE_V 0x3FFFFF
#define SENS_TOUCH_PAD7_BASELINE_S 0
#define SENS_TOUCH_PAD7_BENCHMARK 0x003FFFFF
#define SENS_TOUCH_PAD7_BENCHMARK_M ((SENS_TOUCH_PAD7_BENCHMARK_V)<<(SENS_TOUCH_PAD7_BENCHMARK_S))
#define SENS_TOUCH_PAD7_BENCHMARK_V 0x3FFFFF
#define SENS_TOUCH_PAD7_BENCHMARK_S 0
#define SENS_SAR_TOUCH_STATUS8_REG (DR_REG_SENS_BASE + 0x00f8)
/* SENS_TOUCH_PAD8_DEBOUNCE : RO ;bitpos:[31:29] ;default: 3'd0 ; */
@ -1059,12 +1059,12 @@ extern "C" {
#define SENS_TOUCH_PAD8_DEBOUNCE_M ((SENS_TOUCH_PAD8_DEBOUNCE_V)<<(SENS_TOUCH_PAD8_DEBOUNCE_S))
#define SENS_TOUCH_PAD8_DEBOUNCE_V 0x7
#define SENS_TOUCH_PAD8_DEBOUNCE_S 29
/* SENS_TOUCH_PAD8_BASELINE : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/* SENS_TOUCH_PAD8_BENCHMARK : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/*description: */
#define SENS_TOUCH_PAD8_BASELINE 0x003FFFFF
#define SENS_TOUCH_PAD8_BASELINE_M ((SENS_TOUCH_PAD8_BASELINE_V)<<(SENS_TOUCH_PAD8_BASELINE_S))
#define SENS_TOUCH_PAD8_BASELINE_V 0x3FFFFF
#define SENS_TOUCH_PAD8_BASELINE_S 0
#define SENS_TOUCH_PAD8_BENCHMARK 0x003FFFFF
#define SENS_TOUCH_PAD8_BENCHMARK_M ((SENS_TOUCH_PAD8_BENCHMARK_V)<<(SENS_TOUCH_PAD8_BENCHMARK_S))
#define SENS_TOUCH_PAD8_BENCHMARK_V 0x3FFFFF
#define SENS_TOUCH_PAD8_BENCHMARK_S 0
#define SENS_SAR_TOUCH_STATUS9_REG (DR_REG_SENS_BASE + 0x00fc)
/* SENS_TOUCH_PAD9_DEBOUNCE : RO ;bitpos:[31:29] ;default: 3'd0 ; */
@ -1073,12 +1073,12 @@ extern "C" {
#define SENS_TOUCH_PAD9_DEBOUNCE_M ((SENS_TOUCH_PAD9_DEBOUNCE_V)<<(SENS_TOUCH_PAD9_DEBOUNCE_S))
#define SENS_TOUCH_PAD9_DEBOUNCE_V 0x7
#define SENS_TOUCH_PAD9_DEBOUNCE_S 29
/* SENS_TOUCH_PAD9_BASELINE : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/* SENS_TOUCH_PAD9_BENCHMARK : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/*description: */
#define SENS_TOUCH_PAD9_BASELINE 0x003FFFFF
#define SENS_TOUCH_PAD9_BASELINE_M ((SENS_TOUCH_PAD9_BASELINE_V)<<(SENS_TOUCH_PAD9_BASELINE_S))
#define SENS_TOUCH_PAD9_BASELINE_V 0x3FFFFF
#define SENS_TOUCH_PAD9_BASELINE_S 0
#define SENS_TOUCH_PAD9_BENCHMARK 0x003FFFFF
#define SENS_TOUCH_PAD9_BENCHMARK_M ((SENS_TOUCH_PAD9_BENCHMARK_V)<<(SENS_TOUCH_PAD9_BENCHMARK_S))
#define SENS_TOUCH_PAD9_BENCHMARK_V 0x3FFFFF
#define SENS_TOUCH_PAD9_BENCHMARK_S 0
#define SENS_SAR_TOUCH_STATUS10_REG (DR_REG_SENS_BASE + 0x0100)
/* SENS_TOUCH_PAD10_DEBOUNCE : RO ;bitpos:[31:29] ;default: 3'd0 ; */
@ -1087,12 +1087,12 @@ extern "C" {
#define SENS_TOUCH_PAD10_DEBOUNCE_M ((SENS_TOUCH_PAD10_DEBOUNCE_V)<<(SENS_TOUCH_PAD10_DEBOUNCE_S))
#define SENS_TOUCH_PAD10_DEBOUNCE_V 0x7
#define SENS_TOUCH_PAD10_DEBOUNCE_S 29
/* SENS_TOUCH_PAD10_BASELINE : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/* SENS_TOUCH_PAD10_BENCHMARK : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/*description: */
#define SENS_TOUCH_PAD10_BASELINE 0x003FFFFF
#define SENS_TOUCH_PAD10_BASELINE_M ((SENS_TOUCH_PAD10_BASELINE_V)<<(SENS_TOUCH_PAD10_BASELINE_S))
#define SENS_TOUCH_PAD10_BASELINE_V 0x3FFFFF
#define SENS_TOUCH_PAD10_BASELINE_S 0
#define SENS_TOUCH_PAD10_BENCHMARK 0x003FFFFF
#define SENS_TOUCH_PAD10_BENCHMARK_M ((SENS_TOUCH_PAD10_BENCHMARK_V)<<(SENS_TOUCH_PAD10_BENCHMARK_S))
#define SENS_TOUCH_PAD10_BENCHMARK_V 0x3FFFFF
#define SENS_TOUCH_PAD10_BENCHMARK_S 0
#define SENS_SAR_TOUCH_STATUS11_REG (DR_REG_SENS_BASE + 0x0104)
/* SENS_TOUCH_PAD11_DEBOUNCE : RO ;bitpos:[31:29] ;default: 3'd0 ; */
@ -1101,12 +1101,12 @@ extern "C" {
#define SENS_TOUCH_PAD11_DEBOUNCE_M ((SENS_TOUCH_PAD11_DEBOUNCE_V)<<(SENS_TOUCH_PAD11_DEBOUNCE_S))
#define SENS_TOUCH_PAD11_DEBOUNCE_V 0x7
#define SENS_TOUCH_PAD11_DEBOUNCE_S 29
/* SENS_TOUCH_PAD11_BASELINE : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/* SENS_TOUCH_PAD11_BENCHMARK : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/*description: */
#define SENS_TOUCH_PAD11_BASELINE 0x003FFFFF
#define SENS_TOUCH_PAD11_BASELINE_M ((SENS_TOUCH_PAD11_BASELINE_V)<<(SENS_TOUCH_PAD11_BASELINE_S))
#define SENS_TOUCH_PAD11_BASELINE_V 0x3FFFFF
#define SENS_TOUCH_PAD11_BASELINE_S 0
#define SENS_TOUCH_PAD11_BENCHMARK 0x003FFFFF
#define SENS_TOUCH_PAD11_BENCHMARK_M ((SENS_TOUCH_PAD11_BENCHMARK_V)<<(SENS_TOUCH_PAD11_BENCHMARK_S))
#define SENS_TOUCH_PAD11_BENCHMARK_V 0x3FFFFF
#define SENS_TOUCH_PAD11_BENCHMARK_S 0
#define SENS_SAR_TOUCH_STATUS12_REG (DR_REG_SENS_BASE + 0x0108)
/* SENS_TOUCH_PAD12_DEBOUNCE : RO ;bitpos:[31:29] ;default: 3'd0 ; */
@ -1115,12 +1115,12 @@ extern "C" {
#define SENS_TOUCH_PAD12_DEBOUNCE_M ((SENS_TOUCH_PAD12_DEBOUNCE_V)<<(SENS_TOUCH_PAD12_DEBOUNCE_S))
#define SENS_TOUCH_PAD12_DEBOUNCE_V 0x7
#define SENS_TOUCH_PAD12_DEBOUNCE_S 29
/* SENS_TOUCH_PAD12_BASELINE : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/* SENS_TOUCH_PAD12_BENCHMARK : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/*description: */
#define SENS_TOUCH_PAD12_BASELINE 0x003FFFFF
#define SENS_TOUCH_PAD12_BASELINE_M ((SENS_TOUCH_PAD12_BASELINE_V)<<(SENS_TOUCH_PAD12_BASELINE_S))
#define SENS_TOUCH_PAD12_BASELINE_V 0x3FFFFF
#define SENS_TOUCH_PAD12_BASELINE_S 0
#define SENS_TOUCH_PAD12_BENCHMARK 0x003FFFFF
#define SENS_TOUCH_PAD12_BENCHMARK_M ((SENS_TOUCH_PAD12_BENCHMARK_V)<<(SENS_TOUCH_PAD12_BENCHMARK_S))
#define SENS_TOUCH_PAD12_BENCHMARK_V 0x3FFFFF
#define SENS_TOUCH_PAD12_BENCHMARK_S 0
#define SENS_SAR_TOUCH_STATUS13_REG (DR_REG_SENS_BASE + 0x010c)
/* SENS_TOUCH_PAD13_DEBOUNCE : RO ;bitpos:[31:29] ;default: 3'd0 ; */
@ -1129,12 +1129,12 @@ extern "C" {
#define SENS_TOUCH_PAD13_DEBOUNCE_M ((SENS_TOUCH_PAD13_DEBOUNCE_V)<<(SENS_TOUCH_PAD13_DEBOUNCE_S))
#define SENS_TOUCH_PAD13_DEBOUNCE_V 0x7
#define SENS_TOUCH_PAD13_DEBOUNCE_S 29
/* SENS_TOUCH_PAD13_BASELINE : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/* SENS_TOUCH_PAD13_BENCHMARK : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/*description: */
#define SENS_TOUCH_PAD13_BASELINE 0x003FFFFF
#define SENS_TOUCH_PAD13_BASELINE_M ((SENS_TOUCH_PAD13_BASELINE_V)<<(SENS_TOUCH_PAD13_BASELINE_S))
#define SENS_TOUCH_PAD13_BASELINE_V 0x3FFFFF
#define SENS_TOUCH_PAD13_BASELINE_S 0
#define SENS_TOUCH_PAD13_BENCHMARK 0x003FFFFF
#define SENS_TOUCH_PAD13_BENCHMARK_M ((SENS_TOUCH_PAD13_BENCHMARK_V)<<(SENS_TOUCH_PAD13_BENCHMARK_S))
#define SENS_TOUCH_PAD13_BENCHMARK_V 0x3FFFFF
#define SENS_TOUCH_PAD13_BENCHMARK_S 0
#define SENS_SAR_TOUCH_STATUS14_REG (DR_REG_SENS_BASE + 0x0110)
/* SENS_TOUCH_PAD14_DEBOUNCE : RO ;bitpos:[31:29] ;default: 3'd0 ; */
@ -1143,12 +1143,12 @@ extern "C" {
#define SENS_TOUCH_PAD14_DEBOUNCE_M ((SENS_TOUCH_PAD14_DEBOUNCE_V)<<(SENS_TOUCH_PAD14_DEBOUNCE_S))
#define SENS_TOUCH_PAD14_DEBOUNCE_V 0x7
#define SENS_TOUCH_PAD14_DEBOUNCE_S 29
/* SENS_TOUCH_PAD14_BASELINE : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/* SENS_TOUCH_PAD14_BENCHMARK : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/*description: */
#define SENS_TOUCH_PAD14_BASELINE 0x003FFFFF
#define SENS_TOUCH_PAD14_BASELINE_M ((SENS_TOUCH_PAD14_BASELINE_V)<<(SENS_TOUCH_PAD14_BASELINE_S))
#define SENS_TOUCH_PAD14_BASELINE_V 0x3FFFFF
#define SENS_TOUCH_PAD14_BASELINE_S 0
#define SENS_TOUCH_PAD14_BENCHMARK 0x003FFFFF
#define SENS_TOUCH_PAD14_BENCHMARK_M ((SENS_TOUCH_PAD14_BENCHMARK_V)<<(SENS_TOUCH_PAD14_BENCHMARK_S))
#define SENS_TOUCH_PAD14_BENCHMARK_V 0x3FFFFF
#define SENS_TOUCH_PAD14_BENCHMARK_S 0
#define SENS_SAR_TOUCH_SLP_STATUS_REG (DR_REG_SENS_BASE + 0x0114)
/* SENS_TOUCH_SLP_DEBOUNCE : RO ;bitpos:[31:29] ;default: 3'd0 ; */
@ -1157,12 +1157,12 @@ extern "C" {
#define SENS_TOUCH_SLP_DEBOUNCE_M ((SENS_TOUCH_SLP_DEBOUNCE_V)<<(SENS_TOUCH_SLP_DEBOUNCE_S))
#define SENS_TOUCH_SLP_DEBOUNCE_V 0x7
#define SENS_TOUCH_SLP_DEBOUNCE_S 29
/* SENS_TOUCH_SLP_BASELINE : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/* SENS_TOUCH_SLP_BENCHMARK : RO ;bitpos:[21:0] ;default: 22'h0 ; */
/*description: */
#define SENS_TOUCH_SLP_BASELINE 0x003FFFFF
#define SENS_TOUCH_SLP_BASELINE_M ((SENS_TOUCH_SLP_BASELINE_V)<<(SENS_TOUCH_SLP_BASELINE_S))
#define SENS_TOUCH_SLP_BASELINE_V 0x3FFFFF
#define SENS_TOUCH_SLP_BASELINE_S 0
#define SENS_TOUCH_SLP_BENCHMARK 0x003FFFFF
#define SENS_TOUCH_SLP_BENCHMARK_M ((SENS_TOUCH_SLP_BENCHMARK_V)<<(SENS_TOUCH_SLP_BENCHMARK_S))
#define SENS_TOUCH_SLP_BENCHMARK_V 0x3FFFFF
#define SENS_TOUCH_SLP_BENCHMARK_S 0
#define SENS_SAR_TOUCH_APPR_STATUS_REG (DR_REG_SENS_BASE + 0x0118)
/* SENS_TOUCH_SLP_APPROACH_CNT : RO ;bitpos:[31:24] ;default: 8'd0 ; */

View File

@ -271,7 +271,7 @@ typedef volatile struct {
} sar_touch_status0;
union {
struct {
uint32_t touch_pad_baseline: 22;
uint32_t touch_pad_benchmark: 22;
uint32_t reserved22: 7;
uint32_t touch_pad_debounce: 3;
};
@ -279,7 +279,7 @@ typedef volatile struct {
} sar_touch_status[14];
union {
struct {
uint32_t touch_slp_baseline:22;
uint32_t touch_slp_benchmark:22;
uint32_t reserved22: 7;
uint32_t touch_slp_debounce: 3;
};

View File

@ -41,10 +41,7 @@ void touch_hal_filter_set_config(const touch_filter_config_t *filter_info)
{
touch_ll_filter_set_filter_mode(filter_info->mode);
touch_ll_filter_set_debounce(filter_info->debounce_cnt);
touch_ll_filter_set_hysteresis(filter_info->hysteresis_thr);
touch_ll_filter_set_noise_thres(filter_info->noise_thr);
touch_ll_filter_set_neg_noise_thres(filter_info->noise_neg_thr);
touch_ll_filter_set_baseline_reset(filter_info->neg_noise_limit);
touch_ll_filter_set_jitter_step(filter_info->jitter_step);
}
@ -52,10 +49,7 @@ void touch_hal_filter_get_config(touch_filter_config_t *filter_info)
{
touch_ll_filter_get_filter_mode(&filter_info->mode);
touch_ll_filter_get_debounce(&filter_info->debounce_cnt);
touch_ll_filter_get_hysteresis(&filter_info->hysteresis_thr);
touch_ll_filter_get_noise_thres(&filter_info->noise_thr);
touch_ll_filter_get_neg_noise_thres(&filter_info->noise_neg_thr);
touch_ll_filter_get_baseline_reset(&filter_info->neg_noise_limit);
touch_ll_filter_get_jitter_step(&filter_info->jitter_step);
}

View File

@ -196,10 +196,13 @@ typedef enum {
} touch_pad_shield_driver_t;
typedef struct touch_pad_waterproof {
touch_pad_t guard_ring_pad; /*!<Waterproof. Select touch channel use for guard pad */
touch_pad_shield_driver_t shield_driver;/*!<Waterproof. Select max equivalent capacitance for sheild pad
Config the Touch14 to the touch sensor and compare the measured
reading to the Touch0 reading to estimate the equivalent capacitance.*/
touch_pad_t guard_ring_pad; /*!<Waterproof. Select touch channel use for guard pad.
Guard pad is used to detect the large area of water covering the touch panel. */
touch_pad_shield_driver_t shield_driver;/*!<Waterproof. Shield channel drive capability configuration.
Shield pad is used to shield the influence of water droplets covering the touch panel.
When the waterproof function is enabled, Touch14 is set as shield channel by default.
The larger the parasitic capacitance on the shielding channel, the higher the drive capability needs to be set.
The equivalent capacitance of the shield channel can be estimated through the reading value of the denoise channel(Touch0).*/
} touch_pad_waterproof_t;
typedef struct touch_pad_proximity {
@ -224,32 +227,17 @@ typedef enum {
} touch_filter_mode_t;
typedef struct touch_filter_config {
touch_filter_mode_t mode; /*!<Set filter mode. The input to the filter is raw data and the output is the baseline value.
Larger filter coefficients increase the stability of the baseline. */
touch_filter_mode_t mode; /*!<Set filter mode. The input of the filter is the raw value of touch reading,
and the output of the filter is involved in the judgment of the touch state. */
uint32_t debounce_cnt; /*!<Set debounce count, such as `n`. If the measured values continue to exceed
the threshold for `n` times, it is determined that the touch sensor state changes.
Range: 0 ~ 7 */
uint32_t hysteresis_thr; /*!<Hysteresis threshold coefficient. hysteresis = hysteresis_thr * touch_threshold.
If (raw data - baseline) > (touch threshold + hysteresis), the touch channel be touched.
If (raw data - baseline) < (touch threshold - hysteresis), the touch channel be released.
Range: 0 ~ 3. The coefficient is 0: 1/8; 1: 3/32; 2: 1/16; 3: 1/32 */
uint32_t noise_thr; /*!<Noise threshold coefficient. noise = noise_thr * touch threshold.
If (raw data - baseline) > (noise), the baseline stop updating.
If (raw data - baseline) < (noise), the baseline start updating.
uint32_t noise_thr; /*!<Noise threshold coefficient. Higher = More noise resistance.
The actual noise should be less than (noise coefficient * touch threshold).
Range: 0 ~ 3. The coefficient is 0: 1/2; 1: 3/8; 2: 1/4; 3: 1/8; */
uint32_t noise_neg_thr; /*!<Negative noise threshold coefficient. negative noise = noise_neg_thr * touch threshold.
If (baseline - raw data) > (negative noise), the baseline restart reset process(refer to `baseline_reset`).
If (baseline - raw data) < (negative noise), the baseline stop reset process(refer to `baseline_reset`).
Range: 0 ~ 3. The coefficient is 0: 1/2; 1: 3/8; 2: 1/4; 3: 1/8; */
uint32_t neg_noise_limit; /*!<Set the cumulative number of baseline reset processes. such as `n`. If the measured values continue to exceed
the negative noise threshold for `n` times, the baseline reset to raw data.
Range: 0 ~ 15 */
uint32_t jitter_step; /*!<Set jitter filter step size. Range: 0 ~ 15 */
#define TOUCH_DEBOUNCE_CNT_MAX (7)
#define TOUCH_HYSTERESIS_THR_MAX (3)
#define TOUCH_NOISE_THR_MAX (3)
#define TOUCH_NOISE_NEG_THR_MAX (3)
#define TOUCH_NEG_NOISE_CNT_LIMIT (15)
#define TOUCH_JITTER_STEP_MAX (15)
} touch_filter_config_t;

View File

@ -41,8 +41,8 @@ static const touch_pad_t button[TOUCH_BUTTON_NUM] = {
/*
* Touch threshold. The threshold determines the sensitivity of the touch.
* This threshold is derived by testing changes in readings from different touch channels.
* If (raw_data - baseline) > baseline * threshold, the pad be actived.
* If (raw_data - baseline) < baseline * threshold, the pad be inactived.
* If (raw_data - benchmark) > benchmark * threshold, the pad be actived.
* If (raw_data - benchmark) < benchmark * threshold, the pad be inactived.
*/
static const float button_threshold[TOUCH_BUTTON_NUM] = {
0.2, // 20%.
@ -65,7 +65,7 @@ static void touchsensor_interrupt_cb(void *arg)
evt.pad_num = touch_pad_get_current_meas_channel();
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_DONE) {
touch_pad_filter_read_baseline(evt.pad_num, &evt.pad_val);
touch_pad_filter_read_benchmark(evt.pad_num, &evt.pad_val);
}
xQueueSendFromISR(que_touch, &evt, &task_awoken);
if (task_awoken == pdTRUE) {
@ -77,8 +77,8 @@ static void tp_example_set_thresholds(void)
{
uint32_t touch_value;
for (int i = 0; i < TOUCH_BUTTON_NUM; i++) {
//read baseline value
touch_pad_filter_read_baseline(button[i], &touch_value);
//read benchmark value
touch_pad_filter_read_benchmark(button[i], &touch_value);
//set interrupt threshold.
touch_pad_set_thresh(button[i], touch_value * button_threshold[i]);
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, thresh %d", \
@ -92,15 +92,12 @@ static void touchsensor_filter_set(touch_filter_mode_t mode)
touch_filter_config_t filter_info = {
.mode = mode, // Test jitter and filter 1/4.
.debounce_cnt = 1, // 1 time count.
.hysteresis_thr = 3, // 3%
.noise_thr = 0, // 50%
.noise_neg_thr = 0, // 50%
.neg_noise_limit = 10, // 10 time count.
.jitter_step = 4, // use for jitter mode.
};
touch_pad_filter_set_config(&filter_info);
touch_pad_filter_enable();
touch_pad_filter_reset_baseline(TOUCH_PAD_MAX);
touch_pad_reset_benchmark(TOUCH_PAD_MAX);
ESP_LOGI(TAG, "touch pad filter init");
}

View File

@ -186,15 +186,12 @@ void app_main(void)
touch_filter_config_t filter_info = {
.mode = TOUCH_PAD_FILTER_IIR_8,
.debounce_cnt = 1, // 1 time count.
.hysteresis_thr = 3, // 3%
.noise_thr = 0, // 50%
.noise_neg_thr = 0, // 50%
.neg_noise_limit = 10, // 10 time count.
.jitter_step = 4, // use for jitter mode.
};
touch_pad_filter_set_config(&filter_info);
touch_pad_filter_enable();
touch_pad_filter_reset_baseline(TOUCH_PAD_NUM9);
touch_pad_reset_benchmark(TOUCH_PAD_NUM9);
printf("touch pad filter init %d\n", TOUCH_PAD_FILTER_IIR_8);
/* Set sleep touch pad. */
touch_pad_sleep_channel_t slp_config = {
@ -209,7 +206,7 @@ void app_main(void)
vTaskDelay(100 / portTICK_RATE_MS);
/* read sleep touch pad value */
uint32_t touch_value;
touch_pad_sleep_channel_read_baseline(&touch_value);
touch_pad_sleep_channel_read_benchmark(&touch_value);
slp_config.sleep_pad_threshold = touch_value * 0.1;
touch_pad_sleep_channel_config(&slp_config); //10%
printf("test init: touch pad [%d] slp %d, thresh %d\n",