Skip to content

Commit 0f69fda

Browse files
committed
change(doc): added more usage notes about PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
1 parent de05373 commit 0f69fda

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

components/esp_hw_support/include/esp_sleep.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -429,8 +429,10 @@ __attribute__((deprecated("please use 'esp_sleep_enable_ext1_wakeup_io' and 'esp
429429
*
430430
* This function enables an IO pin to wake up the chip from deep sleep.
431431
*
432-
* @note This function does not modify pin configuration. The pins are
433-
* configured inside esp_deep_sleep_start, immediately before entering sleep mode.
432+
* @note 1.This function does not modify pin configuration. The pins are configured
433+
* inside `esp_deep_sleep_start`, immediately before entering sleep mode.
434+
* 2.This function is also applicable to waking up the lightsleep when the peripheral
435+
* power domain is powered off, see PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP in menuconfig.
434436
*
435437
* @note You don't need to worry about pull-up or pull-down resistors before
436438
* using this function because the ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS
@@ -465,11 +467,17 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee
465467
* wakeup level, for each GPIO which is used for wakeup.
466468
* Then call this function to enable wakeup feature.
467469
*
468-
* @note On ESP32, GPIO wakeup source can not be used together with touch or ULP wakeup sources.
470+
* @note 1. On ESP32, GPIO wakeup source can not be used together with touch or ULP wakeup sources.
471+
* 2. If PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP is enabled (if target supported),
472+
* this API is unavailable since the GPIO module is powered down during sleep.
473+
* You can use `esp_deep_sleep_enable_gpio_wakeup` instead, or use EXT1 wakeup source
474+
* by `esp_sleep_enable_ext1_wakeup_io` to achieve the same function.
475+
* (Only GPIOs which have RTC functionality can be used)
469476
*
470477
* @return
471478
* - ESP_OK on success
472479
* - ESP_ERR_INVALID_STATE if wakeup triggers conflict
480+
* - ESP_ERR_NOT_SUPPORTED if GPIO wakeup source is not available
473481
*/
474482
esp_err_t esp_sleep_enable_gpio_wakeup(void);
475483

@@ -481,12 +489,15 @@ esp_err_t esp_sleep_enable_gpio_wakeup(void);
481489
* Wakeup from light sleep takes some time, so not every character sent
482490
* to the UART can be received by the application.
483491
*
484-
* @note ESP32 does not support wakeup from UART2.
492+
* @note 1. ESP32 does not support wakeup from UART2.
493+
* 2. If PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP is enabled (if target supported),
494+
* this API is unavailable since the UART module is powered down during sleep.
485495
*
486496
* @param uart_num UART port to wake up from
487497
* @return
488498
* - ESP_OK on success
489499
* - ESP_ERR_INVALID_ARG if wakeup from given UART is not supported
500+
* - ESP_ERR_NOT_SUPPORTED if UART wakeup source is not available
490501
*/
491502
esp_err_t esp_sleep_enable_uart_wakeup(int uart_num);
492503

components/esp_hw_support/sleep_modes.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,6 +2076,10 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee
20762076

20772077
esp_err_t esp_sleep_enable_gpio_wakeup(void)
20782078
{
2079+
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
2080+
ESP_LOGE(TAG, "%s wakeup source is not available if the peripheral power domain is powered down in sleep", "GPIO");
2081+
return ESP_ERR_NOT_SUPPORTED;
2082+
#endif
20792083
#if CONFIG_IDF_TARGET_ESP32
20802084
if (s_config.wakeup_triggers & (RTC_TOUCH_TRIG_EN | RTC_ULP_TRIG_EN)) {
20812085
ESP_LOGE(TAG, "Conflicting wake-up triggers: touch / ULP");
@@ -2088,6 +2092,10 @@ esp_err_t esp_sleep_enable_gpio_wakeup(void)
20882092

20892093
esp_err_t esp_sleep_enable_uart_wakeup(int uart_num)
20902094
{
2095+
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
2096+
ESP_LOGE(TAG, "%s wakeup source is not available if the peripheral power domain is powered down in sleep", "UART");
2097+
return ESP_ERR_NOT_SUPPORTED;
2098+
#endif
20912099
if (uart_num == UART_NUM_0) {
20922100
s_config.wakeup_triggers |= RTC_UART0_TRIG_EN;
20932101
} else if (uart_num == UART_NUM_1) {

components/esp_pm/Kconfig

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,17 @@ menu "Power Management"
146146
select PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP if !SOC_CPU_IN_TOP_DOMAIN
147147
default n #TODO: enable by default if periph init/deinit management supported (WIFI-5252)
148148
help
149-
If enabled, digital peripherals will be powered down in light sleep, it will reduce sleep
150-
current consumption by about 100 uA. Chip will save/restore register context at sleep/wake
151-
time to keep the system running. Enabling this option will increase static RAM and heap usage,
152-
the actual cost depends on the peripherals you have initialized. In order to save/restore the
153-
context of the necessary hardware for FreeRTOS to run, it will need at least 4.55 KB free heap
154-
at sleep time. Otherwise sleep will not power down the peripherals.
149+
If enabled, digital peripherals will be powered down in light sleep, all related peripherals will
150+
not be available during sleep, including wake-up sources from the peripherals (For detailed availability
151+
information, see the note of the corresponding wakeup source enable function).
152+
The chip will automatically save/restore register context during sleep/wakeup to make the upper layer
153+
user unaware of the peripheral powerdown during sleep. Enabling this option will increase static RAM and
154+
heap usage but will also significantly reduce power.
155+
consumption during lightsleep, the actual memory cost depends on the peripherals you have initialized,
156+
for specific power consumption data in this mode, please refer to Electrical Characteristics section
157+
in the chip datasheet.
158+
(In order to save/restore the context of the necessary hardware for FreeRTOS to run, it will need
159+
at least 4.55 KB free heap at sleep time. Otherwise sleep will not power down the peripherals.)
155160

156161
Note1: Please use this option with caution, the current IDF does not support the retention of
157162
all peripherals. When the digital peripherals are powered off and a sleep and wake-up is completed,

0 commit comments

Comments
 (0)