Skip to content

Commit e57f02e

Browse files
committed
Merge branch 'doc/add_wakeup_source_usage_precautions' into 'master'
change(doc): added more usage notes about PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP Closes IDF-12166 See merge request espressif/esp-idf!36879
2 parents bbd9ace + 0f69fda commit e57f02e

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

components/esp_hw_support/include/esp_sleep.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,10 @@ __attribute__((deprecated("please use 'esp_sleep_enable_ext1_wakeup_io' and 'esp
433433
*
434434
* This function enables an IO pin to wake up the chip from deep sleep.
435435
*
436-
* @note This function does not modify pin configuration. The pins are
437-
* configured inside esp_deep_sleep_start, immediately before entering sleep mode.
436+
* @note 1.This function does not modify pin configuration. The pins are configured
437+
* inside `esp_deep_sleep_start`, immediately before entering sleep mode.
438+
* 2.This function is also applicable to waking up the lightsleep when the peripheral
439+
* power domain is powered off, see PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP in menuconfig.
438440
*
439441
* @note You don't need to worry about pull-up or pull-down resistors before
440442
* using this function because the ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS
@@ -469,11 +471,17 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee
469471
* wakeup level, for each GPIO which is used for wakeup.
470472
* Then call this function to enable wakeup feature.
471473
*
472-
* @note On ESP32, GPIO wakeup source can not be used together with touch or ULP wakeup sources.
474+
* @note 1. On ESP32, GPIO wakeup source can not be used together with touch or ULP wakeup sources.
475+
* 2. If PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP is enabled (if target supported),
476+
* this API is unavailable since the GPIO module is powered down during sleep.
477+
* You can use `esp_deep_sleep_enable_gpio_wakeup` instead, or use EXT1 wakeup source
478+
* by `esp_sleep_enable_ext1_wakeup_io` to achieve the same function.
479+
* (Only GPIOs which have RTC functionality can be used)
473480
*
474481
* @return
475482
* - ESP_OK on success
476483
* - ESP_ERR_INVALID_STATE if wakeup triggers conflict
484+
* - ESP_ERR_NOT_SUPPORTED if GPIO wakeup source is not available
477485
*/
478486
esp_err_t esp_sleep_enable_gpio_wakeup(void);
479487

@@ -485,12 +493,15 @@ esp_err_t esp_sleep_enable_gpio_wakeup(void);
485493
* Wakeup from light sleep takes some time, so not every character sent
486494
* to the UART can be received by the application.
487495
*
488-
* @note ESP32 does not support wakeup from UART2.
496+
* @note 1. ESP32 does not support wakeup from UART2.
497+
* 2. If PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP is enabled (if target supported),
498+
* this API is unavailable since the UART module is powered down during sleep.
489499
*
490500
* @param uart_num UART port to wake up from
491501
* @return
492502
* - ESP_OK on success
493503
* - ESP_ERR_INVALID_ARG if wakeup from given UART is not supported
504+
* - ESP_ERR_NOT_SUPPORTED if UART wakeup source is not available
494505
*/
495506
esp_err_t esp_sleep_enable_uart_wakeup(int uart_num);
496507

components/esp_hw_support/sleep_modes.c

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

20562056
esp_err_t esp_sleep_enable_gpio_wakeup(void)
20572057
{
2058+
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
2059+
ESP_LOGE(TAG, "%s wakeup source is not available if the peripheral power domain is powered down in sleep", "GPIO");
2060+
return ESP_ERR_NOT_SUPPORTED;
2061+
#endif
20582062
#if CONFIG_IDF_TARGET_ESP32
20592063
if (s_config.wakeup_triggers & (RTC_TOUCH_TRIG_EN | RTC_ULP_TRIG_EN)) {
20602064
ESP_LOGE(TAG, "Conflicting wake-up triggers: touch / ULP");
@@ -2067,6 +2071,10 @@ esp_err_t esp_sleep_enable_gpio_wakeup(void)
20672071

20682072
esp_err_t esp_sleep_enable_uart_wakeup(int uart_num)
20692073
{
2074+
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
2075+
ESP_LOGE(TAG, "%s wakeup source is not available if the peripheral power domain is powered down in sleep", "UART");
2076+
return ESP_ERR_NOT_SUPPORTED;
2077+
#endif
20702078
if (uart_num == UART_NUM_0) {
20712079
s_config.wakeup_triggers |= RTC_UART0_TRIG_EN;
20722080
} 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)