Skip to content

Commit 395a51b

Browse files
committed
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!9273
2 parents 2bfd725 + 1568b69 commit 395a51b

File tree

16 files changed

+248
-468
lines changed

16 files changed

+248
-468
lines changed

components/driver/esp32s2/include/driver/touch_sensor.h

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extern "C" {
2222
/**
2323
* @brief Set touch sensor FSM start
2424
* @note Start FSM after the touch sensor FSM mode is set.
25-
* @note Call this function will reset baseline of all touch channels.
25+
* @note Call this function will reset benchmark of all touch channels.
2626
* @return
2727
* - ESP_OK on success
2828
*/
@@ -98,7 +98,7 @@ esp_err_t touch_pad_get_idle_channel_connect(touch_pad_conn_type_t *type);
9898
/**
9999
* @brief Set the trigger threshold of touch sensor.
100100
* The threshold determines the sensitivity of the touch sensor.
101-
* The threshold is the original value of the trigger state minus the baseline value.
101+
* The threshold is the original value of the trigger state minus the benchmark value.
102102
* @note If set "TOUCH_PAD_THRESHOLD_MAX", the touch is never be triggered.
103103
* @param touch_num touch pad index
104104
* @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);
264264
esp_err_t touch_pad_read_raw_data(touch_pad_t touch_num, uint32_t *raw_data);
265265

266266
/**
267-
* @brief get baseline of touch sensor.
268-
* @note After initialization, the baseline value is the maximum during the first measurement period.
267+
* @brief get benchmark of touch sensor.
268+
* @note After initialization, the benchmark value is the maximum during the first measurement period.
269269
* @param touch_num touch pad index
270-
* @param basedata pointer to accept touch sensor baseline value
270+
* @param benchmark pointer to accept touch sensor benchmark value
271271
* @return
272272
* - ESP_OK Success
273273
* - ESP_ERR_INVALID_ARG Touch channel 0 haven't this parameter.
274274
*/
275-
esp_err_t touch_pad_filter_read_baseline(touch_pad_t touch_num, uint32_t *basedata);
275+
esp_err_t touch_pad_read_benchmark(touch_pad_t touch_num, uint32_t *benchmark);
276276

277277
/**
278278
* @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
283283
esp_err_t touch_pad_filter_read_smooth(touch_pad_t touch_num, uint32_t *smooth);
284284

285285
/**
286-
* @brief Force reset baseline to raw data of touch sensor.
286+
* @brief Force reset benchmark to raw data of touch sensor.
287287
* @param touch_num touch pad index
288288
* - TOUCH_PAD_MAX Reset basaline of all channels
289289
* @return
290290
* - ESP_OK Success
291291
*/
292-
esp_err_t touch_pad_filter_reset_baseline(touch_pad_t touch_num);
292+
esp_err_t touch_pad_reset_benchmark(touch_pad_t touch_num);
293293

294294
/**
295295
* @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);
375375

376376
/**
377377
* @brief set parameter of waterproof function.
378+
*
378379
* The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel.
379-
* The shielded channel outputs the same signal as the channel being measured.
380+
* Guard pad is used to detect the large area of water covering the touch panel.
381+
* Shield pad is used to shield the influence of water droplets covering the touch panel.
380382
* It is generally designed as a grid and is placed around the touch buttons.
381-
* The shielded channel does not follow the measurement signal of the protection channel.
382-
* So that the guard channel can detect a large area of water.
383+
*
383384
* @param waterproof parameter of waterproof
384385
* @return
385386
* - ESP_OK Success
@@ -396,23 +397,14 @@ esp_err_t touch_pad_waterproof_get_config(touch_pad_waterproof_t *waterproof);
396397

397398
/**
398399
* @brief Enable parameter of waterproof function.
399-
* The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel.
400-
* The shielded channel outputs the same signal as the channel being measured.
401-
* It is generally designed as a grid and is placed around the touch buttons.
402-
* The shielded channel does not follow the measurement signal of the protection channel.
403-
* So that the guard channel can detect a large area of water.
400+
* Should be called after function ``touch_pad_waterproof_set_config``.
404401
* @return
405402
* - ESP_OK Success
406403
*/
407404
esp_err_t touch_pad_waterproof_enable(void);
408405

409406
/**
410-
* @brief Enable parameter of waterproof function.
411-
* The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel.
412-
* The shielded channel outputs the same signal as the channel being measured.
413-
* It is generally designed as a grid and is placed around the touch buttons.
414-
* The shielded channel does not follow the measurement signal of the protection channel.
415-
* So that the guard channel can detect a large area of water.
407+
* @brief Disable parameter of waterproof function.
416408
* @return
417409
* - ESP_OK Success
418410
*/
@@ -537,14 +529,14 @@ esp_err_t touch_pad_sleep_set_threshold(touch_pad_t pad_num, uint32_t touch_thre
537529
esp_err_t touch_pad_sleep_get_threshold(touch_pad_t pad_num, uint32_t *touch_thres);
538530

539531
/**
540-
* @brief Read baseline of touch sensor sleep channel.
532+
* @brief Read benchmark of touch sensor sleep channel.
541533
* @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode.
542-
* @param baseline pointer to accept touch sensor baseline value
534+
* @param benchmark pointer to accept touch sensor benchmark value
543535
* @return
544536
* - ESP_OK Success
545537
* - ESP_ERR_INVALID_ARG parameter is NULL
546538
*/
547-
esp_err_t touch_pad_sleep_channel_read_baseline(touch_pad_t pad_num, uint32_t *baseline);
539+
esp_err_t touch_pad_sleep_channel_read_benchmark(touch_pad_t pad_num, uint32_t *benchmark);
548540

549541
/**
550542
* @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
568560
esp_err_t touch_pad_sleep_channel_read_data(touch_pad_t pad_num, uint32_t *raw_data);
569561

570562
/**
571-
* @brief Reset baseline of touch sensor sleep channel.
563+
* @brief Reset benchmark of touch sensor sleep channel.
572564
*
573565
* @return
574566
* - ESP_OK Success
575567
*/
576-
esp_err_t touch_pad_sleep_channel_reset_baseline(void);
568+
esp_err_t touch_pad_sleep_channel_reset_benchmark(void);
577569

578570
/**
579571
* @brief Read proximity count of touch sensor sleep channel.

components/driver/esp32s2/touch_sensor.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -322,21 +322,21 @@ esp_err_t IRAM_ATTR touch_pad_filter_read_smooth(touch_pad_t touch_num, uint32_t
322322
return ESP_OK;
323323
}
324324

325-
esp_err_t IRAM_ATTR touch_pad_filter_read_baseline(touch_pad_t touch_num, uint32_t *basedata)
325+
esp_err_t IRAM_ATTR touch_pad_read_benchmark(touch_pad_t touch_num, uint32_t *benchmark)
326326
{
327327
TOUCH_CHANNEL_CHECK(touch_num);
328328
TOUCH_ENTER_CRITICAL_SAFE();
329-
touch_hal_filter_read_baseline(touch_num, basedata);
329+
touch_hal_read_benchmark(touch_num, benchmark);
330330
TOUCH_EXIT_CRITICAL_SAFE();
331331
return ESP_OK;
332332
}
333333

334334
/* Should be call after clk enable and filter enable. */
335-
esp_err_t touch_pad_filter_reset_baseline(touch_pad_t touch_num)
335+
esp_err_t touch_pad_reset_benchmark(touch_pad_t touch_num)
336336
{
337337
TOUCH_CHECK(touch_num <= TOUCH_PAD_MAX && touch_num >= 0, "Touch channel error", ESP_ERR_INVALID_ARG);
338338
TOUCH_ENTER_CRITICAL();
339-
touch_hal_filter_reset_baseline(touch_num);
339+
touch_hal_reset_benchmark(touch_num);
340340
TOUCH_EXIT_CRITICAL();
341341
return ESP_OK;
342342
}
@@ -345,10 +345,7 @@ esp_err_t touch_pad_filter_set_config(touch_filter_config_t *filter_info)
345345
{
346346
TOUCH_CHECK(filter_info->mode < TOUCH_PAD_FILTER_MAX, TOUCH_PARAM_CHECK_STR("mode"), ESP_ERR_INVALID_ARG);
347347
TOUCH_CHECK(filter_info->debounce_cnt <= TOUCH_DEBOUNCE_CNT_MAX, TOUCH_PARAM_CHECK_STR("debounce"), ESP_ERR_INVALID_ARG);
348-
TOUCH_CHECK(filter_info->hysteresis_thr <= TOUCH_HYSTERESIS_THR_MAX, TOUCH_PARAM_CHECK_STR("hysteresis"), ESP_ERR_INVALID_ARG);
349348
TOUCH_CHECK(filter_info->noise_thr <= TOUCH_NOISE_THR_MAX, TOUCH_PARAM_CHECK_STR("noise"), ESP_ERR_INVALID_ARG);
350-
TOUCH_CHECK(filter_info->noise_neg_thr <= TOUCH_NOISE_NEG_THR_MAX, TOUCH_PARAM_CHECK_STR("noise"), ESP_ERR_INVALID_ARG);
351-
TOUCH_CHECK(filter_info->neg_noise_limit <= TOUCH_NEG_NOISE_CNT_LIMIT, TOUCH_PARAM_CHECK_STR("noise_limit"), ESP_ERR_INVALID_ARG);
352349
TOUCH_CHECK(filter_info->jitter_step <= TOUCH_JITTER_STEP_MAX, TOUCH_PARAM_CHECK_STR("jitter_step"), ESP_ERR_INVALID_ARG);
353350
TOUCH_CHECK(filter_info->smh_lvl < TOUCH_PAD_SMOOTH_MAX, TOUCH_PARAM_CHECK_STR("smooth level"), ESP_ERR_INVALID_ARG);
354351

@@ -522,7 +519,7 @@ esp_err_t touch_pad_proximity_get_data(touch_pad_t touch_num, uint32_t *measure_
522519
{
523520
TOUCH_CHECK(touch_hal_proximity_pad_check(touch_num), "touch num is not proximity", ESP_ERR_INVALID_ARG);
524521
TOUCH_ENTER_CRITICAL_SAFE();
525-
touch_hal_filter_read_baseline(touch_num, measure_out);
522+
touch_hal_read_benchmark(touch_num, measure_out);
526523
TOUCH_EXIT_CRITICAL_SAFE();
527524
return ESP_OK;
528525
}
@@ -585,10 +582,10 @@ esp_err_t touch_pad_sleep_get_threshold(touch_pad_t pad_num, uint32_t *touch_thr
585582
return ESP_OK;
586583
}
587584

588-
esp_err_t touch_pad_sleep_channel_read_baseline(touch_pad_t pad_num, uint32_t *baseline)
585+
esp_err_t touch_pad_sleep_channel_read_benchmark(touch_pad_t pad_num, uint32_t *benchmark)
589586
{
590587
TOUCH_ENTER_CRITICAL_SAFE();
591-
touch_hal_sleep_read_baseline(baseline);
588+
touch_hal_sleep_read_benchmark(benchmark);
592589
TOUCH_EXIT_CRITICAL_SAFE();
593590
return ESP_OK;
594591
}
@@ -609,10 +606,10 @@ esp_err_t touch_pad_sleep_channel_read_data(touch_pad_t pad_num, uint32_t *raw_d
609606
return ESP_OK;
610607
}
611608

612-
esp_err_t touch_pad_sleep_channel_reset_baseline(void)
609+
esp_err_t touch_pad_sleep_channel_reset_benchmark(void)
613610
{
614611
TOUCH_ENTER_CRITICAL();
615-
touch_hal_sleep_reset_baseline();
612+
touch_hal_sleep_reset_benchmark();
616613
TOUCH_EXIT_CRITICAL();
617614
return ESP_OK;
618615
}

0 commit comments

Comments
 (0)