mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-23 02:48:25 +00:00
fix: reduce the consumption of touch sensor during deep sleep
This commit is contained in:
@@ -608,6 +608,33 @@ void touch_hal_sleep_channel_enable(touch_pad_t pad_num, bool enable);
|
||||
*/
|
||||
#define touch_hal_get_wakeup_status(pad_num) touch_ll_get_wakeup_status(pad_num)
|
||||
|
||||
/**
|
||||
* Change the operating frequency of touch pad in deep sleep state. Reducing the operating frequency can effectively reduce power consumption.
|
||||
* 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.
|
||||
*
|
||||
* @param sleep_cycle The touch sensor will sleep after each measurement.
|
||||
* sleep_cycle decide the interval between each measurement.
|
||||
* t_sleep = sleep_cycle / (RTC_SLOW_CLK frequency).
|
||||
* The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function.
|
||||
* @param meas_times The times of charge and discharge in each measure process of touch channels.
|
||||
* The timer frequency is 8Mhz. Range: 0 ~ 0xffff.
|
||||
* Recommended typical value: Modify this value to make the measurement time around 1ms.
|
||||
*/
|
||||
void touch_hal_sleep_channel_set_work_time(uint16_t sleep_cycle, uint16_t meas_times);
|
||||
|
||||
/**
|
||||
* Get the operating frequency of touch pad in deep sleep state. Reducing the operating frequency can effectively reduce power consumption.
|
||||
*
|
||||
* @param sleep_cycle The touch sensor will sleep after each measurement.
|
||||
* sleep_cycle decide the interval between each measurement.
|
||||
* t_sleep = sleep_cycle / (RTC_SLOW_CLK frequency).
|
||||
* The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function.
|
||||
* @param meas_times The times of charge and discharge in each measure process of touch channels.
|
||||
* The timer frequency is 8Mhz. Range: 0 ~ 0xffff.
|
||||
* Recommended typical value: Modify this value to make the measurement time around 1ms.
|
||||
*/
|
||||
void touch_hal_sleep_channel_get_work_time(uint16_t *sleep_cycle, uint16_t *meas_times);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
#include "hal/touch_sensor_types.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
static int s_sleep_cycle = -1;
|
||||
static int s_meas_times = -1;
|
||||
|
||||
void touch_hal_init(void)
|
||||
{
|
||||
touch_ll_stop_fsm();
|
||||
@@ -157,3 +160,23 @@ void touch_hal_sleep_channel_get_config(touch_pad_sleep_channel_t *slp_config)
|
||||
touch_ll_sleep_get_channel_num(&slp_config->touch_num);
|
||||
slp_config->en_proximity = touch_ll_sleep_get_approach_status();
|
||||
}
|
||||
|
||||
void touch_hal_sleep_channel_set_work_time(uint16_t sleep_cycle, uint16_t meas_times)
|
||||
{
|
||||
s_sleep_cycle = (int)sleep_cycle;
|
||||
s_meas_times = (int)meas_times;
|
||||
}
|
||||
|
||||
void touch_hal_sleep_channel_get_work_time(uint16_t *sleep_cycle, uint16_t *meas_times)
|
||||
{
|
||||
if (s_meas_times < 0) {
|
||||
touch_ll_get_measure_times(meas_times);
|
||||
} else {
|
||||
*meas_times = (uint16_t)s_meas_times;
|
||||
}
|
||||
if (s_sleep_cycle < 0) {
|
||||
touch_ll_get_sleep_time(sleep_cycle);
|
||||
} else {
|
||||
*sleep_cycle = (uint16_t)s_sleep_cycle;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user