fix(sleep): swap touchpad num in wakeup status
This commit is contained in:
parent
6d46220456
commit
54a67d92a4
3 changed files with 23 additions and 3 deletions
|
@ -550,6 +550,15 @@ esp_err_t touch_pad_filter_stop();
|
|||
*/
|
||||
esp_err_t touch_pad_filter_delete();
|
||||
|
||||
/**
|
||||
* @brief Get the touch pad which caused wakeup from sleep
|
||||
* @param pad_num pointer to touch pad which caused wakeup
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL get status err
|
||||
*/
|
||||
esp_err_t touch_pad_get_wakeup_status(touch_pad_t *pad_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1002,6 +1002,16 @@ esp_err_t touch_pad_filter_delete()
|
|||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t touch_pad_get_wakeup_status(touch_pad_t *pad_num)
|
||||
{
|
||||
uint32_t touch_mask = SENS.sar_touch_ctrl2.touch_meas_en;
|
||||
if(touch_mask == 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
*pad_num = touch_pad_num_wrap((touch_pad_t)(__builtin_ffs(touch_mask) - 1));
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
ADC Common
|
||||
---------------------------------------------------------------*/
|
||||
|
|
|
@ -428,9 +428,10 @@ touch_pad_t esp_sleep_get_touchpad_wakeup_status()
|
|||
if (esp_sleep_get_wakeup_cause() != ESP_SLEEP_WAKEUP_TOUCHPAD) {
|
||||
return TOUCH_PAD_MAX;
|
||||
}
|
||||
uint32_t touch_mask = REG_GET_FIELD(SENS_SAR_TOUCH_CTRL2_REG, SENS_TOUCH_MEAS_EN);
|
||||
assert(touch_mask != 0 && "wakeup reason is RTC_TOUCH_TRIG_EN but SENS_TOUCH_MEAS_EN is zero");
|
||||
return (touch_pad_t) (__builtin_ffs(touch_mask) - 1);
|
||||
touch_pad_t pad_num;
|
||||
esp_err_t ret = touch_pad_get_wakeup_status(&pad_num);
|
||||
assert(ret == ESP_OK && "wakeup reason is RTC_TOUCH_TRIG_EN but SENS_TOUCH_MEAS_EN is zero");
|
||||
return pad_num;
|
||||
}
|
||||
|
||||
esp_err_t esp_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level)
|
||||
|
|
Loading…
Reference in a new issue