touch_sensor_hal.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /*******************************************************************************
  7. * NOTICE
  8. * The hal is not public api, don't use in application code.
  9. * See readme.md in hal/include/hal/readme.md
  10. ******************************************************************************/
  11. // The HAL layer for touch sensor (ESP32-S3 specific part)
  12. #pragma once
  13. #include "hal/touch_sensor_ll.h"
  14. #include "hal/touch_sensor_types.h"
  15. #include_next "hal/touch_sensor_hal.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /**
  20. * Reset the whole of touch module.
  21. *
  22. * @note Call this funtion after `touch_pad_fsm_stop`,
  23. */
  24. #define touch_hal_reset() touch_ll_reset()
  25. /**
  26. * Set touch sensor measurement time.
  27. *
  28. * @param meas_time The duration of the touch sensor measurement.
  29. * t_meas = meas_time / (8MHz), the maximum measure time is 0xffff / 8M = 8.19 ms.
  30. */
  31. #define touch_hal_set_meas_times(meas_time) touch_ll_set_meas_times(meas_time)
  32. /**
  33. * Get touch sensor times of charge and discharge.
  34. *
  35. * @param meas_times Pointer to accept times count of charge and discharge.
  36. */
  37. #define touch_hal_get_measure_times(meas_time) touch_ll_get_measure_times(meas_time)
  38. /**
  39. * Set connection type of touch channel in idle status.
  40. * When a channel is in measurement mode, other initialized channels are in idle mode.
  41. * The touch channel is generally adjacent to the trace, so the connection state of the idle channel
  42. * affects the stability and sensitivity of the test channel.
  43. * The `CONN_HIGHZ`(high resistance) setting increases the sensitivity of touch channels.
  44. * The `CONN_GND`(grounding) setting increases the stability of touch channels.
  45. *
  46. * @param type Select idle channel connect to high resistance state or ground.
  47. */
  48. #define touch_hal_set_idle_channel_connect(type) touch_ll_set_idle_channel_connect(type)
  49. /**
  50. * Set connection type of touch channel in idle status.
  51. * When a channel is in measurement mode, other initialized channels are in idle mode.
  52. * The touch channel is generally adjacent to the trace, so the connection state of the idle channel
  53. * affects the stability and sensitivity of the test channel.
  54. * The `CONN_HIGHZ`(high resistance) setting increases the sensitivity of touch channels.
  55. * The `CONN_GND`(grounding) setting increases the stability of touch channels.
  56. *
  57. * @param type Select idle channel connect to high resistance state or ground.
  58. */
  59. #define touch_hal_get_idle_channel_connect(type) touch_ll_get_idle_channel_connect(type)
  60. /**
  61. * Get the current measure channel. Touch sensor measurement is cyclic scan mode.
  62. *
  63. * @return
  64. * - touch channel number
  65. */
  66. #define touch_hal_get_current_meas_channel() touch_ll_get_current_meas_channel()
  67. /**
  68. * Enable touch sensor interrupt by bitmask.
  69. *
  70. * @param type interrupt type
  71. */
  72. #define touch_hal_intr_enable(int_mask) touch_ll_intr_enable(int_mask)
  73. /**
  74. * Disable touch sensor interrupt by bitmask.
  75. *
  76. * @param type interrupt type
  77. */
  78. #define touch_hal_intr_disable(int_mask) touch_ll_intr_disable(int_mask)
  79. /**
  80. * Clear touch sensor interrupt by bitmask.
  81. *
  82. * @param int_mask Pad mask to clear interrupts
  83. */
  84. #define touch_hal_intr_clear(int_mask) touch_ll_intr_clear(int_mask)
  85. /**
  86. * Get the bitmask of touch sensor interrupt status.
  87. *
  88. * @return type interrupt type
  89. */
  90. #define touch_hal_read_intr_status_mask() touch_ll_read_intr_status_mask()
  91. /**
  92. * Enable the timeout check for all touch sensor channels measurements.
  93. * When the touch reading of a touch channel exceeds the measurement threshold,
  94. * If enable: a timeout interrupt will be generated and it will go to the next channel measurement.
  95. * If disable: the FSM is always on the channel, until the measurement of this channel is over.
  96. *
  97. * @note Set the timeout threshold correctly before enabling it.
  98. */
  99. #define touch_hal_timeout_enable() touch_ll_timeout_enable()
  100. /**
  101. * Disable the timeout check for all touch sensor channels measurements.
  102. * When the touch reading of a touch channel exceeds the measurement threshold,
  103. * If enable: a timeout interrupt will be generated and it will go to the next channel measurement.
  104. * If disable: the FSM is always on the channel, until the measurement of this channel is over.
  105. *
  106. * @note Set the timeout threshold correctly before enabling it.
  107. */
  108. #define touch_hal_timeout_disable() touch_ll_timeout_disable()
  109. /**
  110. * Set timeout threshold for all touch sensor channels measurements.
  111. * Compared with touch readings.
  112. *
  113. * @param threshold Set to the maximum time measured on one channel.
  114. */
  115. #define touch_hal_timeout_set_threshold(threshold) touch_ll_timeout_set_threshold(threshold)
  116. /**
  117. * Get timeout threshold for all touch sensor channels measurements.
  118. * Compared with touch readings.
  119. *
  120. * @param threshold Point to timeout threshold.
  121. */
  122. #define touch_hal_timeout_get_threshold(threshold) touch_ll_timeout_get_threshold(threshold)
  123. /**
  124. * Touch timer trigger measurement and always wait measurement done.
  125. * Force done for touch timer ensures that the timer always can get the measurement done signal.
  126. */
  127. #define touch_hal_timer_force_done() touch_ll_timer_force_done()
  128. /************************ Filter register setting ************************/
  129. /**
  130. * Set parameter of touch sensor filter and detection algorithm.
  131. * For more details on the detection algorithm, please refer to the application documentation.
  132. *
  133. * @param filter_info select filter type and threshold of detection algorithm
  134. */
  135. void touch_hal_filter_set_config(const touch_filter_config_t *filter_info);
  136. /**
  137. * Get parameter of touch sensor filter and detection algorithm.
  138. * For more details on the detection algorithm, please refer to the application documentation.
  139. *
  140. * @param filter_info select filter type and threshold of detection algorithm
  141. */
  142. void touch_hal_filter_get_config(touch_filter_config_t *filter_info);
  143. /**
  144. * Get smoothed data that obtained by filtering the raw data.
  145. *
  146. * @param touch_num touch pad index
  147. * @param smooth_data pointer to smoothed data
  148. */
  149. #define touch_hal_filter_read_smooth(touch_num, smooth_data) touch_ll_filter_read_smooth(touch_num, smooth_data)
  150. /**
  151. * Get benchmark value of touch sensor.
  152. *
  153. * @note After initialization, the benchmark value is the maximum during the first measurement period.
  154. * @param touch_num touch pad index
  155. * @param touch_value pointer to accept touch sensor value
  156. */
  157. #define touch_hal_read_benchmark(touch_num, benchmark) touch_ll_read_benchmark(touch_num, benchmark)
  158. /**
  159. * Force reset benchmark to raw data of touch sensor.
  160. *
  161. * @param touch_num touch pad index
  162. * - TOUCH_PAD_MAX Reset basaline of all channels.
  163. */
  164. #define touch_hal_reset_benchmark(touch_num) touch_ll_reset_benchmark(touch_num)
  165. /**
  166. * Set filter mode. The input of the filter is the raw value of touch reading,
  167. * and the output of the filter is involved in the judgment of the touch state.
  168. *
  169. * @param mode Filter mode type. Refer to ``touch_filter_mode_t``.
  170. */
  171. #define touch_hal_filter_set_filter_mode(mode) touch_ll_filter_set_filter_mode(mode)
  172. /**
  173. * Get filter mode. The input of the filter is the raw value of touch reading,
  174. * and the output of the filter is involved in the judgment of the touch state.
  175. *
  176. * @param mode Filter mode type. Refer to ``touch_filter_mode_t``.
  177. */
  178. #define touch_hal_filter_get_filter_mode(mode) touch_ll_filter_get_filter_mode(mode)
  179. /**
  180. * Set debounce count, such as `n`. If the measured values continue to exceed
  181. * the threshold for `n` times, it is determined that the touch sensor state changes.
  182. *
  183. * @param dbc_cnt Debounce count value.
  184. */
  185. #define touch_hal_filter_set_debounce(dbc_cnt) touch_ll_filter_set_debounce(dbc_cnt)
  186. /**
  187. * Get debounce count.
  188. *
  189. * @param dbc_cnt Debounce count value.
  190. */
  191. #define touch_hal_filter_get_debounce(dbc_cnt) touch_ll_filter_get_debounce(dbc_cnt)
  192. /**
  193. * Set noise threshold coefficient. Higher = More noise resistance.
  194. * The actual noise should be less than (noise coefficient * touch threshold).
  195. * Range: 0 ~ 3. The coefficient is 0: 4/8; 1: 3/8; 2: 2/8; 3: 1;
  196. *
  197. * @param hys_thr Noise threshold coefficient.
  198. */
  199. #define touch_hal_filter_set_noise_thres(noise_thr) touch_ll_filter_set_noise_thres(noise_thr)
  200. /**
  201. * Get noise threshold coefficient. Higher = More noise resistance.
  202. * The actual noise should be less than (noise coefficient * touch threshold).
  203. * Range: 0 ~ 3. The coefficient is 0: 4/8; 1: 3/8; 2: 2/8; 3: 1;
  204. *
  205. * @param noise_thr Noise threshold coefficient.
  206. */
  207. #define touch_hal_filter_get_noise_thres(noise_thr) touch_ll_filter_get_noise_thres(noise_thr)
  208. /**
  209. * Set the cumulative number of benchmark reset processes. such as `n`. If the measured values continue to exceed
  210. * the negative noise threshold for `n` times, the benchmark reset to raw data.
  211. * Range: 0 ~ 15
  212. *
  213. * @param reset_cnt The cumulative number of benchmark reset processes.
  214. */
  215. #define touch_hal_filter_set_benchmark_reset(reset_cnt) touch_ll_filter_set_benchmark_reset(reset_cnt)
  216. /**
  217. * Get the cumulative number of benchmark reset processes. such as `n`. If the measured values continue to exceed
  218. * the negative noise threshold for `n` times, the benchmark reset to raw data.
  219. * Range: 0 ~ 15
  220. *
  221. * @param reset_cnt The cumulative number of benchmark reset processes.
  222. */
  223. #define touch_hal_filter_get_benchmark_reset(reset_cnt) touch_ll_filter_get_benchmark_reset(reset_cnt)
  224. /**
  225. * Set jitter filter step size.
  226. * If filter mode is jitter, should set filter step for jitter.
  227. * Range: 0 ~ 15
  228. *
  229. * @param step The step size of the data change.
  230. */
  231. #define touch_hal_filter_set_jitter_step(step) touch_ll_filter_set_jitter_step(step)
  232. /**
  233. * Get jitter filter step size.
  234. * If filter mode is jitter, should set filter step for jitter.
  235. * Range: 0 ~ 15
  236. *
  237. * @param step The step size of the data change.
  238. */
  239. #define touch_hal_filter_get_jitter_step(step) touch_ll_filter_get_jitter_step(step)
  240. /**
  241. * Enable touch sensor filter and detection algorithm.
  242. * For more details on the detection algorithm, please refer to the application documentation.
  243. */
  244. #define touch_hal_filter_enable() touch_ll_filter_enable()
  245. /**
  246. * Disable touch sensor filter and detection algorithm.
  247. * For more details on the detection algorithm, please refer to the application documentation.
  248. */
  249. #define touch_hal_filter_disable() touch_ll_filter_disable()
  250. /************************ Denoise register setting ************************/
  251. /**
  252. * set parameter of denoise pad (TOUCH_PAD_NUM0).
  253. * T0 is an internal channel that does not have a corresponding external GPIO.
  254. * T0 will work simultaneously with the measured channel Tn. Finally, the actual
  255. * measured value of Tn is the value after subtracting lower bits of T0.
  256. * This denoise function filters out interference introduced on all channels,
  257. * such as noise introduced by the power supply and external EMI.
  258. *
  259. * @param denoise parameter of denoise
  260. */
  261. void touch_hal_denoise_set_config(const touch_pad_denoise_t *denoise);
  262. /**
  263. * @brief get parameter of denoise pad (TOUCH_PAD_NUM0).
  264. *
  265. * @param denoise Pointer to parameter of denoise
  266. */
  267. void touch_hal_denoise_get_config(touch_pad_denoise_t *denoise);
  268. /**
  269. * Enable denoise function.
  270. * T0 is an internal channel that does not have a corresponding external GPIO.
  271. * T0 will work simultaneously with the measured channel Tn. Finally, the actual
  272. * measured value of Tn is the value after subtracting lower bits of T0.
  273. * This denoise function filters out interference introduced on all channels,
  274. * such as noise introduced by the power supply and external EMI.
  275. */
  276. void touch_hal_denoise_enable(void);
  277. /**
  278. * Enable denoise function.
  279. * T0 is an internal channel that does not have a corresponding external GPIO.
  280. * T0 will work simultaneously with the measured channel Tn. Finally, the actual
  281. * measured value of Tn is the value after subtracting lower bits of T0.
  282. * This denoise function filters out interference introduced on all channels,
  283. * such as noise introduced by the power supply and external EMI.
  284. */
  285. #define touch_hal_denoise_disable() touch_ll_denoise_disable()
  286. /**
  287. * Set internal reference capacitance of denoise channel.
  288. * Select the appropriate internal reference capacitance value so that
  289. * the reading of denoise channel is closest to the reading of the channel being measured.
  290. *
  291. * @param cap_level Capacitance level.
  292. */
  293. #define touch_hal_denoise_set_cap_level(cap_level) touch_ll_denoise_set_cap_level(cap_level)
  294. /**
  295. * Get internal reference capacitance of denoise channel.
  296. * Select the appropriate internal reference capacitance value so that
  297. * the reading of denoise channel is closest to the reading of the channel being measured.
  298. *
  299. * @param cap_level Capacitance level.
  300. */
  301. #define touch_hal_denoise_get_cap_level(cap_level) touch_ll_denoise_get_cap_level(cap_level)
  302. /**
  303. * Set denoise range of denoise channel.
  304. * Determined by measuring the noise amplitude of the denoise channel.
  305. *
  306. * @param grade Denoise range of denoise channel.
  307. */
  308. #define touch_hal_denoise_set_grade(grade) touch_ll_denoise_set_grade(grade)
  309. /**
  310. * Set denoise range of denoise channel.
  311. * Determined by measuring the noise amplitude of the denoise channel.
  312. *
  313. * @param grade Denoise range of denoise channel.
  314. */
  315. #define touch_hal_denoise_get_grade(grade) touch_ll_denoise_get_grade(grade)
  316. /**
  317. * Read denoise measure value (TOUCH_PAD_NUM0).
  318. *
  319. * @param denoise value of denoise.
  320. */
  321. #define touch_hal_denoise_read_data(data) touch_ll_denoise_read_data(data)
  322. /************************ Waterproof register setting ************************/
  323. /**
  324. * Set touch channel use for guard pad.
  325. *
  326. * @param pad_num Touch sensor channel number.
  327. */
  328. #define touch_hal_waterproof_set_guard_pad(pad_num) touch_ll_waterproof_set_guard_pad(pad_num)
  329. /**
  330. * Get touch channel use for guard pad.
  331. *
  332. * @param pad_num Touch sensor channel number.
  333. */
  334. #define touch_hal_waterproof_get_guard_pad(pad_num) touch_ll_waterproof_get_guard_pad(pad_num)
  335. /**
  336. * Set max equivalent capacitance for sheild channel.
  337. * The equivalent capacitance of the shielded channel can be calculated
  338. * from the reading of denoise channel.
  339. *
  340. * @param pad_num Touch sensor channel number.
  341. */
  342. #define touch_hal_waterproof_set_sheild_driver(driver_level) touch_ll_waterproof_set_sheild_driver(driver_level)
  343. /**
  344. * Get max equivalent capacitance for sheild channel.
  345. * The equivalent capacitance of the shielded channel can be calculated
  346. * from the reading of denoise channel.
  347. *
  348. * @param pad_num Touch sensor channel number.
  349. */
  350. #define touch_hal_waterproof_get_sheild_driver(driver_level) touch_ll_waterproof_get_sheild_driver(driver_level)
  351. /**
  352. * Set parameter of waterproof function.
  353. *
  354. * The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel.
  355. * Guard pad is used to detect the large area of water covering the touch panel.
  356. * Shield pad is used to shield the influence of water droplets covering the touch panel.
  357. * It is generally designed as a grid and is placed around the touch buttons.
  358. *
  359. * @param waterproof parameter of waterproof
  360. */
  361. void touch_hal_waterproof_set_config(const touch_pad_waterproof_t *waterproof);
  362. /**
  363. * Get parameter of waterproof function.
  364. *
  365. * @param waterproof parameter of waterproof.
  366. */
  367. void touch_hal_waterproof_get_config(touch_pad_waterproof_t *waterproof);
  368. /**
  369. * Enable parameter of waterproof function.
  370. * Should be called after function ``touch_hal_waterproof_set_config``.
  371. */
  372. void touch_hal_waterproof_enable(void);
  373. /**
  374. * Disable parameter of waterproof function.
  375. */
  376. #define touch_hal_waterproof_disable() touch_ll_waterproof_disable()
  377. /************************ Proximity register setting ************************/
  378. /**
  379. * Enable/disable proximity function of touch channels.
  380. * The proximity sensor measurement is the accumulation of touch channel measurements.
  381. *
  382. * @note Supports up to three touch channels configured as proximity sensors.
  383. * @param touch_num touch pad index
  384. * @param enabled true: enable the proximity function; false: disable the proximity function
  385. * @return
  386. * - true: Configured correctly.
  387. * - false: Configured error.
  388. */
  389. bool touch_hal_enable_proximity(touch_pad_t touch_num, bool enabled);
  390. /**
  391. * Set touch channel number for proximity pad.
  392. * If disable the proximity pad, point this pad to `TOUCH_PAD_NUM0`
  393. *
  394. * @param prox_pad The array of three proximity pads.
  395. */
  396. #define touch_hal_proximity_set_channel_num(prox_pad) touch_ll_proximity_set_channel_num(prox_pad)
  397. /**
  398. * Get touch channel number for proximity pad.
  399. * If disable the proximity pad, point this pad to `TOUCH_PAD_NUM0`
  400. *
  401. * @param prox_pad The array of three proximity pads.
  402. */
  403. #define touch_hal_proximity_get_channel_num(prox_pad) touch_ll_proximity_get_channel_num(prox_pad)
  404. /**
  405. * Set cumulative measurement times for proximity pad.
  406. *
  407. * @param times The cumulative number of measurement cycles.
  408. */
  409. #define touch_hal_proximity_set_meas_times(times) touch_ll_proximity_set_meas_times(times)
  410. /**
  411. * Get cumulative measurement times for proximity pad.
  412. *
  413. * @param times The cumulative number of measurement cycles.
  414. */
  415. #define touch_hal_proximity_get_meas_times(times) touch_ll_proximity_get_meas_times(times)
  416. /**
  417. * Read current cumulative measurement times for proximity pad.
  418. *
  419. * @param times The cumulative number of measurement cycles.
  420. */
  421. #define touch_hal_proximity_read_meas_cnt(touch_num, cnt) touch_ll_proximity_read_meas_cnt(touch_num, cnt)
  422. /**
  423. * Check if the touch sensor channel is the proximity pad.
  424. *
  425. * @param touch_num The touch sensor channel number.
  426. */
  427. #define touch_hal_proximity_pad_check(touch_num) touch_ll_proximity_pad_check(touch_num)
  428. /************** sleep pad setting ***********************/
  429. /**
  430. * Get parameter of touch sensor sleep channel.
  431. * The touch sensor can works in sleep mode to wake up sleep.
  432. * After the sleep channel is configured, users should query the channel reading using a specific function.
  433. *
  434. * @param slp_config Point to touch sleep pad config.
  435. */
  436. void touch_hal_sleep_channel_get_config(touch_pad_sleep_channel_t *slp_config);
  437. /**
  438. * Set parameter of touch sensor sleep channel.
  439. * The touch sensor can works in sleep mode to wake up sleep.
  440. * After the sleep channel is configured, users should query the channel reading using a specific function.
  441. *
  442. * @note ESP32S2 only support one channel to be set sleep channel.
  443. *
  444. * @param pad_num touch sleep pad number.
  445. * @param enable Enable/disable sleep pad function.
  446. */
  447. void touch_hal_sleep_channel_enable(touch_pad_t pad_num, bool enable);
  448. /**
  449. * Set touch channel number for sleep pad.
  450. *
  451. * @note Only one touch sensor channel is supported in deep sleep mode.
  452. * @param touch_num Touch sensor channel number.
  453. */
  454. #define touch_hal_sleep_set_channel_num(touch_num) touch_ll_sleep_set_channel_num(touch_num)
  455. /**
  456. * Get touch channel number for sleep pad.
  457. *
  458. * @note Only one touch sensor channel is supported in deep sleep mode.
  459. * @param touch_num Touch sensor channel number.
  460. */
  461. #define touch_hal_sleep_get_channel_num(touch_num) touch_ll_sleep_get_channel_num(touch_num)
  462. /**
  463. * Set the trigger threshold of touch sensor in deep sleep.
  464. * The threshold determines the sensitivity of the touch sensor.
  465. * The threshold is the original value of the trigger state minus the benchmark value.
  466. *
  467. * @note The threshold at sleep is the same as the threshold before sleep.
  468. */
  469. #define touch_hal_sleep_set_threshold(touch_thres) touch_ll_sleep_set_threshold(touch_thres)
  470. /**
  471. * Get the trigger threshold of touch sensor in deep sleep.
  472. * The threshold determines the sensitivity of the touch sensor.
  473. * The threshold is the original value of the trigger state minus the benchmark value.
  474. *
  475. * @note The threshold at sleep is the same as the threshold before sleep.
  476. */
  477. #define touch_hal_sleep_get_threshold(touch_thres) touch_ll_sleep_get_threshold(touch_thres)
  478. /**
  479. * Enable proximity function for sleep pad.
  480. */
  481. #define touch_hal_sleep_enable_approach() touch_ll_sleep_enable_approach()
  482. /**
  483. * Disable proximity function for sleep pad.
  484. */
  485. #define touch_hal_sleep_disable_approach() touch_ll_sleep_disable_approach()
  486. /**
  487. * Read benchmark of touch sensor for sleep pad.
  488. *
  489. * @param benchmark Pointer to accept touch sensor benchmark value.
  490. */
  491. #define touch_hal_sleep_read_benchmark(benchmark) touch_ll_sleep_read_benchmark(benchmark)
  492. /**
  493. * Read smooth data of touch sensor for sleep pad.
  494. */
  495. #define touch_hal_sleep_read_smooth(smooth_data) touch_ll_sleep_read_smooth(smooth_data)
  496. /**
  497. * Read raw data of touch sensor for sleep pad.
  498. */
  499. #define touch_hal_sleep_read_data(raw_data) touch_ll_sleep_read_data(raw_data)
  500. /**
  501. * Reset benchmark of touch sensor for sleep pad.
  502. */
  503. #define touch_hal_sleep_reset_benchmark() touch_ll_sleep_reset_benchmark()
  504. /**
  505. * Read debounce of touch sensor for sleep pad.
  506. *
  507. * @param debounce Pointer to accept touch sensor debounce value.
  508. */
  509. #define touch_hal_sleep_read_debounce(debounce) touch_ll_sleep_read_debounce(debounce)
  510. /**
  511. * Read proximity count of touch sensor for sleep pad.
  512. * @param proximity_cnt Pointer to accept touch sensor proximity count value.
  513. */
  514. #define touch_hal_sleep_read_proximity_cnt(approach_cnt) touch_ll_sleep_read_proximity_cnt(approach_cnt)
  515. /**
  516. * Get the touch pad which caused wakeup from deep sleep.
  517. *
  518. * @param pad_num pointer to touch pad which caused wakeup.
  519. */
  520. #define touch_hal_get_wakeup_status(pad_num) touch_ll_get_wakeup_status(pad_num)
  521. /**
  522. * Change the operating frequency of touch pad in deep sleep state. Reducing the operating frequency can effectively reduce power consumption.
  523. * If this function is not called, the working frequency of touch in the deep sleep state is the same as that in the wake-up state.
  524. *
  525. * @param sleep_cycle The touch sensor will sleep after each measurement.
  526. * sleep_cycle decide the interval between each measurement.
  527. * t_sleep = sleep_cycle / (RTC_SLOW_CLK frequency).
  528. * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function.
  529. * @param meas_times The times of charge and discharge in each measure process of touch channels.
  530. * The timer frequency is 8Mhz. Range: 0 ~ 0xffff.
  531. * Recommended typical value: Modify this value to make the measurement time around 1ms.
  532. */
  533. void touch_hal_sleep_channel_set_work_time(uint16_t sleep_cycle, uint16_t meas_times);
  534. /**
  535. * Get the operating frequency of touch pad in deep sleep state. Reducing the operating frequency can effectively reduce power consumption.
  536. *
  537. * @param sleep_cycle The touch sensor will sleep after each measurement.
  538. * sleep_cycle decide the interval between each measurement.
  539. * t_sleep = sleep_cycle / (RTC_SLOW_CLK frequency).
  540. * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function.
  541. * @param meas_times The times of charge and discharge in each measure process of touch channels.
  542. * The timer frequency is 8Mhz. Range: 0 ~ 0xffff.
  543. * Recommended typical value: Modify this value to make the measurement time around 1ms.
  544. */
  545. void touch_hal_sleep_channel_get_work_time(uint16_t *sleep_cycle, uint16_t *meas_times);
  546. #ifdef __cplusplus
  547. }
  548. #endif