kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'bugfix/fix_touch_sensor_api' into 'master'
driver(touch): fix touch sensor driver redundancy Closes IDF-1850 See merge request espressif/esp-idf!9273pull/5688/head
commit
395a51b441
|
@ -22,7 +22,7 @@ extern "C" {
|
||||||
/**
|
/**
|
||||||
* @brief Set touch sensor FSM start
|
* @brief Set touch sensor FSM start
|
||||||
* @note Start FSM after the touch sensor FSM mode is set.
|
* @note Start FSM after the touch sensor FSM mode is set.
|
||||||
* @note Call this function will reset baseline of all touch channels.
|
* @note Call this function will reset benchmark of all touch channels.
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK on success
|
* - ESP_OK on success
|
||||||
*/
|
*/
|
||||||
|
@ -98,7 +98,7 @@ esp_err_t touch_pad_get_idle_channel_connect(touch_pad_conn_type_t *type);
|
||||||
/**
|
/**
|
||||||
* @brief Set the trigger threshold of touch sensor.
|
* @brief Set the trigger threshold of touch sensor.
|
||||||
* The threshold determines the sensitivity of the 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 triggered.
|
* @note If set "TOUCH_PAD_THRESHOLD_MAX", the touch is never be triggered.
|
||||||
* @param touch_num touch pad index
|
* @param touch_num touch pad index
|
||||||
* @param threshold threshold of touch sensor. Should be less than the max change value of touch.
|
* @param threshold threshold of touch sensor. Should be less than the max change value of touch.
|
||||||
|
@ -264,15 +264,15 @@ esp_err_t touch_pad_timeout_resume(void);
|
||||||
esp_err_t touch_pad_read_raw_data(touch_pad_t touch_num, uint32_t *raw_data);
|
esp_err_t touch_pad_read_raw_data(touch_pad_t touch_num, uint32_t *raw_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get baseline of touch sensor.
|
* @brief get benchmark 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_num touch pad index
|
||||||
* @param basedata pointer to accept touch sensor baseline value
|
* @param benchmark pointer to accept touch sensor benchmark value
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK Success
|
* - ESP_OK Success
|
||||||
* - ESP_ERR_INVALID_ARG Touch channel 0 haven't this parameter.
|
* - ESP_ERR_INVALID_ARG Touch channel 0 haven't this parameter.
|
||||||
*/
|
*/
|
||||||
esp_err_t touch_pad_filter_read_baseline(touch_pad_t touch_num, uint32_t *basedata);
|
esp_err_t touch_pad_read_benchmark(touch_pad_t touch_num, uint32_t *benchmark);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get smoothed data that obtained by filtering the raw data.
|
* @brief Get smoothed data that obtained by filtering the raw data.
|
||||||
|
@ -283,13 +283,13 @@ esp_err_t touch_pad_filter_read_baseline(touch_pad_t touch_num, uint32_t *baseda
|
||||||
esp_err_t touch_pad_filter_read_smooth(touch_pad_t touch_num, uint32_t *smooth);
|
esp_err_t touch_pad_filter_read_smooth(touch_pad_t touch_num, uint32_t *smooth);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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
|
* @param touch_num touch pad index
|
||||||
* - TOUCH_PAD_MAX Reset basaline of all channels
|
* - TOUCH_PAD_MAX Reset basaline of all channels
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK Success
|
* - 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.
|
* @brief set parameter of touch sensor filter and detection algorithm.
|
||||||
|
@ -375,11 +375,12 @@ esp_err_t touch_pad_denoise_read_data(uint32_t *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief set parameter of waterproof function.
|
* @brief set parameter of waterproof function.
|
||||||
|
*
|
||||||
* The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel.
|
* 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.
|
* 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
|
* @param waterproof parameter of waterproof
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK Success
|
* - ESP_OK Success
|
||||||
|
@ -396,23 +397,14 @@ esp_err_t touch_pad_waterproof_get_config(touch_pad_waterproof_t *waterproof);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enable parameter of waterproof function.
|
* @brief Enable parameter of waterproof function.
|
||||||
* The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel.
|
* Should be called after function ``touch_pad_waterproof_set_config``.
|
||||||
* 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.
|
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK Success
|
* - ESP_OK Success
|
||||||
*/
|
*/
|
||||||
esp_err_t touch_pad_waterproof_enable(void);
|
esp_err_t touch_pad_waterproof_enable(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enable parameter of waterproof function.
|
* @brief Disable 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.
|
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK Success
|
* - ESP_OK Success
|
||||||
*/
|
*/
|
||||||
|
@ -537,14 +529,14 @@ esp_err_t touch_pad_sleep_set_threshold(touch_pad_t pad_num, uint32_t touch_thre
|
||||||
esp_err_t touch_pad_sleep_get_threshold(touch_pad_t pad_num, uint32_t *touch_thres);
|
esp_err_t touch_pad_sleep_get_threshold(touch_pad_t pad_num, uint32_t *touch_thres);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read baseline of touch sensor sleep channel.
|
* @brief Read benchmark of touch sensor sleep channel.
|
||||||
* @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode.
|
* @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode.
|
||||||
* @param baseline pointer to accept touch sensor baseline value
|
* @param benchmark pointer to accept touch sensor benchmark value
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK Success
|
* - ESP_OK Success
|
||||||
* - ESP_ERR_INVALID_ARG parameter is NULL
|
* - ESP_ERR_INVALID_ARG parameter is NULL
|
||||||
*/
|
*/
|
||||||
esp_err_t touch_pad_sleep_channel_read_baseline(touch_pad_t pad_num, uint32_t *baseline);
|
esp_err_t touch_pad_sleep_channel_read_benchmark(touch_pad_t pad_num, uint32_t *benchmark);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read smoothed data of touch sensor sleep channel.
|
* @brief Read smoothed data of touch sensor sleep channel.
|
||||||
|
@ -568,12 +560,12 @@ esp_err_t touch_pad_sleep_channel_read_smooth(touch_pad_t pad_num, uint32_t *smo
|
||||||
esp_err_t touch_pad_sleep_channel_read_data(touch_pad_t pad_num, uint32_t *raw_data);
|
esp_err_t touch_pad_sleep_channel_read_data(touch_pad_t pad_num, uint32_t *raw_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reset baseline of touch sensor sleep channel.
|
* @brief Reset benchmark of touch sensor sleep channel.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK Success
|
* - ESP_OK Success
|
||||||
*/
|
*/
|
||||||
esp_err_t touch_pad_sleep_channel_reset_baseline(void);
|
esp_err_t touch_pad_sleep_channel_reset_benchmark(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read proximity count of touch sensor sleep channel.
|
* @brief Read proximity count of touch sensor sleep channel.
|
||||||
|
|
|
@ -322,21 +322,21 @@ esp_err_t IRAM_ATTR touch_pad_filter_read_smooth(touch_pad_t touch_num, uint32_t
|
||||||
return ESP_OK;
|
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_read_benchmark(touch_pad_t touch_num, uint32_t *benchmark)
|
||||||
{
|
{
|
||||||
TOUCH_CHANNEL_CHECK(touch_num);
|
TOUCH_CHANNEL_CHECK(touch_num);
|
||||||
TOUCH_ENTER_CRITICAL_SAFE();
|
TOUCH_ENTER_CRITICAL_SAFE();
|
||||||
touch_hal_filter_read_baseline(touch_num, basedata);
|
touch_hal_read_benchmark(touch_num, benchmark);
|
||||||
TOUCH_EXIT_CRITICAL_SAFE();
|
TOUCH_EXIT_CRITICAL_SAFE();
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Should be call after clk enable and filter enable. */
|
/* 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_CHECK(touch_num <= TOUCH_PAD_MAX && touch_num >= 0, "Touch channel error", ESP_ERR_INVALID_ARG);
|
||||||
TOUCH_ENTER_CRITICAL();
|
TOUCH_ENTER_CRITICAL();
|
||||||
touch_hal_filter_reset_baseline(touch_num);
|
touch_hal_reset_benchmark(touch_num);
|
||||||
TOUCH_EXIT_CRITICAL();
|
TOUCH_EXIT_CRITICAL();
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
@ -345,10 +345,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->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->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_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_CHECK(filter_info->jitter_step <= TOUCH_JITTER_STEP_MAX, TOUCH_PARAM_CHECK_STR("jitter_step"), ESP_ERR_INVALID_ARG);
|
||||||
TOUCH_CHECK(filter_info->smh_lvl < TOUCH_PAD_SMOOTH_MAX, TOUCH_PARAM_CHECK_STR("smooth level"), ESP_ERR_INVALID_ARG);
|
TOUCH_CHECK(filter_info->smh_lvl < TOUCH_PAD_SMOOTH_MAX, TOUCH_PARAM_CHECK_STR("smooth level"), ESP_ERR_INVALID_ARG);
|
||||||
|
|
||||||
|
@ -522,7 +519,7 @@ esp_err_t touch_pad_proximity_get_data(touch_pad_t touch_num, uint32_t *measure_
|
||||||
{
|
{
|
||||||
TOUCH_CHECK(touch_hal_proximity_pad_check(touch_num), "touch num is not proximity", ESP_ERR_INVALID_ARG);
|
TOUCH_CHECK(touch_hal_proximity_pad_check(touch_num), "touch num is not proximity", ESP_ERR_INVALID_ARG);
|
||||||
TOUCH_ENTER_CRITICAL_SAFE();
|
TOUCH_ENTER_CRITICAL_SAFE();
|
||||||
touch_hal_filter_read_baseline(touch_num, measure_out);
|
touch_hal_read_benchmark(touch_num, measure_out);
|
||||||
TOUCH_EXIT_CRITICAL_SAFE();
|
TOUCH_EXIT_CRITICAL_SAFE();
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
@ -585,10 +582,10 @@ esp_err_t touch_pad_sleep_get_threshold(touch_pad_t pad_num, uint32_t *touch_thr
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t touch_pad_sleep_channel_read_baseline(touch_pad_t pad_num, uint32_t *baseline)
|
esp_err_t touch_pad_sleep_channel_read_benchmark(touch_pad_t pad_num, uint32_t *benchmark)
|
||||||
{
|
{
|
||||||
TOUCH_ENTER_CRITICAL_SAFE();
|
TOUCH_ENTER_CRITICAL_SAFE();
|
||||||
touch_hal_sleep_read_baseline(baseline);
|
touch_hal_sleep_read_benchmark(benchmark);
|
||||||
TOUCH_EXIT_CRITICAL_SAFE();
|
TOUCH_EXIT_CRITICAL_SAFE();
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
@ -609,10 +606,10 @@ esp_err_t touch_pad_sleep_channel_read_data(touch_pad_t pad_num, uint32_t *raw_d
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t touch_pad_sleep_channel_reset_baseline(void)
|
esp_err_t touch_pad_sleep_channel_reset_benchmark(void)
|
||||||
{
|
{
|
||||||
TOUCH_ENTER_CRITICAL();
|
TOUCH_ENTER_CRITICAL();
|
||||||
touch_hal_sleep_reset_baseline();
|
touch_hal_sleep_reset_benchmark();
|
||||||
TOUCH_EXIT_CRITICAL();
|
TOUCH_EXIT_CRITICAL();
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,12 +125,12 @@ static void printf_touch_hw_read(const char *str)
|
||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printf_touch_baseline_read(const char *str)
|
static void printf_touch_benchmark_read(const char *str)
|
||||||
{
|
{
|
||||||
uint32_t touch_value;
|
uint32_t touch_value;
|
||||||
printf("[%s] ", str);
|
printf("[%s] ", str);
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
printf("[%d]%d ", touch_list[i], touch_value);
|
printf("[%d]%d ", touch_list[i], touch_value);
|
||||||
}
|
}
|
||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
|
@ -190,19 +190,18 @@ static void test_touch_release_all(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test: if the raw data exceed noise threshold, the baseline should not be updated. */
|
static void test_touch_benchmark(void)
|
||||||
static void test_touch_baseline_not_update(void)
|
|
||||||
{
|
{
|
||||||
uint32_t touch_val[TEST_TOUCH_CHANNEL] = {0};
|
uint32_t touch_val[TEST_TOUCH_CHANNEL] = {0};
|
||||||
uint32_t touch_temp[TEST_TOUCH_CHANNEL] = {0};
|
uint32_t touch_temp[TEST_TOUCH_CHANNEL] = {0};
|
||||||
|
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_val[i]) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_val[i]) );
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
vTaskDelay(20 / portTICK_PERIOD_MS);
|
vTaskDelay(20 / portTICK_PERIOD_MS);
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_temp[i]) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_temp[i]) );
|
||||||
TEST_ASSERT_EQUAL(touch_temp[i], touch_val[i]);
|
TEST_ASSERT_EQUAL(touch_temp[i], touch_val[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -356,10 +355,7 @@ esp_err_t test_touch_filtered_read(void)
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_IIR_32, // Test jitter and filter 1/4.
|
.mode = TOUCH_PAD_FILTER_IIR_32, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 3, // 0%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
||||||
};
|
};
|
||||||
|
@ -371,10 +367,10 @@ esp_err_t test_touch_filtered_read(void)
|
||||||
/* Wait touch pad init done. */
|
/* Wait touch pad init done. */
|
||||||
vTaskDelay(50 * SYS_DELAY_TIME_MOM / portTICK_PERIOD_MS);
|
vTaskDelay(50 * SYS_DELAY_TIME_MOM / portTICK_PERIOD_MS);
|
||||||
/* Test the stable for init value of touch reading.
|
/* Test the stable for init value of touch reading.
|
||||||
* Ideal: baseline == raw data == smooth data.
|
* Ideal: benchmark == raw data == smooth data.
|
||||||
*/
|
*/
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value[i]) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value[i]) );
|
||||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value[i]);
|
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value[i]);
|
||||||
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_temp[i]) );
|
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_temp[i]) );
|
||||||
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_temp[i]);
|
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_temp[i]);
|
||||||
|
@ -385,7 +381,7 @@ esp_err_t test_touch_filtered_read(void)
|
||||||
}
|
}
|
||||||
printf("touch filter init value:\n");
|
printf("touch filter init value:\n");
|
||||||
printf_touch_hw_read("raw ");
|
printf_touch_hw_read("raw ");
|
||||||
printf_touch_baseline_read("base ");
|
printf_touch_benchmark_read("base ");
|
||||||
printf_touch_smooth_read("smooth");
|
printf_touch_smooth_read("smooth");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
@ -394,7 +390,7 @@ esp_err_t test_touch_filtered_read(void)
|
||||||
/* Touch reading filtered value equal to raw data. */
|
/* Touch reading filtered value equal to raw data. */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_value[i]) );
|
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_value[i]) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_temp[i]) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_temp[i]) );
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp[i], touch_value[i]);
|
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp[i], touch_value[i]);
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &touch_temp[i]) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &touch_temp[i]) );
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp[i], touch_value[i]);
|
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp[i], touch_value[i]);
|
||||||
|
@ -453,10 +449,7 @@ int test_touch_base_parameter(touch_pad_t pad_num, int meas_time, int slp_time,
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_IIR_32, // Test jitter and filter 1/4.
|
.mode = TOUCH_PAD_FILTER_IIR_32, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 3, // 0%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
||||||
};
|
};
|
||||||
|
@ -469,9 +462,9 @@ int test_touch_base_parameter(touch_pad_t pad_num, int meas_time, int slp_time,
|
||||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
while (test_cnt--) {
|
while (test_cnt--) {
|
||||||
/* Correctness of reading. Ideal: baseline == raw data == smooth data. */
|
/* Correctness of reading. Ideal: benchmark == raw data == smooth data. */
|
||||||
TEST_ESP_OK( touch_pad_read_raw_data(pad_num, &touch_value) );
|
TEST_ESP_OK( touch_pad_read_raw_data(pad_num, &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(pad_num, &touch_filter) );
|
TEST_ESP_OK( touch_pad_read_benchmark(pad_num, &touch_filter) );
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_filter, touch_value);
|
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_filter, touch_value);
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(pad_num, &touch_filter) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(pad_num, &touch_filter) );
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_filter, touch_value);
|
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_filter, touch_value);
|
||||||
|
@ -779,10 +772,10 @@ static void test_touch_intr_cb(void *arg)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_SCAN_DONE) {
|
if (evt.intr_mask & TOUCH_PAD_INTR_MASK_SCAN_DONE) {
|
||||||
touch_pad_filter_read_baseline(evt.pad_num, &evt.pad_val);
|
touch_pad_read_benchmark(evt.pad_num, &evt.pad_val);
|
||||||
touch_pad_sleep_channel_t slp_config;
|
touch_pad_sleep_channel_t slp_config;
|
||||||
touch_pad_sleep_channel_get_info(&slp_config);
|
touch_pad_sleep_channel_get_info(&slp_config);
|
||||||
touch_pad_sleep_channel_read_baseline(slp_config.touch_num, &touch_value);
|
touch_pad_sleep_channel_read_benchmark(slp_config.touch_num, &touch_value);
|
||||||
touch_pad_sleep_channel_read_proximity_cnt(slp_config.touch_num, &cnt);
|
touch_pad_sleep_channel_read_proximity_cnt(slp_config.touch_num, &cnt);
|
||||||
evt.slp_proxi_cnt = cnt;
|
evt.slp_proxi_cnt = cnt;
|
||||||
evt.slp_proxi_base = touch_value;
|
evt.slp_proxi_base = touch_value;
|
||||||
|
@ -804,7 +797,7 @@ static void test_touch_intr_cb(void *arg)
|
||||||
* TEST POINT:
|
* TEST POINT:
|
||||||
* 1. Touch interrupt.
|
* 1. Touch interrupt.
|
||||||
* 2. Raw data noise.
|
* 2. Raw data noise.
|
||||||
* 3. smooth data and baseline data.
|
* 3. smooth data and benchmark data.
|
||||||
*/
|
*/
|
||||||
esp_err_t test_touch_interrupt(void)
|
esp_err_t test_touch_interrupt(void)
|
||||||
{
|
{
|
||||||
|
@ -826,10 +819,7 @@ esp_err_t test_touch_interrupt(void)
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 3, // 0%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
||||||
};
|
};
|
||||||
|
@ -845,7 +835,7 @@ esp_err_t test_touch_interrupt(void)
|
||||||
|
|
||||||
/* Set threshold of touch sensor */
|
/* Set threshold of touch sensor */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d",
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d",
|
||||||
|
@ -857,8 +847,7 @@ esp_err_t test_touch_interrupt(void)
|
||||||
TEST_ESP_OK( test_touch_check_ch_touched(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
TEST_ESP_OK( test_touch_check_ch_touched(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
||||||
printf_touch_hw_read("push");
|
printf_touch_hw_read("push");
|
||||||
|
|
||||||
/* Test: if the raw data exceed noise threshold, the baseline should not be updated. */
|
test_touch_benchmark();
|
||||||
test_touch_baseline_not_update();
|
|
||||||
|
|
||||||
test_touch_release_all();
|
test_touch_release_all();
|
||||||
TEST_ESP_OK( test_touch_check_ch_released(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
TEST_ESP_OK( test_touch_check_ch_released(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
||||||
|
@ -875,7 +864,7 @@ esp_err_t test_touch_interrupt(void)
|
||||||
* TEST POINT:
|
* TEST POINT:
|
||||||
* 1. Touch interrupt.
|
* 1. Touch interrupt.
|
||||||
* 2. Raw data noise.
|
* 2. Raw data noise.
|
||||||
* 3. smooth data and baseline data.
|
* 3. smooth data and benchmark data.
|
||||||
*/
|
*/
|
||||||
esp_err_t test_touch_scan_done_interrupt(void)
|
esp_err_t test_touch_scan_done_interrupt(void)
|
||||||
{
|
{
|
||||||
|
@ -897,10 +886,7 @@ esp_err_t test_touch_scan_done_interrupt(void)
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 3, // 0%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
||||||
};
|
};
|
||||||
|
@ -917,7 +903,7 @@ esp_err_t test_touch_scan_done_interrupt(void)
|
||||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d", \
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d", \
|
||||||
|
@ -929,8 +915,7 @@ esp_err_t test_touch_scan_done_interrupt(void)
|
||||||
TEST_ESP_OK( test_touch_check_ch_touched(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
TEST_ESP_OK( test_touch_check_ch_touched(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
||||||
printf_touch_hw_read("push");
|
printf_touch_hw_read("push");
|
||||||
|
|
||||||
/* Test: if the raw data exceed noise threshold, the baseline should not be updated. */
|
test_touch_benchmark();
|
||||||
test_touch_baseline_not_update();
|
|
||||||
|
|
||||||
test_touch_release_all();
|
test_touch_release_all();
|
||||||
TEST_ESP_OK( test_touch_check_ch_released(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
TEST_ESP_OK( test_touch_check_ch_released(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
||||||
|
@ -947,7 +932,7 @@ esp_err_t test_touch_scan_done_interrupt(void)
|
||||||
* TEST POINT:
|
* TEST POINT:
|
||||||
* 1. Touch interrupt.
|
* 1. Touch interrupt.
|
||||||
* 2. Raw data noise.
|
* 2. Raw data noise.
|
||||||
* 3. smooth data and baseline data.
|
* 3. smooth data and benchmark data.
|
||||||
*/
|
*/
|
||||||
esp_err_t test_touch_timeout_interrupt(void)
|
esp_err_t test_touch_timeout_interrupt(void)
|
||||||
{
|
{
|
||||||
|
@ -968,10 +953,7 @@ esp_err_t test_touch_timeout_interrupt(void)
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 3, // 0%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
||||||
};
|
};
|
||||||
|
@ -986,14 +968,14 @@ esp_err_t test_touch_timeout_interrupt(void)
|
||||||
vTaskDelay(50 * SYS_DELAY_TIME_MOM / portTICK_PERIOD_MS);
|
vTaskDelay(50 * SYS_DELAY_TIME_MOM / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d",
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d",
|
||||||
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
touch_list[i], touch_value, smooth, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
||||||
}
|
}
|
||||||
/* Set timeout parameter */
|
/* Set timeout parameter */
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[0], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[0], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_timeout_set(true , touch_value * 10) );
|
TEST_ESP_OK( touch_pad_timeout_set(true , touch_value * 10) );
|
||||||
|
|
||||||
// Only fake push one touch pad.
|
// Only fake push one touch pad.
|
||||||
|
@ -1004,7 +986,7 @@ esp_err_t test_touch_timeout_interrupt(void)
|
||||||
|
|
||||||
vTaskDelay(50 * SYS_DELAY_TIME_MOM / portTICK_PERIOD_MS);
|
vTaskDelay(50 * SYS_DELAY_TIME_MOM / portTICK_PERIOD_MS);
|
||||||
printf_touch_hw_read("raw ");
|
printf_touch_hw_read("raw ");
|
||||||
printf_touch_baseline_read("base ");
|
printf_touch_benchmark_read("base ");
|
||||||
printf_touch_smooth_read("smooth");
|
printf_touch_smooth_read("smooth");
|
||||||
|
|
||||||
int test_cnt = TEST_TOUCH_COUNT_NUM;
|
int test_cnt = TEST_TOUCH_COUNT_NUM;
|
||||||
|
@ -1013,8 +995,7 @@ esp_err_t test_touch_timeout_interrupt(void)
|
||||||
TEST_ESP_OK( test_touch_check_ch_touched(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
TEST_ESP_OK( test_touch_check_ch_touched(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
||||||
printf_touch_hw_read("push");
|
printf_touch_hw_read("push");
|
||||||
|
|
||||||
/* Test: if the raw data exceed noise threshold, the baseline should not be updated. */
|
test_touch_benchmark();
|
||||||
test_touch_baseline_not_update();
|
|
||||||
|
|
||||||
test_touch_release_all();
|
test_touch_release_all();
|
||||||
TEST_ESP_OK( test_touch_check_ch_released(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
TEST_ESP_OK( test_touch_check_ch_released(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
||||||
|
@ -1052,7 +1033,7 @@ static void test_touch_measure_step(uint32_t step)
|
||||||
* TEST POINT:
|
* TEST POINT:
|
||||||
* 1. Touch interrupt.
|
* 1. Touch interrupt.
|
||||||
* 2. Raw data noise.
|
* 2. Raw data noise.
|
||||||
* 3. smooth data and baseline data.
|
* 3. smooth data and benchmark data.
|
||||||
*/
|
*/
|
||||||
esp_err_t test_touch_filter_parameter_debounce(int deb_cnt)
|
esp_err_t test_touch_filter_parameter_debounce(int deb_cnt)
|
||||||
{
|
{
|
||||||
|
@ -1074,10 +1055,7 @@ esp_err_t test_touch_filter_parameter_debounce(int deb_cnt)
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_IIR_128, // Test jitter and filter 1/4.
|
.mode = TOUCH_PAD_FILTER_IIR_128, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = ((deb_cnt < 0) ? 1 : deb_cnt) , // 1 time count.
|
.debounce_cnt = ((deb_cnt < 0) ? 1 : deb_cnt) , // 1 time count.
|
||||||
.hysteresis_thr = 3, // 0%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
.smh_lvl = TOUCH_PAD_SMOOTH_OFF,
|
.smh_lvl = TOUCH_PAD_SMOOTH_OFF,
|
||||||
};
|
};
|
||||||
|
@ -1093,7 +1071,7 @@ esp_err_t test_touch_filter_parameter_debounce(int deb_cnt)
|
||||||
|
|
||||||
/* Set the threshold. */
|
/* Set the threshold. */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, thresh %d", \
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, thresh %d", \
|
||||||
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
||||||
|
@ -1122,7 +1100,7 @@ esp_err_t test_touch_filter_parameter_debounce(int deb_cnt)
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t test_touch_filter_parameter_neg_reset(int reset_cnt)
|
esp_err_t test_touch_filter_parameter_reset(int reset_cnt)
|
||||||
{
|
{
|
||||||
uint32_t touch_value, base_value;
|
uint32_t touch_value, base_value;
|
||||||
|
|
||||||
|
@ -1142,10 +1120,7 @@ esp_err_t test_touch_filter_parameter_neg_reset(int reset_cnt)
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 3, // 0%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = reset_cnt, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
.smh_lvl = TOUCH_PAD_SMOOTH_OFF,
|
.smh_lvl = TOUCH_PAD_SMOOTH_OFF,
|
||||||
};
|
};
|
||||||
|
@ -1161,7 +1136,7 @@ esp_err_t test_touch_filter_parameter_neg_reset(int reset_cnt)
|
||||||
|
|
||||||
/* Set the threshold. */
|
/* Set the threshold. */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, thresh %d", \
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, thresh %d", \
|
||||||
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
||||||
|
@ -1169,36 +1144,36 @@ esp_err_t test_touch_filter_parameter_neg_reset(int reset_cnt)
|
||||||
|
|
||||||
/* 1. Fake init status is touched. */
|
/* 1. Fake init status is touched. */
|
||||||
test_touch_push_all();
|
test_touch_push_all();
|
||||||
TEST_ESP_OK( touch_pad_filter_reset_baseline(TOUCH_PAD_MAX) );
|
TEST_ESP_OK( touch_pad_reset_benchmark(TOUCH_PAD_MAX) );
|
||||||
/* Run to wait the data become stable. */
|
/* Run to wait the data become stable. */
|
||||||
test_touch_measure_step(20); // 2 scan loop
|
test_touch_measure_step(20); // 2 scan loop
|
||||||
printf_touch_hw_read("[raw ] reset:");
|
printf_touch_hw_read("[raw ] reset:");
|
||||||
printf_touch_baseline_read("[base] reset:");
|
printf_touch_benchmark_read("[base] reset:");
|
||||||
|
|
||||||
/* 2. Fake the touch status is released. */
|
/* 2. Fake the touch status is released. */
|
||||||
test_touch_release_all();
|
test_touch_release_all();
|
||||||
/* 3. Fake measure `reset_cnt + 1` times to reset the baseline. */
|
/* 3. Fake measure `reset_cnt + 1` times to reset the benchmark. */
|
||||||
test_touch_measure_step(reset_cnt);
|
test_touch_measure_step(reset_cnt);
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &base_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &base_value) );
|
||||||
if ((base_value - touch_value) < (base_value * TOUCH_INTR_THRESHOLD)) {
|
if ((base_value - touch_value) < (base_value * TOUCH_INTR_THRESHOLD)) {
|
||||||
ESP_LOGE(TAG, "neg reset cnt err");
|
ESP_LOGE(TAG, "reset cnt err");
|
||||||
TEST_FAIL();
|
TEST_FAIL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf_touch_hw_read("[raw ] neg_cnt:");
|
printf_touch_hw_read("[raw ] cnt:");
|
||||||
printf_touch_baseline_read("[base] neg_cnt:");
|
printf_touch_benchmark_read("[base] cnt:");
|
||||||
|
|
||||||
test_touch_measure_step(1);
|
test_touch_measure_step(1);
|
||||||
/* ESP32S2 neg reset baseline to raw data */
|
/* ESP32S2 reset benchmark to raw data */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &base_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &base_value) );
|
||||||
TEST_ASSERT_EQUAL_UINT32(base_value, touch_value);
|
TEST_ASSERT_EQUAL_UINT32(base_value, touch_value);
|
||||||
}
|
}
|
||||||
printf_touch_hw_read("[raw ] neg_cnt+1:");
|
printf_touch_hw_read("[raw ] cnt+1:");
|
||||||
printf_touch_baseline_read("[base] neg_cnt+1:");
|
printf_touch_benchmark_read("[base] cnt+1:");
|
||||||
|
|
||||||
int test_cnt = 2;
|
int test_cnt = 2;
|
||||||
while (test_cnt--) {
|
while (test_cnt--) {
|
||||||
|
@ -1240,10 +1215,7 @@ esp_err_t test_touch_filter_parameter_jitter(int jitter_step)
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_JITTER, // Test jitter and filter 1/4.
|
.mode = TOUCH_PAD_FILTER_JITTER, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 3, // 0%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = jitter_step, // use for jitter mode.
|
.jitter_step = jitter_step, // use for jitter mode.
|
||||||
};
|
};
|
||||||
TEST_ESP_OK( touch_pad_filter_set_config(&filter_info) );
|
TEST_ESP_OK( touch_pad_filter_set_config(&filter_info) );
|
||||||
|
@ -1256,30 +1228,30 @@ esp_err_t test_touch_filter_parameter_jitter(int jitter_step)
|
||||||
test_touch_measure_step(20); // 2 scan loop
|
test_touch_measure_step(20); // 2 scan loop
|
||||||
|
|
||||||
/* Check the jitter step. */
|
/* Check the jitter step. */
|
||||||
printf_touch_baseline_read("[smooth] t1:");
|
printf_touch_benchmark_read("[smooth] t1:");
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
test_touch_measure_step(1);
|
test_touch_measure_step(1);
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
test_press_fake(touch_list[i]);
|
test_press_fake(touch_list[i]);
|
||||||
test_touch_measure_step(1);
|
test_touch_measure_step(1);
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &base_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &base_value) );
|
||||||
TEST_ASSERT_EQUAL_UINT32(jitter_step, (base_value - touch_value));
|
TEST_ASSERT_EQUAL_UINT32(jitter_step, (base_value - touch_value));
|
||||||
}
|
}
|
||||||
printf_touch_baseline_read("[smooth] t2:");
|
printf_touch_benchmark_read("[smooth] t2:");
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
test_touch_measure_step(1);
|
test_touch_measure_step(1);
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
test_release_fake(touch_list[i]);
|
test_release_fake(touch_list[i]);
|
||||||
test_touch_measure_step(1);
|
test_touch_measure_step(1);
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &base_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &base_value) );
|
||||||
TEST_ASSERT_EQUAL_UINT32(jitter_step, (touch_value - base_value));
|
TEST_ASSERT_EQUAL_UINT32(jitter_step, (touch_value - base_value));
|
||||||
}
|
}
|
||||||
printf_touch_baseline_read("[smooth] t3:");
|
printf_touch_benchmark_read("[smooth] t3:");
|
||||||
|
|
||||||
/* Set the threshold. */
|
/* Set the threshold. */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
//read baseline value
|
//read benchmark value
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
//set interrupt threshold.
|
//set interrupt threshold.
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, thresh %d", \
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, thresh %d", \
|
||||||
|
@ -1306,17 +1278,15 @@ esp_err_t test_touch_filter_parameter_jitter(int jitter_step)
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Touch Sensor filter paramter test (debounce, neg_reset, jitter)", "[touch]")
|
TEST_CASE("Touch Sensor filter paramter test (debounce, reset, jitter)", "[touch]")
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "*********** touch filter debounce test ********************");
|
ESP_LOGI(TAG, "*********** touch filter debounce test ********************");
|
||||||
TEST_ESP_OK( test_touch_filter_parameter_debounce(0) );
|
TEST_ESP_OK( test_touch_filter_parameter_debounce(0) );
|
||||||
TEST_ESP_OK( test_touch_filter_parameter_debounce(3) );
|
TEST_ESP_OK( test_touch_filter_parameter_debounce(3) );
|
||||||
TEST_ESP_OK( test_touch_filter_parameter_debounce(7) );
|
TEST_ESP_OK( test_touch_filter_parameter_debounce(7) );
|
||||||
|
|
||||||
ESP_LOGI(TAG, "*********** touch filter neg threshold reset limit test ********************");
|
ESP_LOGI(TAG, "*********** touch filter benchmark reset ********************");
|
||||||
TEST_ESP_OK( test_touch_filter_parameter_neg_reset(1) );
|
TEST_ESP_OK( test_touch_filter_parameter_reset(0xF) );
|
||||||
TEST_ESP_OK( test_touch_filter_parameter_neg_reset(5) );
|
|
||||||
TEST_ESP_OK( test_touch_filter_parameter_neg_reset(15) );
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "*********** touch filter jitter test ********************");
|
ESP_LOGI(TAG, "*********** touch filter jitter test ********************");
|
||||||
TEST_ESP_OK( test_touch_filter_parameter_jitter(1) );
|
TEST_ESP_OK( test_touch_filter_parameter_jitter(1) );
|
||||||
|
@ -1353,10 +1323,7 @@ esp_err_t test_touch_denoise(uint32_t out_val[], uint32_t *denoise_val, touch_pa
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 3, // 0%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
};
|
};
|
||||||
TEST_ESP_OK( touch_pad_filter_set_config(&filter_info) );
|
TEST_ESP_OK( touch_pad_filter_set_config(&filter_info) );
|
||||||
|
@ -1370,14 +1337,14 @@ esp_err_t test_touch_denoise(uint32_t out_val[], uint32_t *denoise_val, touch_pa
|
||||||
|
|
||||||
/* Set the threshold. */
|
/* Set the threshold. */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
if (out_val) {
|
if (out_val) {
|
||||||
/* Output value for check. */
|
/* Output value for check. */
|
||||||
out_val[i] = touch_value;
|
out_val[i] = touch_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf_touch_baseline_read("Denoise");
|
printf_touch_benchmark_read("Denoise");
|
||||||
if (denoise_val) {
|
if (denoise_val) {
|
||||||
touch_pad_denoise_read_data(denoise_val);
|
touch_pad_denoise_read_data(denoise_val);
|
||||||
}
|
}
|
||||||
|
@ -1470,10 +1437,7 @@ esp_err_t test_touch_waterproof(void)
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 3, // 0%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
};
|
};
|
||||||
TEST_ESP_OK( touch_pad_filter_set_config(&filter_info) );
|
TEST_ESP_OK( touch_pad_filter_set_config(&filter_info) );
|
||||||
|
@ -1496,7 +1460,7 @@ esp_err_t test_touch_waterproof(void)
|
||||||
|
|
||||||
/* Set the threshold. */
|
/* Set the threshold. */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1550,10 +1514,7 @@ esp_err_t test_touch_proximity(int meas_num)
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 3, // 0%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
};
|
};
|
||||||
TEST_ESP_OK( touch_pad_filter_set_config(&filter_info) );
|
TEST_ESP_OK( touch_pad_filter_set_config(&filter_info) );
|
||||||
|
@ -1576,7 +1537,7 @@ esp_err_t test_touch_proximity(int meas_num)
|
||||||
|
|
||||||
/* Set the threshold. */
|
/* Set the threshold. */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
if (touch_list[i] == proximity_pad[0] ||
|
if (touch_list[i] == proximity_pad[0] ||
|
||||||
touch_list[i] == proximity_pad[1] ||
|
touch_list[i] == proximity_pad[1] ||
|
||||||
touch_list[i] == proximity_pad[2]) {
|
touch_list[i] == proximity_pad[2]) {
|
||||||
|
@ -1658,10 +1619,7 @@ esp_err_t test_touch_sleep_reading_stable(touch_pad_t sleep_pad)
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 3, // 0%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
.smh_lvl = TOUCH_PAD_SMOOTH_OFF,
|
.smh_lvl = TOUCH_PAD_SMOOTH_OFF,
|
||||||
};
|
};
|
||||||
|
@ -1679,7 +1637,7 @@ esp_err_t test_touch_sleep_reading_stable(touch_pad_t sleep_pad)
|
||||||
|
|
||||||
/* Set threshold of touch sensor */
|
/* Set threshold of touch sensor */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d",
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d",
|
||||||
|
@ -1687,7 +1645,7 @@ esp_err_t test_touch_sleep_reading_stable(touch_pad_t sleep_pad)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sleep channel setting */
|
/* Sleep channel setting */
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_baseline(sleep_pad, &touch_value) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_set_threshold(sleep_pad, touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_sleep_set_threshold(sleep_pad, touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
vTaskDelay(50 * SYS_DELAY_TIME_MOM / portTICK_PERIOD_MS);
|
vTaskDelay(50 * SYS_DELAY_TIME_MOM / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
|
@ -1695,7 +1653,7 @@ esp_err_t test_touch_sleep_reading_stable(touch_pad_t sleep_pad)
|
||||||
/* Touch reading filtered value equal to raw data. */
|
/* Touch reading filtered value equal to raw data. */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_data(sleep_pad, &touch_value) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_data(sleep_pad, &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_baseline(sleep_pad, &touch_temp) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &touch_temp) );
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp, touch_value);
|
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp, touch_value);
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &touch_temp) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &touch_temp) );
|
||||||
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp, touch_value);
|
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp, touch_value);
|
||||||
|
@ -1708,7 +1666,7 @@ esp_err_t test_touch_sleep_reading_stable(touch_pad_t sleep_pad)
|
||||||
}
|
}
|
||||||
vTaskDelay(20 / portTICK_PERIOD_MS);
|
vTaskDelay(20 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_baseline(sleep_pad, &ret_val) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &ret_val) );
|
||||||
|
|
||||||
TEST_ESP_OK( touch_pad_deinit() );
|
TEST_ESP_OK( touch_pad_deinit() );
|
||||||
|
|
||||||
|
@ -1760,10 +1718,7 @@ uint32_t test_touch_sleep_pad_proximity(touch_pad_t sleep_pad, bool is_proximity
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 3, // 0%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
.smh_lvl = TOUCH_PAD_SMOOTH_OFF,
|
.smh_lvl = TOUCH_PAD_SMOOTH_OFF,
|
||||||
};
|
};
|
||||||
|
@ -1789,14 +1744,13 @@ uint32_t test_touch_sleep_pad_proximity(touch_pad_t sleep_pad, bool is_proximity
|
||||||
ESP_LOGI(TAG, "Sleep pad [%d] base %d, thresh %d", touch_list[i], touch_value,
|
ESP_LOGI(TAG, "Sleep pad [%d] base %d, thresh %d", touch_list[i], touch_value,
|
||||||
(uint32_t)(meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD)));
|
(uint32_t)(meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD)));
|
||||||
} else if (touch_list[i] == sleep_pad) {
|
} else if (touch_list[i] == sleep_pad) {
|
||||||
// TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
|
||||||
touch_pad_sleep_channel_read_smooth(sleep_pad, &touch_value);
|
touch_pad_sleep_channel_read_smooth(sleep_pad, &touch_value);
|
||||||
/* The threshold of proximity pad is the sum of touch reading `meas_num` times */
|
/* The threshold of proximity pad is the sum of touch reading `meas_num` times */
|
||||||
touch_pad_sleep_set_threshold(sleep_pad, meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD));
|
touch_pad_sleep_set_threshold(sleep_pad, meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD));
|
||||||
ESP_LOGI(TAG, "proximity pad [%d] base %d, thresh %d", touch_list[i], touch_value,
|
ESP_LOGI(TAG, "proximity pad [%d] base %d, thresh %d", touch_list[i], touch_value,
|
||||||
(uint32_t)(meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD)));
|
(uint32_t)(meas_num * touch_value * (1 + TOUCH_INTR_THRESHOLD)));
|
||||||
} else {
|
} else {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "touch pad [%d] base %d, thresh %d", \
|
ESP_LOGI(TAG, "touch pad [%d] base %d, thresh %d", \
|
||||||
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
touch_list[i], touch_value, (uint32_t)(touch_value * TOUCH_INTR_THRESHOLD));
|
||||||
|
@ -1817,7 +1771,7 @@ uint32_t test_touch_sleep_pad_proximity(touch_pad_t sleep_pad, bool is_proximity
|
||||||
} else {
|
} else {
|
||||||
/* Set threshold of touch sensor */
|
/* Set threshold of touch sensor */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d",
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d",
|
||||||
|
@ -1837,7 +1791,7 @@ uint32_t test_touch_sleep_pad_proximity(touch_pad_t sleep_pad, bool is_proximity
|
||||||
printf_touch_hw_read("push");
|
printf_touch_hw_read("push");
|
||||||
if (is_proximity) {
|
if (is_proximity) {
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &smooth) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_baseline(sleep_pad, &touch_value) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_proximity_get_data(sleep_pad, &measure_out) );
|
TEST_ESP_OK( touch_pad_proximity_get_data(sleep_pad, &measure_out) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_proximity_cnt(sleep_pad, &proximity_cnt) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_proximity_cnt(sleep_pad, &proximity_cnt) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_get_threshold(sleep_pad, &touch_thres) );
|
TEST_ESP_OK( touch_pad_sleep_get_threshold(sleep_pad, &touch_thres) );
|
||||||
|
@ -1850,7 +1804,7 @@ uint32_t test_touch_sleep_pad_proximity(touch_pad_t sleep_pad, bool is_proximity
|
||||||
printf_touch_hw_read("release");
|
printf_touch_hw_read("release");
|
||||||
if (is_proximity) {
|
if (is_proximity) {
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &smooth) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_baseline(sleep_pad, &touch_value) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_proximity_get_data(sleep_pad, &measure_out) );
|
TEST_ESP_OK( touch_pad_proximity_get_data(sleep_pad, &measure_out) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_proximity_cnt(sleep_pad, &proximity_cnt) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_proximity_cnt(sleep_pad, &proximity_cnt) );
|
||||||
printf("touch slp smooth %d, base %d, proxi %d cnt %d status 0x%x\n",
|
printf("touch slp smooth %d, base %d, proxi %d cnt %d status 0x%x\n",
|
||||||
|
@ -1910,10 +1864,7 @@ esp_err_t test_touch_sleep_pad_interrupt_wakeup_deep_sleep(touch_pad_t sleep_pad
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
.mode = TOUCH_PAD_FILTER_IIR_16, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 3, // 0%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
.smh_lvl = TOUCH_PAD_SMOOTH_OFF,
|
.smh_lvl = TOUCH_PAD_SMOOTH_OFF,
|
||||||
};
|
};
|
||||||
|
@ -1932,7 +1883,7 @@ esp_err_t test_touch_sleep_pad_interrupt_wakeup_deep_sleep(touch_pad_t sleep_pad
|
||||||
|
|
||||||
/* Set threshold of touch sensor */
|
/* Set threshold of touch sensor */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d",
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d",
|
||||||
|
@ -1940,7 +1891,7 @@ esp_err_t test_touch_sleep_pad_interrupt_wakeup_deep_sleep(touch_pad_t sleep_pad
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sleep channel setting */
|
/* Sleep channel setting */
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_baseline(sleep_pad, &touch_value) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_set_threshold(sleep_pad, touch_value * TOUCH_INTR_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_sleep_set_threshold(sleep_pad, touch_value * TOUCH_INTR_THRESHOLD) );
|
||||||
|
|
||||||
vTaskDelay(50 * SYS_DELAY_TIME_MOM / portTICK_PERIOD_MS);
|
vTaskDelay(50 * SYS_DELAY_TIME_MOM / portTICK_PERIOD_MS);
|
||||||
|
@ -1950,7 +1901,7 @@ esp_err_t test_touch_sleep_pad_interrupt_wakeup_deep_sleep(touch_pad_t sleep_pad
|
||||||
printf_touch_hw_read("push");
|
printf_touch_hw_read("push");
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &smooth) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_data(sleep_pad, &raw) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_data(sleep_pad, &raw) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_baseline(sleep_pad, &touch_value) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &touch_value) );
|
||||||
printf("touch slp raw %d, smooth %d, base %d, status 0x%x\n", raw, smooth, touch_value, touch_pad_get_status());
|
printf("touch slp raw %d, smooth %d, base %d, status 0x%x\n", raw, smooth, touch_value, touch_pad_get_status());
|
||||||
|
|
||||||
test_touch_release_all();
|
test_touch_release_all();
|
||||||
|
@ -1958,7 +1909,7 @@ esp_err_t test_touch_sleep_pad_interrupt_wakeup_deep_sleep(touch_pad_t sleep_pad
|
||||||
printf_touch_hw_read("release");
|
printf_touch_hw_read("release");
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &smooth) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_smooth(sleep_pad, &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_data(sleep_pad, &raw) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_data(sleep_pad, &raw) );
|
||||||
TEST_ESP_OK( touch_pad_sleep_channel_read_baseline(sleep_pad, &touch_value) );
|
TEST_ESP_OK( touch_pad_sleep_channel_read_benchmark(sleep_pad, &touch_value) );
|
||||||
printf("touch slp raw %d, smooth %d, base %d, status 0x%x\n", raw, smooth, touch_value, touch_pad_get_status());
|
printf("touch slp raw %d, smooth %d, base %d, status 0x%x\n", raw, smooth, touch_value, touch_pad_get_status());
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
@ -2030,8 +1981,8 @@ TEST_CASE("Touch Sensor sleep pad wakeup deep sleep test", "[touch][ignore]")
|
||||||
|
|
||||||
#include "touch_scope.h"
|
#include "touch_scope.h"
|
||||||
/*
|
/*
|
||||||
* 0: 10 channels raw/smooth/baseline data debug.
|
* 0: 10 channels raw/smooth/benchmark data debug.
|
||||||
* 1: 5 channges smooth + baseline data debug.
|
* 1: 5 channges smooth + benchmark data debug.
|
||||||
* 2: 1 channels filter data.
|
* 2: 1 channels filter data.
|
||||||
*/
|
*/
|
||||||
#define SCOPE_DEBUG_TYPE 2
|
#define SCOPE_DEBUG_TYPE 2
|
||||||
|
@ -2062,10 +2013,7 @@ void test_touch_slope_debug(int pad_num)
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_IIR_32, // Test jitter and filter 1/4.
|
.mode = TOUCH_PAD_FILTER_IIR_32, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 2, // 6.25%
|
|
||||||
.noise_thr = 3, // 50%
|
.noise_thr = 3, // 50%
|
||||||
.noise_neg_thr = 3, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
||||||
};
|
};
|
||||||
|
@ -2090,7 +2038,7 @@ void test_touch_slope_debug(int pad_num)
|
||||||
|
|
||||||
/* Set threshold of touch sensor */
|
/* Set threshold of touch sensor */
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
TEST_ESP_OK( touch_pad_filter_read_baseline(touch_list[i], &touch_value) );
|
TEST_ESP_OK( touch_pad_read_benchmark(touch_list[i], &touch_value) );
|
||||||
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
TEST_ESP_OK( touch_pad_filter_read_smooth(touch_list[i], &smooth) );
|
||||||
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_THRESHOLD) );
|
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * TOUCH_THRESHOLD) );
|
||||||
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d", \
|
ESP_LOGI(TAG, "test init: touch pad [%d] base %d, smooth %d, thresh %d", \
|
||||||
|
@ -2106,7 +2054,7 @@ void test_touch_slope_debug(int pad_num)
|
||||||
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
|
||||||
touch_pad_read_raw_data(touch_list[i], &scope_data[i]);
|
touch_pad_read_raw_data(touch_list[i], &scope_data[i]);
|
||||||
// touch_pad_filter_read_smooth(touch_list[i], &scope_data[i]);
|
// touch_pad_filter_read_smooth(touch_list[i], &scope_data[i]);
|
||||||
// touch_pad_filter_read_baseline(touch_list[i], &scope_data[i]);
|
// touch_pad_read_benchmark(touch_list[i], &scope_data[i]);
|
||||||
scope_temp[i] = scope_data[i];
|
scope_temp[i] = scope_data[i];
|
||||||
}
|
}
|
||||||
test_tp_print_to_scope(scope_temp, TEST_TOUCH_CHANNEL);
|
test_tp_print_to_scope(scope_temp, TEST_TOUCH_CHANNEL);
|
||||||
|
@ -2128,29 +2076,27 @@ void test_touch_slope_debug(int pad_num)
|
||||||
}
|
}
|
||||||
#elif SCOPE_DEBUG_TYPE == 2
|
#elif SCOPE_DEBUG_TYPE == 2
|
||||||
uint32_t status;
|
uint32_t status;
|
||||||
touch_pad_filter_read_baseline(pad_num, &status);
|
touch_pad_read_benchmark(pad_num, &status);
|
||||||
while (1) {
|
while (1) {
|
||||||
xQueueReceive(que_touch, &evt, SCOPE_DEBUG_FREQ_MS / portTICK_RATE_MS);
|
xQueueReceive(que_touch, &evt, SCOPE_DEBUG_FREQ_MS / portTICK_RATE_MS);
|
||||||
//read filtered value
|
//read filtered value
|
||||||
touch_pad_read_raw_data(pad_num, &scope_data[0]);
|
touch_pad_read_raw_data(pad_num, &scope_data[0]);
|
||||||
touch_pad_filter_read_baseline(pad_num, &scope_data[1]);
|
touch_pad_read_benchmark(pad_num, &scope_data[1]);
|
||||||
touch_pad_get_thresh(pad_num, &scope_data[2]);
|
touch_pad_get_thresh(pad_num, &scope_data[2]);
|
||||||
touch_pad_filter_read_smooth(pad_num, &scope_data[8]);
|
touch_pad_filter_read_smooth(pad_num, &scope_data[8]);
|
||||||
// raw data
|
// raw data
|
||||||
scope_temp[0] = scope_data[0];
|
scope_temp[0] = scope_data[0];
|
||||||
// baseline
|
// benchmark
|
||||||
scope_temp[1] = scope_data[1];
|
scope_temp[1] = scope_data[1];
|
||||||
// smooth data
|
// smooth data
|
||||||
scope_temp[8] = scope_data[8];
|
scope_temp[8] = scope_data[8];
|
||||||
// noise neg thr
|
// noise thr
|
||||||
scope_temp[2] = scope_temp[1] - scope_data[2] * 0.5;
|
scope_temp[2] = scope_temp[1] - scope_data[2] * 0.5;
|
||||||
// noise thr
|
// noise thr
|
||||||
scope_temp[3] = scope_temp[1] + scope_data[2] * 0.5;
|
scope_temp[3] = scope_temp[1] + scope_data[2] * 0.5;
|
||||||
// touch thr
|
// touch thr
|
||||||
scope_temp[4] = scope_temp[1] + scope_data[2];
|
scope_temp[4] = scope_temp[1] + scope_data[2];
|
||||||
// hysteresis_thr thr
|
|
||||||
scope_temp[5] = scope_temp[4] - scope_data[2] * 0.0625;
|
scope_temp[5] = scope_temp[4] - scope_data[2] * 0.0625;
|
||||||
// hysteresis_thr thr
|
|
||||||
scope_temp[6] = scope_temp[4] + scope_data[2] * 0.0625;
|
scope_temp[6] = scope_temp[4] + scope_data[2] * 0.0625;
|
||||||
// touch status
|
// touch status
|
||||||
if (touch_pad_get_status() & BIT(pad_num)) {
|
if (touch_pad_get_status() & BIT(pad_num)) {
|
||||||
|
@ -2166,8 +2112,7 @@ void test_touch_slope_debug(int pad_num)
|
||||||
TEST_ESP_OK( test_touch_check_ch_touched(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
TEST_ESP_OK( test_touch_check_ch_touched(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
||||||
printf_touch_hw_read("push");
|
printf_touch_hw_read("push");
|
||||||
|
|
||||||
/* Test: if the raw data exceed noise threshold, the baseline should not be updated. */
|
test_touch_benchmark();
|
||||||
test_touch_baseline_not_update();
|
|
||||||
|
|
||||||
test_touch_release_all();
|
test_touch_release_all();
|
||||||
TEST_ESP_OK( test_touch_check_ch_released(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
TEST_ESP_OK( test_touch_check_ch_released(TEST_TOUCH_CHANNEL, TOUCH_EXCEED_TIME_MS) );
|
||||||
|
|
|
@ -193,6 +193,7 @@ typedef struct touch_pad_denoise {
|
||||||
from the reading of denoise channel. */
|
from the reading of denoise channel. */
|
||||||
} touch_pad_denoise_t;
|
} touch_pad_denoise_t;
|
||||||
|
|
||||||
|
/** Touch sensor shield channel drive capability level */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TOUCH_PAD_SHIELD_DRV_L0 = 0,/*!<The max equivalent capacitance in shield channel is 40pf */
|
TOUCH_PAD_SHIELD_DRV_L0 = 0,/*!<The max equivalent capacitance in shield channel is 40pf */
|
||||||
TOUCH_PAD_SHIELD_DRV_L1, /*!<The max equivalent capacitance in shield channel is 80pf */
|
TOUCH_PAD_SHIELD_DRV_L1, /*!<The max equivalent capacitance in shield channel is 80pf */
|
||||||
|
@ -207,10 +208,13 @@ typedef enum {
|
||||||
|
|
||||||
/** Touch sensor waterproof configuration */
|
/** Touch sensor waterproof configuration */
|
||||||
typedef struct touch_pad_waterproof {
|
typedef struct touch_pad_waterproof {
|
||||||
touch_pad_t guard_ring_pad; /*!<Waterproof. Select touch channel use for guard pad */
|
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 shield pad
|
Guard pad is used to detect the large area of water covering the touch panel. */
|
||||||
Config the Touch14 to the touch sensor and compare the measured
|
touch_pad_shield_driver_t shield_driver;/*!<Waterproof. Shield channel drive capability configuration.
|
||||||
reading to the Touch0 reading to estimate the equivalent capacitance.*/
|
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;
|
} touch_pad_waterproof_t;
|
||||||
|
|
||||||
/** Touch sensor proximity detection configuration */
|
/** Touch sensor proximity detection configuration */
|
||||||
|
@ -257,33 +261,18 @@ typedef enum {
|
||||||
|
|
||||||
/** Touch sensor filter configuration */
|
/** Touch sensor filter configuration */
|
||||||
typedef struct touch_filter_config {
|
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.
|
touch_filter_mode_t mode; /*!<Set filter mode. The input of the filter is the raw value of touch reading,
|
||||||
Larger filter coefficients increase the stability of the baseline. */
|
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
|
uint32_t debounce_cnt; /*!<Set debounce count, such as `n`. If the measured values continue to exceed
|
||||||
the threshold for `n+1` times, the touch sensor state changes.
|
the threshold for `n+1` times, the touch sensor state changes.
|
||||||
Range: 0 ~ 7 */
|
Range: 0 ~ 7 */
|
||||||
uint32_t hysteresis_thr; /*!<Hysteresis threshold coefficient. hysteresis = hysteresis coefficient * touch threshold.
|
uint32_t noise_thr; /*!<Noise threshold coefficient. Higher = More noise resistance.
|
||||||
If (raw data - baseline) > (touch threshold + hysteresis), the touch channel be touched.
|
The actual noise should be less than (noise coefficient * touch threshold).
|
||||||
If (raw data - baseline) < (touch threshold - hysteresis), the touch channel be released.
|
|
||||||
Range: 0 ~ 3. The coefficient is 0: 4/32; 1: 3/32; 2: 1/32; 3: OFF */
|
|
||||||
uint32_t noise_thr; /*!<Noise threshold coefficient. noise = noise coefficient * touch threshold.
|
|
||||||
If (raw data - baseline) > (noise), the baseline stop updating.
|
|
||||||
If (raw data - baseline) < (noise), the baseline start updating.
|
|
||||||
Range: 0 ~ 3. The coefficient is 0: 4/8; 1: 3/8; 2: 2/8; 3: 1; */
|
Range: 0 ~ 3. The coefficient is 0: 4/8; 1: 3/8; 2: 2/8; 3: 1; */
|
||||||
uint32_t noise_neg_thr; /*!<Negative noise threshold coefficient. negative noise = noise coefficient * 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: 4/8; 1: 3/8; 2: 2/8; 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+1` times, the baseline reset to raw data.
|
|
||||||
Range: 0 ~ 15 */
|
|
||||||
uint32_t jitter_step; /*!<Set jitter filter step size. Range: 0 ~ 15 */
|
uint32_t jitter_step; /*!<Set jitter filter step size. Range: 0 ~ 15 */
|
||||||
touch_smooth_mode_t smh_lvl;/*!<Level of filter applied on the original data against large noise interference. */
|
touch_smooth_mode_t smh_lvl;/*!<Level of filter applied on the original data against large noise interference. */
|
||||||
#define TOUCH_DEBOUNCE_CNT_MAX (7)
|
#define TOUCH_DEBOUNCE_CNT_MAX (7)
|
||||||
#define TOUCH_HYSTERESIS_THR_MAX (3)
|
|
||||||
#define TOUCH_NOISE_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)
|
#define TOUCH_JITTER_STEP_MAX (15)
|
||||||
} touch_filter_config_t;
|
} touch_filter_config_t;
|
||||||
|
|
||||||
|
|
|
@ -3114,30 +3114,30 @@ extern "C" {
|
||||||
#define RTC_CNTL_TOUCH_DEBOUNCE_M ((RTC_CNTL_TOUCH_DEBOUNCE_V)<<(RTC_CNTL_TOUCH_DEBOUNCE_S))
|
#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_V 0x7
|
||||||
#define RTC_CNTL_TOUCH_DEBOUNCE_S 25
|
#define RTC_CNTL_TOUCH_DEBOUNCE_S 25
|
||||||
/* RTC_CNTL_TOUCH_HYSTERESIS : R/W ;bitpos:[24:23] ;default: 2'd1 ; */
|
/* RTC_CNTL_TOUCH_CONFIG3 : R/W ;bitpos:[24:23] ;default: 2'd1 ; */
|
||||||
/*description: */
|
/*description: */
|
||||||
#define RTC_CNTL_TOUCH_HYSTERESIS 0x00000003
|
#define RTC_CNTL_TOUCH_CONFIG3 0x00000003
|
||||||
#define RTC_CNTL_TOUCH_HYSTERESIS_M ((RTC_CNTL_TOUCH_HYSTERESIS_V)<<(RTC_CNTL_TOUCH_HYSTERESIS_S))
|
#define RTC_CNTL_TOUCH_CONFIG3_M ((RTC_CNTL_TOUCH_CONFIG3_V)<<(RTC_CNTL_TOUCH_CONFIG3_S))
|
||||||
#define RTC_CNTL_TOUCH_HYSTERESIS_V 0x3
|
#define RTC_CNTL_TOUCH_CONFIG3_V 0x3
|
||||||
#define RTC_CNTL_TOUCH_HYSTERESIS_S 23
|
#define RTC_CNTL_TOUCH_CONFIG3_S 23
|
||||||
/* RTC_CNTL_TOUCH_NOISE_THRES : R/W ;bitpos:[22:21] ;default: 2'd1 ; */
|
/* RTC_CNTL_TOUCH_NOISE_THRES : R/W ;bitpos:[22:21] ;default: 2'd1 ; */
|
||||||
/*description: */
|
/*description: */
|
||||||
#define RTC_CNTL_TOUCH_NOISE_THRES 0x00000003
|
#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_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_V 0x3
|
||||||
#define RTC_CNTL_TOUCH_NOISE_THRES_S 21
|
#define RTC_CNTL_TOUCH_NOISE_THRES_S 21
|
||||||
/* RTC_CNTL_TOUCH_NEG_NOISE_THRES : R/W ;bitpos:[20:19] ;default: 2'd1 ; */
|
/* RTC_CNTL_TOUCH_CONFIG2 : R/W ;bitpos:[20:19] ;default: 2'd1 ; */
|
||||||
/*description: */
|
/*description: */
|
||||||
#define RTC_CNTL_TOUCH_NEG_NOISE_THRES 0x00000003
|
#define RTC_CNTL_TOUCH_CONFIG2 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_CONFIG2_M ((RTC_CNTL_TOUCH_CONFIG2_V)<<(RTC_CNTL_TOUCH_CONFIG2_S))
|
||||||
#define RTC_CNTL_TOUCH_NEG_NOISE_THRES_V 0x3
|
#define RTC_CNTL_TOUCH_CONFIG2_V 0x3
|
||||||
#define RTC_CNTL_TOUCH_NEG_NOISE_THRES_S 19
|
#define RTC_CNTL_TOUCH_CONFIG2_S 19
|
||||||
/* RTC_CNTL_TOUCH_NEG_NOISE_LIMIT : R/W ;bitpos:[18:15] ;default: 4'd5 ; */
|
/* RTC_CNTL_TOUCH_CONFIG1 : R/W ;bitpos:[18:15] ;default: 4'd5 ; */
|
||||||
/*description: negative threshold counter limit*/
|
/*description: */
|
||||||
#define RTC_CNTL_TOUCH_NEG_NOISE_LIMIT 0x0000000F
|
#define RTC_CNTL_TOUCH_CONFIG1 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_CONFIG1_M ((RTC_CNTL_TOUCH_CONFIG1_V)<<(RTC_CNTL_TOUCH_CONFIG1_S))
|
||||||
#define RTC_CNTL_TOUCH_NEG_NOISE_LIMIT_V 0xF
|
#define RTC_CNTL_TOUCH_CONFIG1_V 0xF
|
||||||
#define RTC_CNTL_TOUCH_NEG_NOISE_LIMIT_S 15
|
#define RTC_CNTL_TOUCH_CONFIG1_S 15
|
||||||
/* RTC_CNTL_TOUCH_JITTER_STEP : R/W ;bitpos:[14:11] ;default: 4'd1 ; */
|
/* RTC_CNTL_TOUCH_JITTER_STEP : R/W ;bitpos:[14:11] ;default: 4'd1 ; */
|
||||||
/*description: touch jitter step*/
|
/*description: touch jitter step*/
|
||||||
#define RTC_CNTL_TOUCH_JITTER_STEP 0x0000000F
|
#define RTC_CNTL_TOUCH_JITTER_STEP 0x0000000F
|
||||||
|
|
|
@ -800,10 +800,10 @@ typedef volatile struct {
|
||||||
uint32_t reserved0: 9;
|
uint32_t reserved0: 9;
|
||||||
uint32_t touch_smooth_lvl: 2;
|
uint32_t touch_smooth_lvl: 2;
|
||||||
uint32_t touch_jitter_step: 4; /*touch jitter step*/
|
uint32_t touch_jitter_step: 4; /*touch jitter step*/
|
||||||
uint32_t touch_neg_noise_limit: 4; /*negative threshold counter limit*/
|
uint32_t config1: 4;
|
||||||
uint32_t touch_neg_noise_thres: 2;
|
uint32_t config2: 2;
|
||||||
uint32_t touch_noise_thres: 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_debounce: 3; /*debounce counter*/
|
||||||
uint32_t touch_filter_mode: 3; /*0: IIR ? 1: IIR ? 2: IIR 1/8 3: Jitter*/
|
uint32_t touch_filter_mode: 3; /*0: IIR ? 1: IIR ? 2: IIR 1/8 3: Jitter*/
|
||||||
uint32_t touch_filter_en: 1; /*touch filter enable*/
|
uint32_t touch_filter_en: 1; /*touch filter enable*/
|
||||||
|
|
|
@ -631,7 +631,7 @@ extern "C" {
|
||||||
#define SENS_TOUCH_DENOISE_END_V 0x1
|
#define SENS_TOUCH_DENOISE_END_V 0x1
|
||||||
#define SENS_TOUCH_DENOISE_END_S 18
|
#define SENS_TOUCH_DENOISE_END_S 18
|
||||||
/* SENS_TOUCH_DATA_SEL : R/W ;bitpos:[17:16] ;default: 2'd0 ; */
|
/* SENS_TOUCH_DATA_SEL : R/W ;bitpos:[17:16] ;default: 2'd0 ; */
|
||||||
/*description: 3: smooth data 2: baseline 1 0: raw_data*/
|
/*description: 3: smooth data 2: benchmark 1 0: raw_data*/
|
||||||
#define SENS_TOUCH_DATA_SEL 0x00000003
|
#define SENS_TOUCH_DATA_SEL 0x00000003
|
||||||
#define SENS_TOUCH_DATA_SEL_M ((SENS_TOUCH_DATA_SEL_V)<<(SENS_TOUCH_DATA_SEL_S))
|
#define SENS_TOUCH_DATA_SEL_M ((SENS_TOUCH_DATA_SEL_V)<<(SENS_TOUCH_DATA_SEL_S))
|
||||||
#define SENS_TOUCH_DATA_SEL_V 0x3
|
#define SENS_TOUCH_DATA_SEL_V 0x3
|
||||||
|
|
|
@ -225,7 +225,7 @@ typedef volatile struct {
|
||||||
struct {
|
struct {
|
||||||
uint32_t touch_outen: 15; /*touch controller output enable*/
|
uint32_t touch_outen: 15; /*touch controller output enable*/
|
||||||
uint32_t touch_status_clr: 1; /*clear all touch active status*/
|
uint32_t touch_status_clr: 1; /*clear all touch active status*/
|
||||||
uint32_t touch_data_sel: 2; /*3: smooth data 2: baseline 1 0: raw_data*/
|
uint32_t touch_data_sel: 2; /*3: smooth data 2: benchmark 1 0: raw_data*/
|
||||||
uint32_t touch_denoise_end: 1; /*touch_denoise_done*/
|
uint32_t touch_denoise_end: 1; /*touch_denoise_done*/
|
||||||
uint32_t touch_unit_end: 1; /*touch_unit_done*/
|
uint32_t touch_unit_end: 1; /*touch_unit_done*/
|
||||||
uint32_t touch_approach_pad2: 4; /*indicate which pad is approach pad2*/
|
uint32_t touch_approach_pad2: 4; /*indicate which pad is approach pad2*/
|
||||||
|
|
|
@ -24,9 +24,7 @@ extern "C" {
|
||||||
#define SOC_TOUCH_PAD_MEASURE_WAIT (0xFF) /*!<The timer frequency is 8Mhz, the max value is 0xff */
|
#define SOC_TOUCH_PAD_MEASURE_WAIT (0xFF) /*!<The timer frequency is 8Mhz, the max value is 0xff */
|
||||||
#define SOC_TOUCH_PAD_THRESHOLD_MAX (0x1FFFFF) /*!<If set touch threshold max value, The touch sensor can't be in touched status */
|
#define SOC_TOUCH_PAD_THRESHOLD_MAX (0x1FFFFF) /*!<If set touch threshold max value, The touch sensor can't be in touched status */
|
||||||
|
|
||||||
#define SOC_TOUCH_SHIELD_CHANNEL (14) /*!< The waterproof function includes a shielded channel (TOUCH_PAD_NUM14)
|
#define SOC_TOUCH_SHIELD_CHANNEL (14) /*!< The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) */
|
||||||
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. */
|
|
||||||
#define SOC_TOUCH_DENOISE_CHANNEL (0) /*!< T0 is an internal channel that does not have a corresponding external GPIO.
|
#define SOC_TOUCH_DENOISE_CHANNEL (0) /*!< T0 is an internal channel that does not have a corresponding external GPIO.
|
||||||
T0 will work simultaneously with the measured channel Tn. Finally, the actual
|
T0 will work simultaneously with the measured channel Tn. Finally, the actual
|
||||||
measured value of Tn is the value after subtracting lower bits of T0. */
|
measured value of Tn is the value after subtracting lower bits of T0. */
|
||||||
|
|
|
@ -3098,30 +3098,30 @@ extern "C" {
|
||||||
#define RTC_CNTL_TOUCH_DEBOUNCE_M ((RTC_CNTL_TOUCH_DEBOUNCE_V) << (RTC_CNTL_TOUCH_DEBOUNCE_S))
|
#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_V 0x7
|
||||||
#define RTC_CNTL_TOUCH_DEBOUNCE_S 25
|
#define RTC_CNTL_TOUCH_DEBOUNCE_S 25
|
||||||
/* RTC_CNTL_TOUCH_HYSTERESIS : R/W ;bitpos:[24:23] ;default: 2'd1 ; */
|
/* RTC_CNTL_TOUCH_CONFIG3 : R/W ;bitpos:[24:23] ;default: 2'd1 ; */
|
||||||
/*description: */
|
/*description: */
|
||||||
#define RTC_CNTL_TOUCH_HYSTERESIS 0x00000003
|
#define RTC_CNTL_TOUCH_CONFIG3 0x00000003
|
||||||
#define RTC_CNTL_TOUCH_HYSTERESIS_M ((RTC_CNTL_TOUCH_HYSTERESIS_V) << (RTC_CNTL_TOUCH_HYSTERESIS_S))
|
#define RTC_CNTL_TOUCH_CONFIG3_M ((RTC_CNTL_TOUCH_CONFIG3_V) << (RTC_CNTL_TOUCH_CONFIG3_S))
|
||||||
#define RTC_CNTL_TOUCH_HYSTERESIS_V 0x3
|
#define RTC_CNTL_TOUCH_CONFIG3_V 0x3
|
||||||
#define RTC_CNTL_TOUCH_HYSTERESIS_S 23
|
#define RTC_CNTL_TOUCH_CONFIG3_S 23
|
||||||
/* RTC_CNTL_TOUCH_NOISE_THRES : R/W ;bitpos:[22:21] ;default: 2'd1 ; */
|
/* RTC_CNTL_TOUCH_NOISE_THRES : R/W ;bitpos:[22:21] ;default: 2'd1 ; */
|
||||||
/*description: */
|
/*description: */
|
||||||
#define RTC_CNTL_TOUCH_NOISE_THRES 0x00000003
|
#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_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_V 0x3
|
||||||
#define RTC_CNTL_TOUCH_NOISE_THRES_S 21
|
#define RTC_CNTL_TOUCH_NOISE_THRES_S 21
|
||||||
/* RTC_CNTL_TOUCH_NEG_NOISE_THRES : R/W ;bitpos:[20:19] ;default: 2'd1 ; */
|
/* RTC_CNTL_TOUCH_CONFIG2 : R/W ;bitpos:[20:19] ;default: 2'd1 ; */
|
||||||
/*description: */
|
/*description: */
|
||||||
#define RTC_CNTL_TOUCH_NEG_NOISE_THRES 0x00000003
|
#define RTC_CNTL_TOUCH_CONFIG2 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_CONFIG2_M ((RTC_CNTL_TOUCH_CONFIG2_V) << (RTC_CNTL_TOUCH_CONFIG2_S))
|
||||||
#define RTC_CNTL_TOUCH_NEG_NOISE_THRES_V 0x3
|
#define RTC_CNTL_TOUCH_CONFIG2_V 0x3
|
||||||
#define RTC_CNTL_TOUCH_NEG_NOISE_THRES_S 19
|
#define RTC_CNTL_TOUCH_CONFIG2_S 19
|
||||||
/* RTC_CNTL_TOUCH_NEG_NOISE_LIMIT : R/W ;bitpos:[18:15] ;default: 4'd5 ; */
|
/* RTC_CNTL_TOUCH_CONFIG1 : R/W ;bitpos:[18:15] ;default: 4'd5 ; */
|
||||||
/*description: negative threshold counter limit*/
|
/*description: */
|
||||||
#define RTC_CNTL_TOUCH_NEG_NOISE_LIMIT 0x0000000F
|
#define RTC_CNTL_TOUCH_CONFIG1 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_CONFIG1_M ((RTC_CNTL_TOUCH_CONFIG1_V) << (RTC_CNTL_TOUCH_CONFIG1_S))
|
||||||
#define RTC_CNTL_TOUCH_NEG_NOISE_LIMIT_V 0xF
|
#define RTC_CNTL_TOUCH_CONFIG1_V 0xF
|
||||||
#define RTC_CNTL_TOUCH_NEG_NOISE_LIMIT_S 15
|
#define RTC_CNTL_TOUCH_CONFIG1_S 15
|
||||||
/* RTC_CNTL_TOUCH_JITTER_STEP : R/W ;bitpos:[14:11] ;default: 4'd1 ; */
|
/* RTC_CNTL_TOUCH_JITTER_STEP : R/W ;bitpos:[14:11] ;default: 4'd1 ; */
|
||||||
/*description: touch jitter step*/
|
/*description: touch jitter step*/
|
||||||
#define RTC_CNTL_TOUCH_JITTER_STEP 0x0000000F
|
#define RTC_CNTL_TOUCH_JITTER_STEP 0x0000000F
|
||||||
|
@ -3140,12 +3140,12 @@ extern "C" {
|
||||||
#define RTC_CNTL_TOUCH_BYPASS_NOISE_THRES_M (BIT(8))
|
#define RTC_CNTL_TOUCH_BYPASS_NOISE_THRES_M (BIT(8))
|
||||||
#define RTC_CNTL_TOUCH_BYPASS_NOISE_THRES_V 0x1
|
#define RTC_CNTL_TOUCH_BYPASS_NOISE_THRES_V 0x1
|
||||||
#define RTC_CNTL_TOUCH_BYPASS_NOISE_THRES_S 8
|
#define RTC_CNTL_TOUCH_BYPASS_NOISE_THRES_S 8
|
||||||
/* RTC_CNTL_TOUCH_BYPASS_NEG_NOISE_THRES : R/W ;bitpos:[7] ;default: 1'b0 ; */
|
/* RTC_CNTL_TOUCH_BYPASS_NEG_THRES : R/W ;bitpos:[7] ;default: 1'b0 ; */
|
||||||
/*description: */
|
/*description: */
|
||||||
#define RTC_CNTL_TOUCH_BYPASS_NEG_NOISE_THRES (BIT(7))
|
#define RTC_CNTL_TOUCH_BYPASS_NEG_THRES (BIT(7))
|
||||||
#define RTC_CNTL_TOUCH_BYPASS_NEG_NOISE_THRES_M (BIT(7))
|
#define RTC_CNTL_TOUCH_BYPASS_NEG_THRES_M (BIT(7))
|
||||||
#define RTC_CNTL_TOUCH_BYPASS_NEG_NOISE_THRES_V 0x1
|
#define RTC_CNTL_TOUCH_BYPASS_NEG_THRES_V 0x1
|
||||||
#define RTC_CNTL_TOUCH_BYPASS_NEG_NOISE_THRES_S 7
|
#define RTC_CNTL_TOUCH_BYPASS_NEG_THRES_S 7
|
||||||
|
|
||||||
#define RTC_CNTL_USB_CONF_REG (DR_REG_RTCCNTL_BASE + 0x011C)
|
#define RTC_CNTL_USB_CONF_REG (DR_REG_RTCCNTL_BASE + 0x011C)
|
||||||
/* RTC_CNTL_IO_MUX_RESET_DISABLE : R/W ;bitpos:[18] ;default: 1'd0 ; */
|
/* RTC_CNTL_IO_MUX_RESET_DISABLE : R/W ;bitpos:[18] ;default: 1'd0 ; */
|
||||||
|
|
|
@ -809,14 +809,14 @@ typedef volatile struct {
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
uint32_t reserved0: 7;
|
uint32_t reserved0: 7;
|
||||||
uint32_t touch_bypass_neg_noise_thres: 1;
|
uint32_t touch_bypass_neg_thres: 1;
|
||||||
uint32_t touch_bypass_noise_thres: 1;
|
uint32_t touch_bypass_noise_thres: 1;
|
||||||
uint32_t touch_smooth_lvl: 2;
|
uint32_t touch_smooth_lvl: 2;
|
||||||
uint32_t touch_jitter_step: 4; /*touch jitter step*/
|
uint32_t touch_jitter_step: 4; /*touch jitter step*/
|
||||||
uint32_t touch_neg_noise_limit: 4; /*negative threshold counter limit*/
|
uint32_t config1: 4;
|
||||||
uint32_t touch_neg_noise_thres: 2;
|
uint32_t config2: 2;
|
||||||
uint32_t touch_noise_thres: 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_debounce: 3; /*debounce counter*/
|
||||||
uint32_t touch_filter_mode: 3; /*0: IIR ? 1: IIR ? 2: IIR 1/8 3: Jitter*/
|
uint32_t touch_filter_mode: 3; /*0: IIR ? 1: IIR ? 2: IIR 1/8 3: Jitter*/
|
||||||
uint32_t touch_filter_en: 1; /*touch filter enable*/
|
uint32_t touch_filter_en: 1; /*touch filter enable*/
|
||||||
|
|
|
@ -182,32 +182,33 @@ void touch_hal_filter_get_config(touch_filter_config_t *filter_info);
|
||||||
#define touch_hal_filter_read_smooth(touch_num, smooth_data) touch_ll_filter_read_smooth(touch_num, smooth_data)
|
#define touch_hal_filter_read_smooth(touch_num, smooth_data) touch_ll_filter_read_smooth(touch_num, smooth_data)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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_num touch pad index
|
||||||
* @param touch_value pointer to accept touch sensor value
|
* @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_read_benchmark(touch_num, benchmark) touch_ll_read_benchmark(touch_num, 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
|
* @param touch_num touch pad index
|
||||||
* - TOUCH_PAD_MAX Reset basaline of all channels.
|
* - 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_reset_benchmark(touch_num) touch_ll_reset_benchmark(touch_num)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set filter mode. The input to the filter is raw data and the output is the baseline value.
|
* Set filter mode. The input of the filter is the raw value of touch reading,
|
||||||
* Larger filter coefficients increase the stability of the baseline.
|
* and the output of the filter is involved in the judgment of the touch state.
|
||||||
*
|
*
|
||||||
* @param mode Filter mode type. Refer to ``touch_filter_mode_t``.
|
* @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)
|
#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 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.
|
||||||
*
|
*
|
||||||
* @param mode Filter mode type. Refer to ``touch_filter_mode_t``.
|
* @param mode Filter mode type. Refer to ``touch_filter_mode_t``.
|
||||||
*/
|
*/
|
||||||
|
@ -229,89 +230,47 @@ 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)
|
#define touch_hal_filter_get_debounce(dbc_cnt) touch_ll_filter_get_debounce(dbc_cnt)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set hysteresis threshold coefficient. hysteresis = hysteresis_thr * touch_threshold.
|
* Set noise threshold coefficient. Higher = More noise resistance.
|
||||||
* If (raw data - baseline) > (touch threshold + hysteresis), the touch channel be touched.
|
* The actual noise should be less than (noise coefficient * touch threshold).
|
||||||
* If (raw data - baseline) < (touch threshold - hysteresis), the touch channel be released.
|
* Range: 0 ~ 3. The coefficient is 0: 4/8; 1: 3/8; 2: 2/8; 3: 1;
|
||||||
* 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.
|
|
||||||
* Range: 0 ~ 3. The coefficient is 0: 1/2; 1: 3/8; 2: 1/4; 3: 1/8;
|
|
||||||
*
|
*
|
||||||
* @param hys_thr Noise threshold coefficient.
|
* @param hys_thr Noise threshold coefficient.
|
||||||
*/
|
*/
|
||||||
#define touch_hal_filter_set_noise_thres(noise_thr) touch_ll_filter_set_noise_thres(noise_thr)
|
#define touch_hal_filter_set_noise_thres(noise_thr) touch_ll_filter_set_noise_thres(noise_thr)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get noise threshold coefficient. noise = noise_thr * touch threshold.
|
* Get noise threshold coefficient. Higher = More noise resistance.
|
||||||
* If (raw data - baseline) > (noise), the baseline stop updating.
|
* The actual noise should be less than (noise coefficient * touch threshold).
|
||||||
* If (raw data - baseline) < (noise), the baseline start updating.
|
* Range: 0 ~ 3. The coefficient is 0: 4/8; 1: 3/8; 2: 2/8; 3: 1;
|
||||||
* Range: 0 ~ 3. The coefficient is 0: 1/2; 1: 3/8; 2: 1/4; 3: 1/8;
|
|
||||||
*
|
*
|
||||||
* @param noise_thr Noise threshold coefficient.
|
* @param noise_thr Noise threshold coefficient.
|
||||||
*/
|
*/
|
||||||
#define touch_hal_filter_get_noise_thres(noise_thr) touch_ll_filter_get_noise_thres(noise_thr)
|
#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.
|
* Set the cumulative number of benchmark reset processes. such as `n`. If the measured values continue to exceed
|
||||||
* If (baseline - raw data) > (negative noise), the baseline restart reset process(refer to `baseline_reset`).
|
* the negative noise threshold for `n` times, the benchmark reset to raw data.
|
||||||
* 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.
|
|
||||||
* Range: 0 ~ 15
|
* 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
|
* 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 baseline reset to raw data.
|
* the negative noise threshold for `n` times, the benchmark reset to raw data.
|
||||||
* Range: 0 ~ 15
|
* 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.
|
* Set jitter filter step size.
|
||||||
* If filter mode is jitter, should set filter step for jitter.
|
* If filter mode is jitter, should set filter step for jitter.
|
||||||
* Range: 0 ~ 15
|
* 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.
|
||||||
*/
|
*/
|
||||||
#define touch_hal_filter_set_jitter_step(step) touch_ll_filter_set_jitter_step(step)
|
#define touch_hal_filter_set_jitter_step(step) touch_ll_filter_set_jitter_step(step)
|
||||||
|
|
||||||
|
@ -320,7 +279,7 @@ void touch_hal_filter_get_config(touch_filter_config_t *filter_info);
|
||||||
* If filter mode is jitter, should set filter step for jitter.
|
* If filter mode is jitter, should set filter step for jitter.
|
||||||
* Range: 0 ~ 15
|
* 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.
|
||||||
*/
|
*/
|
||||||
#define touch_hal_filter_get_jitter_step(step) touch_ll_filter_get_jitter_step(step)
|
#define touch_hal_filter_get_jitter_step(step) touch_ll_filter_get_jitter_step(step)
|
||||||
|
|
||||||
|
@ -453,11 +412,11 @@ void touch_hal_denoise_enable(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set parameter of waterproof function.
|
* Set parameter of waterproof function.
|
||||||
|
*
|
||||||
* The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel.
|
* 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.
|
* 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
|
* @param waterproof parameter of waterproof
|
||||||
*/
|
*/
|
||||||
|
@ -472,21 +431,12 @@ void touch_hal_waterproof_get_config(touch_pad_waterproof_t *waterproof);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable parameter of waterproof function.
|
* Enable parameter of waterproof function.
|
||||||
* The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel.
|
* Should be called after function ``touch_hal_waterproof_set_config``.
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
void touch_hal_waterproof_enable(void);
|
void touch_hal_waterproof_enable(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable parameter of waterproof function.
|
* Disable 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.
|
|
||||||
*/
|
*/
|
||||||
#define touch_hal_waterproof_disable() touch_ll_waterproof_disable()
|
#define touch_hal_waterproof_disable() touch_ll_waterproof_disable()
|
||||||
|
|
||||||
|
@ -591,7 +541,7 @@ void touch_hal_sleep_channel_enable(touch_pad_t pad_num, bool enable);
|
||||||
/**
|
/**
|
||||||
* Set the trigger threshold of touch sensor in deep sleep.
|
* Set the trigger threshold of touch sensor in deep sleep.
|
||||||
* The threshold determines the sensitivity of the 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 The threshold at sleep is the same as the threshold before sleep.
|
* @note The threshold at sleep is the same as the threshold before sleep.
|
||||||
*/
|
*/
|
||||||
|
@ -600,7 +550,7 @@ void touch_hal_sleep_channel_enable(touch_pad_t pad_num, bool enable);
|
||||||
/**
|
/**
|
||||||
* Get the trigger threshold of touch sensor in deep sleep.
|
* Get the trigger threshold of touch sensor in deep sleep.
|
||||||
* The threshold determines the sensitivity of the 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 The threshold at sleep is the same as the threshold before sleep.
|
* @note The threshold at sleep is the same as the threshold before sleep.
|
||||||
*/
|
*/
|
||||||
|
@ -617,11 +567,11 @@ void touch_hal_sleep_channel_enable(touch_pad_t pad_num, bool enable);
|
||||||
#define touch_hal_sleep_disable_approach() touch_ll_sleep_disable_approach()
|
#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 smooth data of touch sensor for sleep pad.
|
* Read smooth data of touch sensor for sleep pad.
|
||||||
|
@ -634,9 +584,9 @@ void touch_hal_sleep_channel_enable(touch_pad_t pad_num, bool enable);
|
||||||
#define touch_hal_sleep_read_data(raw_data) touch_ll_sleep_read_data(raw_data)
|
#define touch_hal_sleep_read_data(raw_data) touch_ll_sleep_read_data(raw_data)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset baseline of touch sensor for sleep pad.
|
* Reset benchmark of touch sensor for sleep pad.
|
||||||
*/
|
*/
|
||||||
#define touch_hal_sleep_reset_baseline() touch_ll_sleep_reset_baseline()
|
#define touch_hal_sleep_reset_benchmark() touch_ll_sleep_reset_benchmark()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read debounce of touch sensor for sleep pad.
|
* Read debounce of touch sensor for sleep pad.
|
||||||
|
|
|
@ -32,7 +32,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TOUCH_LL_READ_RAW 0x0
|
#define TOUCH_LL_READ_RAW 0x0
|
||||||
#define TOUCH_LL_READ_BASELINE 0x2
|
#define TOUCH_LL_READ_BENCHMARK 0x2
|
||||||
#define TOUCH_LL_READ_SMOOTH 0x3
|
#define TOUCH_LL_READ_SMOOTH 0x3
|
||||||
#define TOUCH_LL_TIMER_FORCE_DONE 0x3
|
#define TOUCH_LL_TIMER_FORCE_DONE 0x3
|
||||||
#define TOUCH_LL_TIMER_DONE 0x0
|
#define TOUCH_LL_TIMER_DONE 0x0
|
||||||
|
@ -307,7 +307,7 @@ static inline void touch_ll_start_sw_meas(void)
|
||||||
/**
|
/**
|
||||||
* Set the trigger threshold of touch sensor.
|
* Set the trigger threshold of touch sensor.
|
||||||
* The threshold determines the sensitivity of the 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.
|
* @note If set "TOUCH_PAD_THRESHOLD_MAX", the touch is never be trigered.
|
||||||
* @param touch_num touch pad index
|
* @param touch_num touch pad index
|
||||||
|
@ -321,7 +321,7 @@ static inline void touch_ll_set_threshold(touch_pad_t touch_num, uint32_t thresh
|
||||||
/**
|
/**
|
||||||
* Get the trigger threshold of touch sensor.
|
* Get the trigger threshold of touch sensor.
|
||||||
* The threshold determines the sensitivity of the 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 touch_num touch pad index.
|
||||||
* @param threshold pointer to accept threshold.
|
* @param threshold pointer to accept threshold.
|
||||||
|
@ -635,28 +635,28 @@ static inline void IRAM_ATTR touch_ll_filter_read_smooth(touch_pad_t touch_num,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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_num touch pad index
|
||||||
* @param touch_value pointer to accept touch sensor value
|
* @param touch_value pointer to accept touch sensor value
|
||||||
*/
|
*/
|
||||||
static inline void IRAM_ATTR touch_ll_filter_read_baseline(touch_pad_t touch_num, uint32_t *basedata)
|
static inline void IRAM_ATTR touch_ll_read_benchmark(touch_pad_t touch_num, uint32_t *benchmark)
|
||||||
{
|
{
|
||||||
SENS.sar_touch_conf.touch_data_sel = TOUCH_LL_READ_BASELINE;
|
SENS.sar_touch_conf.touch_data_sel = TOUCH_LL_READ_BENCHMARK;
|
||||||
*basedata = SENS.sar_touch_status[touch_num - 1].touch_pad_data;
|
*benchmark = SENS.sar_touch_status[touch_num - 1].touch_pad_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force reset baseline to raw data of touch sensor.
|
* Force reset benchmark to raw data of touch sensor.
|
||||||
*
|
*
|
||||||
* @note If call this API, make sure enable clock gate(`touch_ll_clkgate`) first.
|
* @note If call this API, make sure enable clock gate(`touch_ll_clkgate`) first.
|
||||||
* @param touch_num touch pad index
|
* @param touch_num touch pad index
|
||||||
* - TOUCH_PAD_MAX Reset basaline of all channels.
|
* - 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_reset_benchmark(touch_pad_t touch_num)
|
||||||
{
|
{
|
||||||
/* Clear touch channels to initialize the channel value (baseline, raw_data).
|
/* Clear touch channels to initialize the channel value (benchmark, raw_data).
|
||||||
*/
|
*/
|
||||||
if (touch_num == TOUCH_PAD_MAX) {
|
if (touch_num == TOUCH_PAD_MAX) {
|
||||||
SENS.sar_touch_chn_st.touch_channel_clr = SOC_TOUCH_SENSOR_BIT_MASK_MAX;
|
SENS.sar_touch_chn_st.touch_channel_clr = SOC_TOUCH_SENSOR_BIT_MASK_MAX;
|
||||||
|
@ -666,8 +666,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.
|
* Set filter mode. The input of the filter is the raw value of touch reading,
|
||||||
* Larger filter coefficients increase the stability of the baseline.
|
* and the output of the filter is involved in the judgment of the touch state.
|
||||||
*
|
*
|
||||||
* @param mode Filter mode type. Refer to ``touch_filter_mode_t``.
|
* @param mode Filter mode type. Refer to ``touch_filter_mode_t``.
|
||||||
*/
|
*/
|
||||||
|
@ -677,7 +677,8 @@ 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 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.
|
||||||
*
|
*
|
||||||
* @param mode Filter mode type. Refer to ``touch_filter_mode_t``.
|
* @param mode Filter mode type. Refer to ``touch_filter_mode_t``.
|
||||||
*/
|
*/
|
||||||
|
@ -729,35 +730,8 @@ static inline void touch_ll_filter_get_debounce(uint32_t *dbc_cnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set hysteresis threshold coefficient. hysteresis = hysteresis_thr * touch_threshold.
|
* Set noise threshold coefficient. Higher = More noise resistance.
|
||||||
* If (raw data - baseline) > (touch threshold + hysteresis), the touch channel be touched.
|
* The actual noise should be less than (noise coefficient * touch threshold).
|
||||||
* If (raw data - baseline) < (touch threshold - hysteresis), the touch channel be released.
|
|
||||||
* Range: 0 ~ 3. The coefficient is 0: 4/32; 1: 3/32; 2: 2/32; 3: OFF.
|
|
||||||
*
|
|
||||||
* @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: 4/32; 1: 3/32; 2: 2/32; 3: OFF.
|
|
||||||
*
|
|
||||||
* @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.
|
|
||||||
* Range: 0 ~ 3. The coefficient is 0: 4/8; 1: 3/8; 2: 2/8; 3: 1;
|
* Range: 0 ~ 3. The coefficient is 0: 4/8; 1: 3/8; 2: 2/8; 3: 1;
|
||||||
*
|
*
|
||||||
* @param hys_thr Noise threshold coefficient.
|
* @param hys_thr Noise threshold coefficient.
|
||||||
|
@ -765,12 +739,14 @@ 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)
|
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.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.
|
* Get noise threshold coefficient. Higher = More noise resistance.
|
||||||
* If (raw data - baseline) > (noise), the baseline stop updating.
|
* The actual noise should be less than (noise coefficient * touch threshold).
|
||||||
* If (raw data - baseline) < (noise), the baseline start updating.
|
|
||||||
* Range: 0 ~ 3. The coefficient is 0: 4/8; 1: 3/8; 2: 2/8; 3: 1;
|
* Range: 0 ~ 3. The coefficient is 0: 4/8; 1: 3/8; 2: 2/8; 3: 1;
|
||||||
*
|
*
|
||||||
* @param noise_thr Noise threshold coefficient.
|
* @param noise_thr Noise threshold coefficient.
|
||||||
|
@ -780,62 +756,12 @@ static inline void touch_ll_filter_get_noise_thres(uint32_t *noise_thr)
|
||||||
*noise_thr = RTCCNTL.touch_filter_ctrl.touch_noise_thres;
|
*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+1` 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+1` 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.
|
* Set jitter filter step size.
|
||||||
* If filter mode is jitter, should set filter step for jitter.
|
* If filter mode is jitter, should set filter step for jitter.
|
||||||
* Range: 0 ~ 15
|
* 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.
|
||||||
*/
|
*/
|
||||||
static inline void touch_ll_filter_set_jitter_step(uint32_t step)
|
static inline void touch_ll_filter_set_jitter_step(uint32_t step)
|
||||||
{
|
{
|
||||||
|
@ -847,7 +773,7 @@ static inline void touch_ll_filter_set_jitter_step(uint32_t step)
|
||||||
* If filter mode is jitter, should set filter step for jitter.
|
* If filter mode is jitter, should set filter step for jitter.
|
||||||
* Range: 0 ~ 15
|
* 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.
|
||||||
*/
|
*/
|
||||||
static inline void touch_ll_filter_get_jitter_step(uint32_t *step)
|
static inline void touch_ll_filter_get_jitter_step(uint32_t *step)
|
||||||
{
|
{
|
||||||
|
@ -1004,11 +930,11 @@ static inline void touch_ll_waterproof_get_sheild_driver(touch_pad_shield_driver
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable parameter of waterproof function.
|
* Enable parameter of waterproof function.
|
||||||
|
*
|
||||||
* The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel.
|
* 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.
|
* 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.
|
|
||||||
*/
|
*/
|
||||||
static inline void touch_ll_waterproof_enable(void)
|
static inline void touch_ll_waterproof_enable(void)
|
||||||
{
|
{
|
||||||
|
@ -1017,11 +943,6 @@ static inline void touch_ll_waterproof_enable(void)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable parameter of waterproof function.
|
* Disable 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.
|
|
||||||
*/
|
*/
|
||||||
static inline void touch_ll_waterproof_disable(void)
|
static inline void touch_ll_waterproof_disable(void)
|
||||||
{
|
{
|
||||||
|
@ -1135,7 +1056,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.
|
* Set the trigger threshold of touch sensor in deep sleep.
|
||||||
* The threshold determines the sensitivity of the 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 In general, the touch threshold during sleep can use the threshold parameter parameters before sleep.
|
* @note In general, the touch threshold during sleep can use the threshold parameter parameters before sleep.
|
||||||
*/
|
*/
|
||||||
|
@ -1147,7 +1068,7 @@ static inline void touch_ll_sleep_set_threshold(uint32_t touch_thres)
|
||||||
/**
|
/**
|
||||||
* Get the trigger threshold of touch sensor in deep sleep.
|
* Get the trigger threshold of touch sensor in deep sleep.
|
||||||
* The threshold determines the sensitivity of the 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 In general, the touch threshold during sleep can use the threshold parameter parameters before sleep.
|
* @note In general, the touch threshold during sleep can use the threshold parameter parameters before sleep.
|
||||||
*/
|
*/
|
||||||
|
@ -1181,14 +1102,14 @@ static inline bool touch_ll_sleep_get_approach_status(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)
|
||||||
{
|
{
|
||||||
SENS.sar_touch_conf.touch_data_sel = TOUCH_LL_READ_BASELINE;
|
SENS.sar_touch_conf.touch_data_sel = TOUCH_LL_READ_BENCHMARK;
|
||||||
*baseline = SENS.sar_touch_slp_status.touch_slp_data;
|
*benchmark = SENS.sar_touch_slp_status.touch_slp_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void touch_ll_sleep_read_smooth(uint32_t *smooth_data)
|
static inline void touch_ll_sleep_read_smooth(uint32_t *smooth_data)
|
||||||
|
@ -1205,7 +1126,7 @@ static inline void touch_ll_sleep_read_data(uint32_t *raw_data)
|
||||||
*raw_data = SENS.sar_touch_status[touch_num - 1].touch_pad_data;
|
*raw_data = SENS.sar_touch_status[touch_num - 1].touch_pad_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void touch_ll_sleep_reset_baseline(void)
|
static inline void touch_ll_sleep_reset_benchmark(void)
|
||||||
{
|
{
|
||||||
RTCCNTL.touch_approach.touch_slp_channel_clr = 1;
|
RTCCNTL.touch_approach.touch_slp_channel_clr = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,17 +28,17 @@ void touch_hal_init(void)
|
||||||
touch_ll_set_voltage_low(TOUCH_PAD_LOW_VOLTAGE_THRESHOLD);
|
touch_ll_set_voltage_low(TOUCH_PAD_LOW_VOLTAGE_THRESHOLD);
|
||||||
touch_ll_set_voltage_attenuation(TOUCH_PAD_ATTEN_VOLTAGE_THRESHOLD);
|
touch_ll_set_voltage_attenuation(TOUCH_PAD_ATTEN_VOLTAGE_THRESHOLD);
|
||||||
touch_ll_set_idle_channel_connect(TOUCH_PAD_IDLE_CH_CONNECT_DEFAULT);
|
touch_ll_set_idle_channel_connect(TOUCH_PAD_IDLE_CH_CONNECT_DEFAULT);
|
||||||
/* Clear touch channels to initialize the channel value (baseline, raw_data).
|
/* Clear touch channels to initialize the channel value (benchmark, raw_data).
|
||||||
* Note: Should call it after enable clock gate. */
|
* Note: Should call it after enable clock gate. */
|
||||||
touch_ll_clkgate(true); // Enable clock gate for touch sensor.
|
touch_ll_clkgate(true); // Enable clock gate for touch sensor.
|
||||||
touch_ll_filter_reset_baseline(TOUCH_PAD_MAX);
|
touch_ll_reset_benchmark(TOUCH_PAD_MAX);
|
||||||
touch_ll_sleep_reset_baseline();
|
touch_ll_sleep_reset_benchmark();
|
||||||
}
|
}
|
||||||
|
|
||||||
void touch_hal_deinit(void)
|
void touch_hal_deinit(void)
|
||||||
{
|
{
|
||||||
touch_ll_filter_reset_baseline(TOUCH_PAD_MAX);
|
touch_ll_reset_benchmark(TOUCH_PAD_MAX);
|
||||||
touch_ll_sleep_reset_baseline();
|
touch_ll_sleep_reset_benchmark();
|
||||||
touch_ll_stop_fsm();
|
touch_ll_stop_fsm();
|
||||||
touch_ll_clkgate(false);
|
touch_ll_clkgate(false);
|
||||||
touch_ll_clear_channel_mask(SOC_TOUCH_SENSOR_BIT_MASK_MAX);
|
touch_ll_clear_channel_mask(SOC_TOUCH_SENSOR_BIT_MASK_MAX);
|
||||||
|
@ -58,10 +58,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_filter_mode(filter_info->mode);
|
||||||
touch_ll_filter_set_debounce(filter_info->debounce_cnt);
|
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_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);
|
touch_ll_filter_set_jitter_step(filter_info->jitter_step);
|
||||||
touch_ll_filter_set_smooth_mode(filter_info->smh_lvl);
|
touch_ll_filter_set_smooth_mode(filter_info->smh_lvl);
|
||||||
}
|
}
|
||||||
|
@ -70,10 +67,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_filter_mode(&filter_info->mode);
|
||||||
touch_ll_filter_get_debounce(&filter_info->debounce_cnt);
|
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_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);
|
touch_ll_filter_get_jitter_step(&filter_info->jitter_step);
|
||||||
touch_ll_filter_get_smooth_mode(&filter_info->smh_lvl);
|
touch_ll_filter_get_smooth_mode(&filter_info->smh_lvl);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +143,7 @@ void touch_hal_sleep_channel_enable(touch_pad_t pad_num, bool enable)
|
||||||
/* Default change touch dbias to self-dbias to save power.
|
/* Default change touch dbias to self-dbias to save power.
|
||||||
Measuring the sleep pad threshold after `sleep_channel_set_config`. */
|
Measuring the sleep pad threshold after `sleep_channel_set_config`. */
|
||||||
touch_ll_sleep_low_power(true);
|
touch_ll_sleep_low_power(true);
|
||||||
touch_ll_sleep_reset_baseline();
|
touch_ll_sleep_reset_benchmark();
|
||||||
} else {
|
} else {
|
||||||
touch_ll_sleep_set_channel_num(TOUCH_PAD_NUM0);
|
touch_ll_sleep_set_channel_num(TOUCH_PAD_NUM0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,8 @@ static const touch_pad_t button[TOUCH_BUTTON_NUM] = {
|
||||||
/*
|
/*
|
||||||
* Touch threshold. The threshold determines the sensitivity of the touch.
|
* Touch threshold. The threshold determines the sensitivity of the touch.
|
||||||
* This threshold is derived by testing changes in readings from different touch channels.
|
* This threshold is derived by testing changes in readings from different touch channels.
|
||||||
* If (raw_data - baseline) > baseline * threshold, the pad be activated.
|
* If (raw_data - benchmark) > benchmark * threshold, the pad be activated.
|
||||||
* If (raw_data - baseline) < baseline * threshold, the pad be inactivated.
|
* If (raw_data - benchmark) < benchmark * threshold, the pad be inactivated.
|
||||||
*/
|
*/
|
||||||
static const float button_threshold[TOUCH_BUTTON_NUM] = {
|
static const float button_threshold[TOUCH_BUTTON_NUM] = {
|
||||||
0.2, // 20%.
|
0.2, // 20%.
|
||||||
|
@ -74,8 +74,8 @@ static void tp_example_set_thresholds(void)
|
||||||
{
|
{
|
||||||
uint32_t touch_value;
|
uint32_t touch_value;
|
||||||
for (int i = 0; i < TOUCH_BUTTON_NUM; i++) {
|
for (int i = 0; i < TOUCH_BUTTON_NUM; i++) {
|
||||||
//read baseline value
|
//read benchmark value
|
||||||
touch_pad_filter_read_baseline(button[i], &touch_value);
|
touch_pad_read_benchmark(button[i], &touch_value);
|
||||||
//set interrupt threshold.
|
//set interrupt threshold.
|
||||||
touch_pad_set_thresh(button[i], touch_value * button_threshold[i]);
|
touch_pad_set_thresh(button[i], touch_value * button_threshold[i]);
|
||||||
ESP_LOGI(TAG, "touch pad [%d] base %d, thresh %d", \
|
ESP_LOGI(TAG, "touch pad [%d] base %d, thresh %d", \
|
||||||
|
@ -89,10 +89,7 @@ static void touchsensor_filter_set(touch_filter_mode_t mode)
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = mode, // Test jitter and filter 1/4.
|
.mode = mode, // Test jitter and filter 1/4.
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 3, // 3%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
||||||
};
|
};
|
||||||
|
|
|
@ -190,10 +190,7 @@ void app_main(void)
|
||||||
touch_filter_config_t filter_info = {
|
touch_filter_config_t filter_info = {
|
||||||
.mode = TOUCH_PAD_FILTER_IIR_16,
|
.mode = TOUCH_PAD_FILTER_IIR_16,
|
||||||
.debounce_cnt = 1, // 1 time count.
|
.debounce_cnt = 1, // 1 time count.
|
||||||
.hysteresis_thr = 3, // 3%
|
|
||||||
.noise_thr = 0, // 50%
|
.noise_thr = 0, // 50%
|
||||||
.noise_neg_thr = 0, // 50%
|
|
||||||
.neg_noise_limit = 10, // 10 time count.
|
|
||||||
.jitter_step = 4, // use for jitter mode.
|
.jitter_step = 4, // use for jitter mode.
|
||||||
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
|
||||||
};
|
};
|
||||||
|
|
Ładowanie…
Reference in New Issue