mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 12:35:28 +00:00
deep sleep: clarify compatibility issues between wakeup sources
ULP and touch FSMs in ESP32 revisions 0 and 1 do not operate correctly if RTC_PERIPH power domain is force powered on (ESP_PD_OPTION_ON). Both ULP and touch still work, but clock frequency of the ULP may be incorrect and touch values may be off by considerable amount. As such, when these wakeup modes are used, RTC_PERIPH power domain has to be set to ESP_PD_OPTION_AUTO (or, in the current implementation, ESP_PD_OPTION_OFF — though this will change in the future when _OFF will actually *force* the power domain to be powered off). Because EXT0 wakeup source requires RTC_PERIPH to be powered ON, mark ULP and touch wakeup sources as incompatible with EXT0. Workaround for this is to use EXT1 wakeup source instead, which offers similar or better functions without having to keep RTC_PERIPH powered on.
This commit is contained in:
@@ -163,8 +163,8 @@ void system_deep_sleep(uint64_t) __attribute__((alias("esp_deep_sleep")));
|
||||
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");
|
||||
if(s_config.wakeup_triggers & RTC_EXT_EVENT0_TRIG_EN) {
|
||||
ESP_LOGE(TAG, "Conflicting wake-up trigger: ext0");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
s_config.wakeup_triggers |= RTC_SAR_TRIG_EN;
|
||||
@@ -183,8 +183,8 @@ esp_err_t esp_deep_sleep_enable_timer_wakeup(uint64_t time_in_us)
|
||||
|
||||
esp_err_t esp_deep_sleep_enable_touchpad_wakeup()
|
||||
{
|
||||
if (s_config.wakeup_triggers & (RTC_SAR_TRIG_EN | RTC_EXT_EVENT0_TRIG_EN)) {
|
||||
ESP_LOGE(TAG, "Conflict wake-up triggers: ulp/ext0");
|
||||
if (s_config.wakeup_triggers & (RTC_EXT_EVENT0_TRIG_EN)) {
|
||||
ESP_LOGE(TAG, "Conflicting wake-up trigger: ext0");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
s_config.wakeup_triggers |= RTC_TOUCH_TRIG_EN;
|
||||
@@ -199,8 +199,8 @@ esp_err_t esp_deep_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level)
|
||||
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");
|
||||
if (s_config.wakeup_triggers & (RTC_TOUCH_TRIG_EN | RTC_SAR_TRIG_EN)) {
|
||||
ESP_LOGE(TAG, "Conflicting wake-up triggers: touch / ULP");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
s_config.ext0_rtc_gpio_num = rtc_gpio_desc[gpio_num].rtc_num;
|
||||
@@ -351,15 +351,14 @@ static uint32_t get_power_down_flags()
|
||||
s_config.pd_options[ESP_PD_DOMAIN_RTC_FAST_MEM] = ESP_PD_OPTION_ON;
|
||||
}
|
||||
|
||||
// RTC_PERIPH is needed for EXT0 wakeup and for ULP.
|
||||
// If RTC_PERIPH is auto, and both EXT0 and ULP aren't enabled,
|
||||
// power down RTC_PERIPH.
|
||||
// RTC_PERIPH is needed for EXT0 wakeup.
|
||||
// If RTC_PERIPH is auto, and EXT0 isn't enabled, power down RTC_PERIPH.
|
||||
if (s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH] == ESP_PD_OPTION_AUTO) {
|
||||
if (s_config.wakeup_triggers &
|
||||
(RTC_SAR_TRIG_EN | RTC_EXT_EVENT0_TRIG_EN)) {
|
||||
if (s_config.wakeup_triggers & 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.
|
||||
} else if (s_config.wakeup_triggers & (RTC_TOUCH_TRIG_EN | RTC_SAR_TRIG_EN)) {
|
||||
// In both rev. 0 and rev. 1 of ESP32, forcing power up of RTC_PERIPH
|
||||
// prevents ULP timer and touch FSMs from working correctly.
|
||||
s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH] = ESP_PD_OPTION_OFF;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user