change(doc): added more usage notes about PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP

This commit is contained in:
wuzhenghui 2025-02-11 21:54:17 +08:00
parent de053738e1
commit 0f69fda3d5
No known key found for this signature in database
GPG Key ID: 3EFEDECDEBA39BB9
3 changed files with 35 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -429,8 +429,10 @@ __attribute__((deprecated("please use 'esp_sleep_enable_ext1_wakeup_io' and 'esp
* *
* This function enables an IO pin to wake up the chip from deep sleep. * 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 * @note 1.This function does not modify pin configuration. The pins are configured
* configured inside esp_deep_sleep_start, immediately before entering sleep mode. * 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 * @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 * 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
* wakeup level, for each GPIO which is used for wakeup. * wakeup level, for each GPIO which is used for wakeup.
* Then call this function to enable wakeup feature. * 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 * @return
* - ESP_OK on success * - ESP_OK on success
* - ESP_ERR_INVALID_STATE if wakeup triggers conflict * - ESP_ERR_INVALID_STATE if wakeup triggers conflict
* - ESP_ERR_NOT_SUPPORTED if GPIO wakeup source is not available
*/ */
esp_err_t esp_sleep_enable_gpio_wakeup(void); esp_err_t esp_sleep_enable_gpio_wakeup(void);
@ -481,12 +489,15 @@ esp_err_t esp_sleep_enable_gpio_wakeup(void);
* Wakeup from light sleep takes some time, so not every character sent * Wakeup from light sleep takes some time, so not every character sent
* to the UART can be received by the application. * 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 * @param uart_num UART port to wake up from
* @return * @return
* - ESP_OK on success * - ESP_OK on success
* - ESP_ERR_INVALID_ARG if wakeup from given UART is not supported * - ESP_ERR_INVALID_ARG if wakeup from given UART is not supported
* - ESP_ERR_NOT_SUPPORTED if UART wakeup source is not available
*/ */
esp_err_t esp_sleep_enable_uart_wakeup(int uart_num); esp_err_t esp_sleep_enable_uart_wakeup(int uart_num);

View File

@ -2076,6 +2076,10 @@ 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) esp_err_t esp_sleep_enable_gpio_wakeup(void)
{ {
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
ESP_LOGE(TAG, "%s wakeup source is not available if the peripheral power domain is powered down in sleep", "GPIO");
return ESP_ERR_NOT_SUPPORTED;
#endif
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32
if (s_config.wakeup_triggers & (RTC_TOUCH_TRIG_EN | RTC_ULP_TRIG_EN)) { if (s_config.wakeup_triggers & (RTC_TOUCH_TRIG_EN | RTC_ULP_TRIG_EN)) {
ESP_LOGE(TAG, "Conflicting wake-up triggers: touch / ULP"); ESP_LOGE(TAG, "Conflicting wake-up triggers: touch / ULP");
@ -2088,6 +2092,10 @@ esp_err_t esp_sleep_enable_gpio_wakeup(void)
esp_err_t esp_sleep_enable_uart_wakeup(int uart_num) esp_err_t esp_sleep_enable_uart_wakeup(int uart_num)
{ {
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
ESP_LOGE(TAG, "%s wakeup source is not available if the peripheral power domain is powered down in sleep", "UART");
return ESP_ERR_NOT_SUPPORTED;
#endif
if (uart_num == UART_NUM_0) { if (uart_num == UART_NUM_0) {
s_config.wakeup_triggers |= RTC_UART0_TRIG_EN; s_config.wakeup_triggers |= RTC_UART0_TRIG_EN;
} else if (uart_num == UART_NUM_1) { } else if (uart_num == UART_NUM_1) {

View File

@ -146,12 +146,17 @@ menu "Power Management"
select PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP if !SOC_CPU_IN_TOP_DOMAIN select PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP if !SOC_CPU_IN_TOP_DOMAIN
default n #TODO: enable by default if periph init/deinit management supported (WIFI-5252) default n #TODO: enable by default if periph init/deinit management supported (WIFI-5252)
help help
If enabled, digital peripherals will be powered down in light sleep, it will reduce sleep If enabled, digital peripherals will be powered down in light sleep, all related peripherals will
current consumption by about 100 uA. Chip will save/restore register context at sleep/wake not be available during sleep, including wake-up sources from the peripherals (For detailed availability
time to keep the system running. Enabling this option will increase static RAM and heap usage, information, see the note of the corresponding wakeup source enable function).
the actual cost depends on the peripherals you have initialized. In order to save/restore the The chip will automatically save/restore register context during sleep/wakeup to make the upper layer
context of the necessary hardware for FreeRTOS to run, it will need at least 4.55 KB free heap user unaware of the peripheral powerdown during sleep. Enabling this option will increase static RAM and
at sleep time. Otherwise sleep will not power down the peripherals. 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 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, all peripherals. When the digital peripherals are powered off and a sleep and wake-up is completed,