diff --git a/components/esp_hw_support/include/esp_sleep.h b/components/esp_hw_support/include/esp_sleep.h index 52d879191c..e19f669752 100644 --- a/components/esp_hw_support/include/esp_sleep.h +++ b/components/esp_hw_support/include/esp_sleep.h @@ -415,8 +415,10 @@ esp_err_t esp_sleep_enable_ext1_wakeup_with_level_mask(uint64_t io_mask, uint64_ * * This function enables an IO pin to wake up the chip from deep sleep. * - * @note This function does not modify pin configuration. The pins are - * configured inside esp_deep_sleep_start, immediately before entering sleep mode. + * @note 1.This function does not modify pin configuration. The pins are configured + * inside `esp_deep_sleep_start`, immediately before entering sleep mode. + * 2.This function is also applicable to waking up the lightsleep when the peripheral + * power domain is powered off, see PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP in menuconfig. * * @note You don't need to worry about pull-up or pull-down resistors before * using this function because the ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS @@ -451,7 +453,12 @@ 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 On ESP32, GPIO wakeup source can not be used together with touch or ULP wakeup sources. + * @note 1. On ESP32, GPIO wakeup source can not be used together with touch or ULP wakeup sources. + * 2. If PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP is enabled (if target supported), + * this API is unavailable since the GPIO module is powered down during sleep. + * You can use `esp_deep_sleep_enable_gpio_wakeup` instead, or use EXT1 wakeup source + * by `esp_sleep_enable_ext1_wakeup_io` to achieve the same function. + * (Only GPIOs which have RTC functionality can be used) * * @return * - ESP_OK on success @@ -467,7 +474,9 @@ esp_err_t esp_sleep_enable_gpio_wakeup(void); * Wakeup from light sleep takes some time, so not every character sent * to the UART can be received by the application. * - * @note ESP32 does not support wakeup from UART2. + * @note 1. ESP32 does not support wakeup from UART2. + * 2. If PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP is enabled (if target supported), + * this API is unavailable since the UART module is powered down during sleep. * * @param uart_num UART port to wake up from * @return diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index 1914bdbcf7..b7f1b88856 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -1844,6 +1844,9 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee esp_err_t esp_sleep_enable_gpio_wakeup(void) { +#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP + ESP_LOGW(TAG, "%s wakeup source is not available if the peripheral power domain is powered down in sleep", "GPIO"); +#endif #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"); @@ -1856,6 +1859,9 @@ esp_err_t esp_sleep_enable_gpio_wakeup(void) esp_err_t esp_sleep_enable_uart_wakeup(int uart_num) { +#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP + ESP_LOGW(TAG, "%s wakeup source is not available if the peripheral power domain is powered down in sleep", "UART"); +#endif if (uart_num == UART_NUM_0) { s_config.wakeup_triggers |= RTC_UART0_TRIG_EN; } else if (uart_num == UART_NUM_1) { diff --git a/components/esp_pm/Kconfig b/components/esp_pm/Kconfig index a0378e7964..f52c38da03 100644 --- a/components/esp_pm/Kconfig +++ b/components/esp_pm/Kconfig @@ -124,12 +124,17 @@ menu "Power Management" depends on SOC_PAU_SUPPORTED default n #TODO: enable by default if periph init/deinit management supported (WIFI-5252) help - If enabled, digital peripherals will be powered down in light sleep, it will reduce sleep - current consumption by about 100 uA. Chip will save/restore register context at sleep/wake - time to keep the system running. Enabling this option will increase static RAM and heap usage, - the actual cost depends on the peripherals you have initialized. In order to save/restore the - context of the necessary hardware for FreeRTOS to run, it will need at least 4.55 KB free heap - at sleep time. Otherwise sleep will not power down the peripherals. + If enabled, digital peripherals will try to powered down in light sleep, then all related peripherals will + not be available during sleep, including wake-up sources from the peripherals (For detailed availability + information, see the note of the corresponding wakeup source enable function). + The chip will automatically save/restore register context during sleep/wakeup to make the upper layer + user unaware of the peripheral powerdown during sleep. Enabling this option will increase static RAM and + heap usage but will also significantly reduce power. + consumption during lightsleep, the actual memory cost depends on the peripherals you have initialized, + for specific power consumption data in this mode, please refer to Electrical Characteristics section + in the chip datasheet. + (In order to save/restore the context of the necessary hardware for FreeRTOS to run, it will need + at least 4.55 KB free heap at sleep time. Otherwise sleep will not power down the peripherals.) Note1: Please use this option with caution, the current IDF does not support the retention of all peripherals. When the digital peripherals are powered off and a sleep and wake-up is completed, @@ -144,6 +149,14 @@ menu "Power Management" of freertos to not be compensated correctly when returning from sleep and cause the system to crash. To avoid this, you can increase FREERTOS_IDLE_TIME_BEFORE_SLEEP threshold in menuconfig. + Note3: Enabling this option does not necessarily mean that the peripheral power domain will be + turned down during sleep. The control priority of `esp_sleep_pd_config` is higher than this option, + user code can still prevent the peripheral power domain from powering down during sleep by + `esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON)`. In addition, whether the peripheral power + domain is powered down during sleep also depends on the sleep working strategy selected by the driver. + If any module belonging to the peripheral power domain chooses not to be powered down during sleep, + then the peripheral power domain will not be powered off either. + config PM_UPDATE_CCOMPARE_HLI_WORKAROUND bool default y if PM_ENABLE && BTDM_CTRL_HLI