diff --git a/components/esp_hw_support/include/esp_sleep.h b/components/esp_hw_support/include/esp_sleep.h index 286ccc76de..3d148bba45 100644 --- a/components/esp_hw_support/include/esp_sleep.h +++ b/components/esp_hw_support/include/esp_sleep.h @@ -107,10 +107,8 @@ esp_err_t esp_sleep_disable_wakeup_source(esp_sleep_source_t source); #if SOC_ULP_SUPPORTED /** * @brief Enable wakeup by ULP coprocessor - * @note In revisions 0 and 1 of the ESP32, ULP wakeup source - * cannot be used when RTC_PERIPH power domain is forced - * to be powered on (ESP_PD_OPTION_ON) or when - * ext0 wakeup source is used. + * @note On ESP32, ULP wakeup source cannot be used when RTC_PERIPH power domain is forced, + * to be powered on (ESP_PD_OPTION_ON) or when ext0 wakeup source is used. * @return * - ESP_OK on success * - ESP_ERR_NOT_SUPPORTED if additional current by touch (CONFIG_RTC_EXT_CRYST_ADDIT_CURRENT) is enabled. @@ -133,10 +131,8 @@ esp_err_t esp_sleep_enable_timer_wakeup(uint64_t time_in_us); /** * @brief Enable wakeup by touch sensor * - * @note In revisions 0 and 1 of the ESP32, touch wakeup source - * can not be used when RTC_PERIPH power domain is forced - * to be powered on (ESP_PD_OPTION_ON) or when ext0 wakeup - * source is used. + * @note On ESP32, touch wakeup source can not be used when RTC_PERIPH power domain is forced + * to be powered on (ESP_PD_OPTION_ON) or when ext0 wakeup source is used. * * @note The FSM mode of the touch button should be configured * as the timer trigger mode. @@ -184,8 +180,7 @@ bool esp_sleep_is_valid_wakeup_gpio(gpio_num_t gpio_num); * configured in esp_deep_sleep_start/esp_light_sleep_start, * immediately before entering sleep mode. * - * @note In revisions 0 and 1 of the ESP32, ext0 wakeup source - * can not be used together with touch or ULP wakeup sources. + * @note On ESP32, ext0 wakeup source can not be used together with touch or ULP wakeup sources. * * @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. @@ -270,8 +265,7 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee * wakeup level, for each GPIO which is used for wakeup. * Then call this function to enable wakeup feature. * - * @note In revisions 0 and 1 of the ESP32, GPIO wakeup source - * can not be used together with touch or ULP wakeup sources. + * @note On ESP32, GPIO wakeup source can not be used together with touch or ULP wakeup sources. * * @return * - ESP_OK on success diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index 16b886e3be..304c7090ed 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -870,7 +870,6 @@ esp_err_t esp_sleep_enable_ulp_wakeup(void) #ifndef CONFIG_ULP_COPROC_ENABLED return ESP_ERR_INVALID_STATE; #endif // CONFIG_ULP_COPROC_ENABLED - #if CONFIG_IDF_TARGET_ESP32 #if ((defined CONFIG_RTC_EXT_CRYST_ADDIT_CURRENT) || (defined CONFIG_RTC_EXT_CRYST_ADDIT_CURRENT_V2)) ESP_LOGE(TAG, "Failed to enable wakeup when provide current to external 32kHz crystal"); @@ -936,6 +935,7 @@ static void touch_wakeup_prepare(void) esp_err_t esp_sleep_enable_touchpad_wakeup(void) { +#if CONFIG_IDF_TARGET_ESP32 #if ((defined CONFIG_RTC_EXT_CRYST_ADDIT_CURRENT) || (defined CONFIG_RTC_EXT_CRYST_ADDIT_CURRENT_V2)) ESP_LOGE(TAG, "Failed to enable wakeup when provide current to external 32kHz crystal"); return ESP_ERR_NOT_SUPPORTED; @@ -944,6 +944,8 @@ esp_err_t esp_sleep_enable_touchpad_wakeup(void) ESP_LOGE(TAG, "Conflicting wake-up trigger: ext0"); return ESP_ERR_INVALID_STATE; } +#endif //CONFIG_IDF_TARGET_ESP32 + s_config.wakeup_triggers |= RTC_TOUCH_TRIG_EN; return ESP_OK; } @@ -980,10 +982,13 @@ esp_err_t esp_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level) if (!esp_sleep_is_valid_wakeup_gpio(gpio_num)) { return ESP_ERR_INVALID_ARG; } +#if CONFIG_IDF_TARGET_ESP32 if (s_config.wakeup_triggers & (RTC_TOUCH_TRIG_EN | RTC_ULP_TRIG_EN)) { ESP_LOGE(TAG, "Conflicting wake-up triggers: touch / ULP"); return ESP_ERR_INVALID_STATE; } +#endif //CONFIG_IDF_TARGET_ESP32 + s_config.ext0_rtc_gpio_num = rtc_io_number_get(gpio_num); s_config.ext0_trigger_level = level; s_config.wakeup_triggers |= RTC_EXT0_TRIG_EN; @@ -1309,28 +1314,18 @@ static uint32_t get_power_down_flags(void) #if SOC_PM_SUPPORT_RTC_PERIPH_PD // RTC_PERIPH is needed for EXT0 wakeup and GPIO wakeup. - // If RTC_PERIPH is auto, and EXT0/GPIO aren't enabled, power down RTC_PERIPH. + // If RTC_PERIPH is left auto (EXT0/GPIO aren't enabled), RTC_PERIPH will be powered off by default. if (s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH] == ESP_PD_OPTION_AUTO) { -#if SOC_PM_SUPPORT_TOUCH_SENSOR_WAKEUP - uint32_t wakeup_source = RTC_TOUCH_TRIG_EN; -#if SOC_ULP_SUPPORTED - wakeup_source |= RTC_ULP_TRIG_EN; -#endif if (s_config.wakeup_triggers & (RTC_EXT0_TRIG_EN | RTC_GPIO_TRIG_EN)) { s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH] = ESP_PD_OPTION_ON; - } else if (s_config.wakeup_triggers & wakeup_source) { - // In both rev. 0 and rev. 1 of ESP32, forcing power up of RTC_PERIPH + } +#if CONFIG_IDF_TARGET_ESP32 + else if (s_config.wakeup_triggers & (RTC_TOUCH_TRIG_EN | RTC_ULP_TRIG_EN)) { + // On 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; } -#else - - if (s_config.wakeup_triggers & RTC_GPIO_TRIG_EN) { - s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH] = ESP_PD_OPTION_ON; - } else { - s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH] = ESP_PD_OPTION_OFF; - } -#endif // SOC_PM_SUPPORT_TOUCH_SENSOR_WAKEUP +#endif //CONFIG_IDF_TARGET_ESP32 } #endif // SOC_PM_SUPPORT_RTC_PERIPH_PD