esp_err_t esp_deep_sleep_enable_ulp_wakeup()
{
#ifdef CONFIG_ULP_COPROC_ENABLED
+ if(s_config.wakeup_triggers & RTC_TOUCH_TRIG_EN) {
+ ESP_LOGE(TAG, "Conflict wake-up triggers: touch");
+ return ESP_ERR_INVALID_STATE;
+ }
s_config.wakeup_triggers |= RTC_SAR_TRIG_EN;
return ESP_OK;
#else
esp_err_t esp_deep_sleep_enable_touchpad_wakeup()
{
- s_config.wakeup_triggers |= TOUCH_TRIG_EN;
+ if (s_config.wakeup_triggers & (RTC_SAR_TRIG_EN | RTC_EXT_EVENT0_TRIG_EN)) {
+ ESP_LOGE(TAG, "Conflict wake-up triggers: ulp/ext0");
+ return ESP_ERR_INVALID_STATE;
+ }
+ s_config.wakeup_triggers |= RTC_TOUCH_TRIG_EN;
return ESP_OK;
}
if (!RTC_GPIO_IS_VALID_GPIO(gpio_num)) {
return ESP_ERR_INVALID_ARG;
}
+ if (s_config.wakeup_triggers & RTC_TOUCH_TRIG_EN) {
+ ESP_LOGE(TAG, "Conflict wake-up triggers: touch");
+ return ESP_ERR_INVALID_STATE;
+ }
s_config.ext0_rtc_gpio_num = rtc_gpio_desc[gpio_num].rtc_num;
s_config.ext0_trigger_level = level;
s_config.wakeup_triggers |= RTC_EXT_EVENT0_TRIG_EN;
if (s_config.wakeup_triggers &
(RTC_SAR_TRIG_EN | RTC_EXT_EVENT0_TRIG_EN)) {
s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH] = ESP_PD_OPTION_ON;
+ } else if (s_config.wakeup_triggers & RTC_TOUCH_TRIG_EN) {
+ // We have to set power down PERIPH so as to enable wake-up from touch sensor.
+ s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH] = ESP_PD_OPTION_OFF;
}
}
/**
* @brief Enable wakeup by ULP coprocessor
+ * @note ulp wakeup conflicts with touch wakeup.
* @return
* - ESP_OK on success
- * - ESP_ERR_INVALID_STATE if ULP co-processor is not enabled.
+ * - ESP_ERR_INVALID_STATE if ULP co-processor is not enabled or if wakeup triggers conflict
*/
esp_err_t esp_deep_sleep_enable_ulp_wakeup();
/**
* @brief Enable wakeup by touch sensor
+ * @note Can not set touch wake-up if ulp or ext0 wake-up is enabled.
* @return
* - ESP_OK on success
+ * - ESP_ERR_INVALID_STATE if wakeup triggers conflict
*/
esp_err_t esp_deep_sleep_enable_touchpad_wakeup();
* @note This function does not modify pin configuration. The pin is
* configured in esp_deep_sleep_start, immediately before
* entering deep sleep.
+ * @note This ext0 wakeup conflicts with touch wakeup.
*
* @param gpio_num GPIO number used as wakeup source. Only GPIOs which are have RTC
* functionality can be used: 0,2,4,12-15,25-27,32-39.
* - ESP_OK on success
* - ESP_ERR_INVALID_ARG if the selected GPIO is not an RTC GPIO,
* or the mode is invalid
+ * - ESP_ERR_INVALID_STATE if wakeup triggers conflict
*/
esp_err_t esp_deep_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level);
.. doxygenfunction:: esp_deep_sleep_enable_timer_wakeup
+Touch pad
+^^^^^
+
+RTC IO module contains logic to trigger wakeup when a touch sensor interrupt occurs. You need to configure the touch pad interrupt before the chip starts deep sleep.
+
+Note that, for now, this wakeup requires RTC peripherals to be powered off during deep sleep.
+
+.. doxygenfunction:: esp_deep_sleep_enable_touchpad_wakeup
+
External wakeup (ext0)
^^^^^^^^^^^^^^^^^^^^^^