From 85601ccb69888aadcbbc28e471612cb52b774b7d Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Thu, 15 May 2025 16:30:45 +0800 Subject: [PATCH 1/4] change(soc): rename peripheral powerdowned sleep wakeable IO soc_caps rename SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK to SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_MASK rename SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT to SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_PIN_CNT rename SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP to SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP --- .../esp_driver_gpio/include/driver/gpio.h | 4 ++-- components/esp_driver_gpio/src/gpio.c | 4 ++-- .../test_apps/gpio/main/test_rtcio.c | 4 ++-- components/esp_driver_ledc/src/ledc.c | 2 +- .../esp_hal_gpio/include/hal/gpio_hal.h | 4 ++-- .../esp_hal_gpio/include/hal/rtc_io_hal.h | 4 ++-- components/esp_hal_pmu/include/hal/rtc_hal.h | 3 ++- components/esp_hw_support/include/esp_sleep.h | 8 ++++---- components/esp_hw_support/sleep_gpio.c | 4 ++-- components/esp_hw_support/sleep_modes.c | 20 +++++++++---------- .../wakeup_tests/main/src/io_wakeup_cmd.c | 8 ++++---- .../esp32c2/include/soc/Kconfig.soc_caps.in | 6 +++--- components/soc/esp32c2/include/soc/soc_caps.h | 12 +++++------ .../esp32c3/include/soc/Kconfig.soc_caps.in | 6 +++--- components/soc/esp32c3/include/soc/soc_caps.h | 12 +++++------ .../esp32c5/include/soc/Kconfig.soc_caps.in | 6 +++--- components/soc/esp32c5/include/soc/soc_caps.h | 9 +++++---- .../esp32c6/include/soc/Kconfig.soc_caps.in | 6 +++--- components/soc/esp32c6/include/soc/soc_caps.h | 9 +++++---- .../esp32c61/include/soc/Kconfig.soc_caps.in | 6 +++--- .../soc/esp32c61/include/soc/soc_caps.h | 9 +++++---- components/soc/esp32h2/include/soc/soc_caps.h | 2 +- .../esp32h4/include/soc/Kconfig.soc_caps.in | 6 +++--- components/soc/esp32h4/include/soc/soc_caps.h | 7 ++++--- .../esp32p4/include/soc/Kconfig.soc_caps.in | 6 +++--- components/soc/esp32p4/include/soc/soc_caps.h | 9 +++++---- docs/en/api-reference/system/sleep_modes.rst | 6 +++--- .../api-reference/system/sleep_modes.rst | 6 +++--- .../system/deep_sleep/main/Kconfig.projbuild | 2 +- 29 files changed, 98 insertions(+), 92 deletions(-) diff --git a/components/esp_driver_gpio/include/driver/gpio.h b/components/esp_driver_gpio/include/driver/gpio.h index 6c8a02458d..35c5f6843d 100644 --- a/components/esp_driver_gpio/include/driver/gpio.h +++ b/components/esp_driver_gpio/include/driver/gpio.h @@ -565,7 +565,7 @@ esp_err_t gpio_sleep_set_direction(gpio_num_t gpio_num, gpio_mode_t mode); */ esp_err_t gpio_sleep_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull); -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP #define GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num) ((gpio_num >= 0) && \ (((1ULL << (gpio_num)) & SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK) != 0)) @@ -596,7 +596,7 @@ esp_err_t gpio_deep_sleep_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t int */ esp_err_t gpio_deep_sleep_wakeup_disable(gpio_num_t gpio_num); -#endif //SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP +#endif //SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP /** * @brief Dump IO configuration information to console diff --git a/components/esp_driver_gpio/src/gpio.c b/components/esp_driver_gpio/src/gpio.c index fe078d4bae..3c7f455872 100644 --- a/components/esp_driver_gpio/src/gpio.c +++ b/components/esp_driver_gpio/src/gpio.c @@ -1017,7 +1017,7 @@ esp_err_t gpio_sleep_sel_dis(gpio_num_t gpio_num) return ESP_OK; } -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED esp_err_t gpio_deep_sleep_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type) { if (!GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num)) { @@ -1057,7 +1057,7 @@ esp_err_t gpio_deep_sleep_wakeup_disable(gpio_num_t gpio_num) portEXIT_CRITICAL(&gpio_context.gpio_spinlock); return ESP_OK; } -#endif // SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED +#endif // SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED esp_err_t gpio_get_io_config(gpio_num_t gpio_num, gpio_io_config_t *out_io_config) { diff --git a/components/esp_driver_gpio/test_apps/gpio/main/test_rtcio.c b/components/esp_driver_gpio/test_apps/gpio/main/test_rtcio.c index ebc87b58a0..bb7bbfa86c 100644 --- a/components/esp_driver_gpio/test_apps/gpio/main/test_rtcio.c +++ b/components/esp_driver_gpio/test_apps/gpio/main/test_rtcio.c @@ -235,7 +235,7 @@ TEST_CASE("RTCIO_output_hold_test", "[rtcio]") } #endif //SOC_RTCIO_HOLD_SUPPORTED -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT > 0) +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT > 0) /* * test interrupt functionality */ @@ -275,7 +275,7 @@ TEST_CASE("RTCIO_interrupt_test", "[rtcio]") rtcio_ll_intr_enable(test_io, GPIO_INTR_DISABLE); TEST_ESP_OK(rtc_gpio_deinit(test_io)); } -#endif //SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT > 0) +#endif //SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT > 0) #endif //SOC_RTCIO_INPUT_OUTPUT_SUPPORTED #if SOC_DEEP_SLEEP_SUPPORTED diff --git a/components/esp_driver_ledc/src/ledc.c b/components/esp_driver_ledc/src/ledc.c index b030bf18eb..3b46aa63ab 100644 --- a/components/esp_driver_ledc/src/ledc.c +++ b/components/esp_driver_ledc/src/ledc.c @@ -1004,7 +1004,7 @@ esp_err_t ledc_channel_config(const ledc_channel_config_t *ledc_conf) // To workaround DIG-399, all LP IOs are held when LP_PERIPH is powered off to ensure EXT wakeup functionality // But holding LP IOs will cause LEDC signal cannot output on the pad during sleep // Therefore, we will force LP periph xpd in such case - if ((1ULL << gpio_num) & SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK) { + if (GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO(gpio_num)) { esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); } #endif diff --git a/components/esp_hal_gpio/include/hal/gpio_hal.h b/components/esp_hal_gpio/include/hal/gpio_hal.h index b878f81dc6..80fe43a33a 100644 --- a/components/esp_hal_gpio/include/hal/gpio_hal.h +++ b/components/esp_hal_gpio/include/hal/gpio_hal.h @@ -497,7 +497,7 @@ void gpio_hal_matrix_out(gpio_hal_context_t *hal, uint32_t gpio_num, uint32_t si */ #define gpio_hal_sleep_output_enable(hal, gpio_num) gpio_ll_sleep_output_enable((hal)->dev, gpio_num) -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT == 0) && SOC_DEEP_SLEEP_SUPPORTED +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT == 0) && SOC_DEEP_SLEEP_SUPPORTED /** * @brief Enable GPIO deep-sleep wake-up function. * @@ -524,7 +524,7 @@ void gpio_hal_matrix_out(gpio_hal_context_t *hal, uint32_t gpio_num, uint32_t si * @return True if the pin is enabled to wake up from deep-sleep */ #define gpio_hal_deepsleep_wakeup_is_enabled(hal, gpio_num) gpio_ll_deepsleep_wakeup_is_enabled((hal)->dev, gpio_num) -#endif //SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT == 0) && SOC_DEEP_SLEEP_SUPPORTED +#endif //SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT == 0) #if SOC_GPIO_SUPPORT_PIN_HYS_FILTER /** diff --git a/components/esp_hal_gpio/include/hal/rtc_io_hal.h b/components/esp_hal_gpio/include/hal/rtc_io_hal.h index a0d94d573f..bdfa4600f2 100644 --- a/components/esp_hal_gpio/include/hal/rtc_io_hal.h +++ b/components/esp_hal_gpio/include/hal/rtc_io_hal.h @@ -312,7 +312,7 @@ void rtcio_hal_isolate(int rtc_num); #endif //SOC_RTCIO_PIN_COUNT > 0 -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT > 0) +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT > 0) #define gpio_hal_deepsleep_wakeup_enable(hal, gpio_num, intr_type) rtcio_hal_wakeup_enable(rtc_io_num_map[gpio_num], intr_type) #define gpio_hal_deepsleep_wakeup_disable(hal, gpio_num) rtcio_hal_wakeup_disable(rtc_io_num_map[gpio_num]) @@ -341,7 +341,7 @@ void rtcio_hal_isolate(int rtc_num); */ #define rtcio_hal_clear_interrupt_status() rtcio_ll_clear_interrupt_status() -#endif //SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT > 0) +#endif //SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT > 0) #ifdef __cplusplus } diff --git a/components/esp_hal_pmu/include/hal/rtc_hal.h b/components/esp_hal_pmu/include/hal/rtc_hal.h index e6ffb848cd..21ab37593b 100644 --- a/components/esp_hal_pmu/include/hal/rtc_hal.h +++ b/components/esp_hal_pmu/include/hal/rtc_hal.h @@ -80,7 +80,8 @@ typedef struct rtc_cntl_sleep_retent { #endif #endif // SOC_PM_SUPPORT_EXT1_WAKEUP -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT == 0) && SOC_DEEP_SLEEP_SUPPORTED +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT == 0) && SOC_DEEP_SLEEP_SUPPORTED + #define rtc_hal_gpio_get_wakeup_status() rtc_cntl_ll_gpio_get_wakeup_status() #define rtc_hal_gpio_clear_wakeup_status() rtc_cntl_ll_gpio_clear_wakeup_status() #endif diff --git a/components/esp_hw_support/include/esp_sleep.h b/components/esp_hw_support/include/esp_sleep.h index 89c2bab628..d658c1f652 100644 --- a/components/esp_hw_support/include/esp_sleep.h +++ b/components/esp_hw_support/include/esp_sleep.h @@ -41,7 +41,7 @@ typedef enum { #endif #endif -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP typedef enum { ESP_GPIO_WAKEUP_GPIO_LOW = 0, ESP_GPIO_WAKEUP_GPIO_HIGH = 1 @@ -452,7 +452,7 @@ __attribute__((deprecated("please use 'esp_sleep_enable_ext1_wakeup_io' and 'esp #endif // SOC_PM_SUPPORT_EXT1_WAKEUP_MODE_PER_PIN #endif // SOC_PM_SUPPORT_EXT1_WAKEUP -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP /** * @brief Enable wakeup using specific gpio pins * @@ -581,7 +581,7 @@ esp_err_t esp_sleep_disable_wifi_beacon_wakeup(void); */ uint64_t esp_sleep_get_ext1_wakeup_status(void); -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP /** * @brief Get the bit mask of GPIOs which caused wakeup (gpio) * @@ -590,7 +590,7 @@ uint64_t esp_sleep_get_ext1_wakeup_status(void); * @return bit mask, if GPIOn caused wakeup, BIT(n) will be set */ uint64_t esp_sleep_get_gpio_wakeup_status(void); -#endif //SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP +#endif //SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP /** * @brief Configure power domain options for sleep mode diff --git a/components/esp_hw_support/sleep_gpio.c b/components/esp_hw_support/sleep_gpio.c index deebc5262e..cfd9229970 100644 --- a/components/esp_hw_support/sleep_gpio.c +++ b/components/esp_hw_support/sleep_gpio.c @@ -244,8 +244,8 @@ void esp_deep_sleep_wakeup_io_reset(void) } #endif -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP - uint32_t dl_io_mask = SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK; +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP + uint32_t dl_io_mask = SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_MASK; gpio_hal_context_t gpio_hal = { .dev = GPIO_HAL_GET_HW(GPIO_PORT_0) }; diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index e6929d5b0a..44ef5212b4 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -273,9 +273,9 @@ typedef struct { uint32_t ext0_trigger_level : 1; uint32_t ext0_rtc_gpio_num : 5; #endif -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP - uint32_t gpio_wakeup_mask : SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT; // Only RTC_GPIO supports wakeup deepsleep - uint32_t gpio_trigger_mode : SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT; +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP + uint32_t gpio_wakeup_mask : SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_PIN_CNT; + uint32_t gpio_trigger_mode : SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_PIN_CNT; #endif uint32_t sleep_time_adjustment; uint32_t ccount_ticks_record; @@ -364,7 +364,7 @@ static void touch_wakeup_prepare(void); #if SOC_VBAT_SUPPORTED static void vbat_under_volt_wakeup_prepare(void); #endif -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED static void gpio_deep_sleep_wakeup_prepare(void); #endif @@ -987,7 +987,7 @@ static esp_err_t SLEEP_FN_ATTR esp_sleep_start(uint32_t sleep_flags, uint32_t cl // for !(s_config.wakeup_triggers & RTC_EXT1_TRIG_EN), ext1 wakeup will be turned off in hardware in the real call to sleep #endif -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED if (deep_sleep && (s_config.wakeup_triggers & RTC_GPIO_TRIG_EN)) { gpio_deep_sleep_wakeup_prepare(); } @@ -1841,7 +1841,7 @@ bool esp_sleep_is_valid_wakeup_gpio(gpio_num_t gpio_num) { #if SOC_RTCIO_PIN_COUNT > 0 return RTC_GPIO_IS_VALID_GPIO(gpio_num); -#elif SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP +#elif SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP return GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num); #else return false; @@ -2069,7 +2069,7 @@ uint64_t esp_sleep_get_ext1_wakeup_status(void) #endif // SOC_PM_SUPPORT_EXT1_WAKEUP && SOC_RTCIO_PIN_COUNT > 0 -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED uint64_t esp_sleep_get_gpio_wakeup_status(void) { if (!(esp_sleep_get_wakeup_causes() & BIT(ESP_SLEEP_WAKEUP_GPIO))) { @@ -2080,7 +2080,7 @@ uint64_t esp_sleep_get_gpio_wakeup_status(void) static void gpio_deep_sleep_wakeup_prepare(void) { - uint32_t valid_wake_io_mask = SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK; + uint32_t valid_wake_io_mask = SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_MASK; for (gpio_num_t gpio_idx = __builtin_ctz(valid_wake_io_mask); valid_wake_io_mask >> gpio_idx; gpio_idx++) { if ((s_config.gpio_wakeup_mask & BIT64(gpio_idx)) == 0) { continue; @@ -2114,7 +2114,7 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee gpio_int_type_t intr_type = ((mode == ESP_GPIO_WAKEUP_GPIO_LOW) ? GPIO_INTR_LOW_LEVEL : GPIO_INTR_HIGH_LEVEL); esp_err_t err = ESP_OK; - uint64_t invalid_io_mask = gpio_pin_mask & ~SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK; + uint64_t invalid_io_mask = gpio_pin_mask & ~SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_MASK; if (invalid_io_mask != 0) { for (gpio_num_t gpio_idx = __builtin_ctzll(invalid_io_mask); invalid_io_mask >> gpio_idx; gpio_idx++) { if (invalid_io_mask & BIT64(gpio_idx)) { @@ -2141,7 +2141,7 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee return err; } -#endif //SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED +#endif //SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED esp_err_t esp_sleep_enable_gpio_wakeup(void) { diff --git a/components/esp_hw_support/test_apps/wakeup_tests/main/src/io_wakeup_cmd.c b/components/esp_hw_support/test_apps/wakeup_tests/main/src/io_wakeup_cmd.c index de140f84a1..01d8d4934d 100644 --- a/components/esp_hw_support/test_apps/wakeup_tests/main/src/io_wakeup_cmd.c +++ b/components/esp_hw_support/test_apps/wakeup_tests/main/src/io_wakeup_cmd.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -142,7 +142,7 @@ static void register_ext1_wakeup(void) } #endif -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP static struct { struct arg_int *pin; struct arg_int *level; @@ -383,7 +383,7 @@ static int process_get_wakeup_cause(int argc, char **argv) if (causes & BIT(ESP_SLEEP_WAKEUP_GPIO)) { if (esp_reset_reason() == ESP_RST_DEEPSLEEP) { -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP uint64_t wakeup_pin_mask = esp_sleep_get_gpio_wakeup_status(); if (wakeup_pin_mask != 0) { int pin = __builtin_ffsll(wakeup_pin_mask) - 1; @@ -440,7 +440,7 @@ void register_io_wakeup_cmd(void) #endif register_gpio_control(); register_gpio_wakeup(); -#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP register_rtcio_wakeup(); #endif register_get_wakeup_cause(); diff --git a/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in index 123858b06f..200eb9a8f6 100644 --- a/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in @@ -291,7 +291,7 @@ config SOC_GPIO_SUPPORT_FORCE_HOLD bool default y -config SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP +config SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP bool default y @@ -303,11 +303,11 @@ config SOC_GPIO_OUT_RANGE_MAX int default 20 -config SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK +config SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_MASK int default 0 -config SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT +config SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_PIN_CNT int default 6 diff --git a/components/soc/esp32c2/include/soc/soc_caps.h b/components/soc/esp32c2/include/soc/soc_caps.h index ca7140b874..20a3417d53 100644 --- a/components/soc/esp32c2/include/soc/soc_caps.h +++ b/components/soc/esp32c2/include/soc/soc_caps.h @@ -126,21 +126,21 @@ #define SOC_GPIO_PIN_COUNT 21 #define SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER 1 -// Target has no full RTC IO subsystem, GPIO0~5 remain RTC function (powered by VDD3V3_RTC, and can be used as deep-sleep wakeup pins) +// Target has no full RTC IO subsystem, GPIO0~5 remain RTC function (powered by VDD3V3_RTC, and can be used as HP peripheral powerdown-ed sleep wakeup pins) // Force hold is a new function of ESP32-C2 #define SOC_GPIO_SUPPORT_FORCE_HOLD (1) -// GPIO0~5 on ESP32-C2 can support chip deep sleep wakeup -#define SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP (1) - +// GPIO0~5 on ESP32-C2 can support chip HP peripheral powerdown-ed sleep wakeup +#define SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP (1) +#define SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP #define SOC_GPIO_VALID_GPIO_MASK ((1U< Date: Thu, 15 May 2025 17:05:45 +0800 Subject: [PATCH 2/4] change(esp_driver_gpio): deprecate gpio_deep_sleep_wakeup_enable/disable API rename gpio_deep_sleep_wakeup_enable to gpio_wakeup_enable_on_hp_periph_powerdown_sleep rename gpio_deep_sleep_wakeup_disable to gpio_wakeup_disable_on_hp_periph_powerdown_sleep rename GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO to GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO --- .../esp_driver_gpio/include/driver/gpio.h | 12 +++--- components/esp_driver_gpio/src/gpio.c | 10 ++--- components/esp_hw_support/sleep_modes.c | 8 ++-- .../wakeup_tests/main/src/io_wakeup_cmd.c | 2 +- .../release-6.x/6.0/peripherals.rst | 42 +++++++++++++++++++ .../release-6.x/6.0/peripherals.rst | 42 +++++++++++++++++++ 6 files changed, 100 insertions(+), 16 deletions(-) diff --git a/components/esp_driver_gpio/include/driver/gpio.h b/components/esp_driver_gpio/include/driver/gpio.h index 35c5f6843d..13fbe12407 100644 --- a/components/esp_driver_gpio/include/driver/gpio.h +++ b/components/esp_driver_gpio/include/driver/gpio.h @@ -567,11 +567,11 @@ esp_err_t gpio_sleep_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull); #if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP -#define GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num) ((gpio_num >= 0) && \ - (((1ULL << (gpio_num)) & SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK) != 0)) +#define GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO(gpio_num) ((gpio_num >= 0) && \ + (((1ULL << (gpio_num)) & SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_MASK) != 0)) /** - * @brief Enable GPIO deep-sleep wake-up function. + * @brief Enable GPIO wake-up function on peripheral powerdowned sleep (including deepsleep and peripheral powerdowned lightsleep). * * @param gpio_num GPIO number. * @@ -583,10 +583,10 @@ esp_err_t gpio_sleep_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull); * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error */ -esp_err_t gpio_deep_sleep_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type); +esp_err_t gpio_wakeup_enable_on_hp_periph_powerdown_sleep(gpio_num_t gpio_num, gpio_int_type_t intr_type); /** - * @brief Disable GPIO deep-sleep wake-up function. + * @brief Disable GPIO peripheral powerdowned sleep (including deepsleep and peripheral powerdowned lightsleep) wake-up function. * * @param gpio_num GPIO number * @@ -594,7 +594,7 @@ esp_err_t gpio_deep_sleep_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t int * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error */ -esp_err_t gpio_deep_sleep_wakeup_disable(gpio_num_t gpio_num); +esp_err_t gpio_wakeup_disable_on_hp_periph_powerdown_sleep(gpio_num_t gpio_num); #endif //SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP diff --git a/components/esp_driver_gpio/src/gpio.c b/components/esp_driver_gpio/src/gpio.c index 3c7f455872..c1ced24ac9 100644 --- a/components/esp_driver_gpio/src/gpio.c +++ b/components/esp_driver_gpio/src/gpio.c @@ -1018,9 +1018,9 @@ esp_err_t gpio_sleep_sel_dis(gpio_num_t gpio_num) } #if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED -esp_err_t gpio_deep_sleep_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type) +esp_err_t gpio_wakeup_enable_on_hp_periph_powerdown_sleep(gpio_num_t gpio_num, gpio_int_type_t intr_type) { - if (!GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num)) { + if (!GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO(gpio_num)) { ESP_LOGE(GPIO_TAG, "GPIO %d does not support deep sleep wakeup", gpio_num); return ESP_ERR_INVALID_ARG; } @@ -1040,9 +1040,9 @@ esp_err_t gpio_deep_sleep_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t int return ESP_OK; } -esp_err_t gpio_deep_sleep_wakeup_disable(gpio_num_t gpio_num) +esp_err_t gpio_wakeup_disable_on_hp_periph_powerdown_sleep(gpio_num_t gpio_num) { - if (!GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num)) { + if (!GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO(gpio_num)) { ESP_LOGE(GPIO_TAG, "GPIO %d does not support deep sleep wakeup", gpio_num); return ESP_ERR_INVALID_ARG; } @@ -1057,7 +1057,7 @@ esp_err_t gpio_deep_sleep_wakeup_disable(gpio_num_t gpio_num) portEXIT_CRITICAL(&gpio_context.gpio_spinlock); return ESP_OK; } -#endif // SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED +#endif // SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP esp_err_t gpio_get_io_config(gpio_num_t gpio_num, gpio_io_config_t *out_io_config) { diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index 44ef5212b4..4e8b340e42 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -365,7 +365,7 @@ static void touch_wakeup_prepare(void); static void vbat_under_volt_wakeup_prepare(void); #endif #if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED -static void gpio_deep_sleep_wakeup_prepare(void); +static void esp_sleep_gpio_wakeup_prepare_on_hp_periph_powerdown(void); #endif #if ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB && SOC_DEEP_SLEEP_SUPPORTED @@ -989,7 +989,7 @@ static esp_err_t SLEEP_FN_ATTR esp_sleep_start(uint32_t sleep_flags, uint32_t cl #if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED if (deep_sleep && (s_config.wakeup_triggers & RTC_GPIO_TRIG_EN)) { - gpio_deep_sleep_wakeup_prepare(); + esp_sleep_gpio_wakeup_prepare_on_hp_periph_powerdown(); } #endif @@ -2078,7 +2078,7 @@ uint64_t esp_sleep_get_gpio_wakeup_status(void) return rtc_hal_gpio_get_wakeup_status(); } -static void gpio_deep_sleep_wakeup_prepare(void) +static void esp_sleep_gpio_wakeup_prepare_on_hp_periph_powerdown(void) { uint32_t valid_wake_io_mask = SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_MASK; for (gpio_num_t gpio_idx = __builtin_ctz(valid_wake_io_mask); valid_wake_io_mask >> gpio_idx; gpio_idx++) { @@ -2128,7 +2128,7 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee if ((gpio_pin_mask & BIT64(gpio_idx)) == 0) { continue; } - err = gpio_deep_sleep_wakeup_enable(gpio_idx, intr_type); + err = gpio_wakeup_enable_on_hp_periph_powerdown_sleep(gpio_idx, intr_type); s_config.gpio_wakeup_mask |= BIT(gpio_idx); if (mode == ESP_GPIO_WAKEUP_GPIO_HIGH) { diff --git a/components/esp_hw_support/test_apps/wakeup_tests/main/src/io_wakeup_cmd.c b/components/esp_hw_support/test_apps/wakeup_tests/main/src/io_wakeup_cmd.c index 01d8d4934d..5bf7b818cf 100644 --- a/components/esp_hw_support/test_apps/wakeup_tests/main/src/io_wakeup_cmd.c +++ b/components/esp_hw_support/test_apps/wakeup_tests/main/src/io_wakeup_cmd.c @@ -177,7 +177,7 @@ static int process_rtcio_wakeup(int argc, char **argv) ESP_LOGI(TAG, "io_wakeup_level = %d\n", io_wakeup_level); if (rtcio_wakeup_args.disable->count) { - ESP_ERROR_CHECK(gpio_deep_sleep_wakeup_disable(io_wakeup_num)); + ESP_ERROR_CHECK(gpio_wakeup_disable_on_hp_periph_powerdown_sleep(io_wakeup_num)); } else { gpio_config_t config = { .pin_bit_mask = BIT64(io_wakeup_num), diff --git a/docs/en/migration-guides/release-6.x/6.0/peripherals.rst b/docs/en/migration-guides/release-6.x/6.0/peripherals.rst index 65a7634469..d7ce411ca5 100644 --- a/docs/en/migration-guides/release-6.x/6.0/peripherals.rst +++ b/docs/en/migration-guides/release-6.x/6.0/peripherals.rst @@ -124,6 +124,48 @@ GPIO - Added the :cpp:type:`esp_err_t` return type to :func:`gpio_uninstall_isr_service`. +GPIO Deep Sleep Wakeup APIs Removed +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following GPIO driver APIs have been removed: + +- :func:`gpio_deep_sleep_wakeup_enable` - Use :func:`gpio_wakeup_enable_on_hp_periph_powerdown_sleep` instead +- :func:`gpio_deep_sleep_wakeup_disable` - Use :func:`gpio_wakeup_disable_on_hp_periph_powerdown_sleep` instead + +The deprecated macro ``GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO()`` has been removed. Use ``GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO()`` instead. + +**Migration Example:** + +Old code: + +.. code-block:: c + + #include "driver/gpio.h" + + // Enable GPIO wakeup + gpio_deep_sleep_wakeup_enable(GPIO_NUM_0, GPIO_INTR_LOW_LEVEL); + + // Check validity + if (GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(GPIO_NUM_0)) { + // ... + } + +New code: + +.. code-block:: c + + #include "driver/gpio.h" + + // Enable GPIO wakeup (works for both deep sleep and light sleep with peripheral powerdown) + gpio_wakeup_enable_on_hp_periph_powerdown_sleep(GPIO_NUM_0, GPIO_INTR_LOW_LEVEL); + + // Check validity + if (GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO(GPIO_NUM_0)) { + // ... + } + +For more details, see the :ref:`GPIO Wakeup API Changes ` section in the System migration guide. + LEDC ---- diff --git a/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst b/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst index 1616812998..0952332d1a 100644 --- a/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst +++ b/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst @@ -124,6 +124,48 @@ GPIO - 为 :func:`gpio_uninstall_isr_service` 添加了 :cpp:type:`esp_err_t` 返回类型。 +GPIO 深度睡眠唤醒 API 已移除 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +以下 GPIO 驱动 API 已被移除: + +- :func:`gpio_deep_sleep_wakeup_enable` - 请使用 :func:`gpio_wakeup_enable_on_hp_periph_powerdown_sleep` 替代 +- :func:`gpio_deep_sleep_wakeup_disable` - 请使用 :func:`gpio_wakeup_disable_on_hp_periph_powerdown_sleep` 替代 + +已弃用的宏 ``GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO()`` 已被移除。请使用 ``GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO()`` 替代。 + +**迁移示例:** + +旧代码: + +.. code-block:: c + + #include "driver/gpio.h" + + // 启用 GPIO 唤醒 + gpio_deep_sleep_wakeup_enable(GPIO_NUM_0, GPIO_INTR_LOW_LEVEL); + + // 检查有效性 + if (GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(GPIO_NUM_0)) { + // ... + } + +新代码: + +.. code-block:: c + + #include "driver/gpio.h" + + // 启用 GPIO 唤醒(同时支持深度睡眠和外设电源域掉电时的 Light Sleep) + gpio_wakeup_enable_on_hp_periph_powerdown_sleep(GPIO_NUM_0, GPIO_INTR_LOW_LEVEL); + + // 检查 GPIO 外设掉电的睡眠唤醒有效性 + if (GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO(GPIO_NUM_0)) { + // ... + } + +更多详细信息,请参阅系统迁移指南中的 :ref:`GPIO 唤醒 API 变更 ` 部分。 + LEDC ---- From fc7cf9967a5fb3ca68266344446c5de8d5cb817e Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Tue, 29 Jul 2025 17:42:46 +0800 Subject: [PATCH 3/4] change(hal): deprecate 'gpio deep sleep wakeup' naming in hal rename `gpio_hal_deepsleep_wakeup_enable/disable` to `gpio_hal_wakeup_enable/disable_on_hp_periph_powerdown_sleep` rename `gpio_hal_deepsleep_wakeup_is_enabled` to `gpio_hal_wakeup_is_enabled_on_hp_periph_powerdown_sleep` rename `gpio_ll_deepsleep_wakeup_enable/disable` to `gpio_ll_wakeup_enable/disable_on_hp_periph_powerdown_sleep` --- components/esp_driver_gpio/src/gpio.c | 12 ++++++------ .../esp_hal_gpio/esp32c2/include/hal/gpio_ll.h | 14 +++++++------- .../esp_hal_gpio/esp32c3/include/hal/gpio_ll.h | 14 +++++++------- .../esp_hal_gpio/esp32h2/include/hal/gpio_ll.h | 14 +++++++------- .../esp_hal_gpio/esp32h21/include/hal/gpio_ll.h | 14 +++++++------- components/esp_hal_gpio/include/hal/gpio_hal.h | 16 ++++++++-------- components/esp_hal_gpio/include/hal/rtc_io_hal.h | 6 +++--- components/esp_hw_support/sleep_gpio.c | 4 ++-- 8 files changed, 47 insertions(+), 47 deletions(-) diff --git a/components/esp_driver_gpio/src/gpio.c b/components/esp_driver_gpio/src/gpio.c index c1ced24ac9..63e106e94f 100644 --- a/components/esp_driver_gpio/src/gpio.c +++ b/components/esp_driver_gpio/src/gpio.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -1017,11 +1017,11 @@ esp_err_t gpio_sleep_sel_dis(gpio_num_t gpio_num) return ESP_OK; } -#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP esp_err_t gpio_wakeup_enable_on_hp_periph_powerdown_sleep(gpio_num_t gpio_num, gpio_int_type_t intr_type) { if (!GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO(gpio_num)) { - ESP_LOGE(GPIO_TAG, "GPIO %d does not support deep sleep wakeup", gpio_num); + ESP_LOGE(GPIO_TAG, "GPIO %d does not support wakeup on peripheral powerdown sleep", gpio_num); return ESP_ERR_INVALID_ARG; } if ((intr_type != GPIO_INTR_LOW_LEVEL) && (intr_type != GPIO_INTR_HIGH_LEVEL)) { @@ -1032,7 +1032,7 @@ esp_err_t gpio_wakeup_enable_on_hp_periph_powerdown_sleep(gpio_num_t gpio_num, g #if SOC_LP_IO_CLOCK_IS_INDEPENDENT io_mux_enable_lp_io_clock(gpio_num, true); #endif - gpio_hal_deepsleep_wakeup_enable(gpio_context.gpio_hal, gpio_num, intr_type); + gpio_hal_wakeup_enable_on_hp_periph_powerdown_sleep(gpio_context.gpio_hal, gpio_num, intr_type); #if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND || CONFIG_PM_SLP_DISABLE_GPIO gpio_hal_sleep_sel_dis(gpio_context.gpio_hal, gpio_num); #endif @@ -1043,11 +1043,11 @@ esp_err_t gpio_wakeup_enable_on_hp_periph_powerdown_sleep(gpio_num_t gpio_num, g esp_err_t gpio_wakeup_disable_on_hp_periph_powerdown_sleep(gpio_num_t gpio_num) { if (!GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO(gpio_num)) { - ESP_LOGE(GPIO_TAG, "GPIO %d does not support deep sleep wakeup", gpio_num); + ESP_LOGE(GPIO_TAG, "GPIO %d does not support wakeup on peripheral powerdown sleep", gpio_num); return ESP_ERR_INVALID_ARG; } portENTER_CRITICAL(&gpio_context.gpio_spinlock); - gpio_hal_deepsleep_wakeup_disable(gpio_context.gpio_hal, gpio_num); + gpio_hal_wakeup_disable_on_hp_periph_powerdown_sleep(gpio_context.gpio_hal, gpio_num); #if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND || CONFIG_PM_SLP_DISABLE_GPIO gpio_hal_sleep_sel_en(gpio_context.gpio_hal, gpio_num); #endif diff --git a/components/esp_hal_gpio/esp32c2/include/hal/gpio_ll.h b/components/esp_hal_gpio/esp32c2/include/hal/gpio_ll.h index d7d6f5691f..33efd2cd6e 100644 --- a/components/esp_hal_gpio/esp32c2/include/hal/gpio_ll.h +++ b/components/esp_hal_gpio/esp32c2/include/hal/gpio_ll.h @@ -687,13 +687,13 @@ static inline void gpio_ll_sleep_output_enable(gpio_dev_t *hw, uint32_t gpio_num } /** - * @brief Enable GPIO deep-sleep wake-up function. + * @brief Enable GPIO wake-up on HP periph powerdown sleep function. * * @param hw Peripheral GPIO hardware instance address. * @param gpio_num GPIO number. * @param intr_type GPIO wake-up type. Only GPIO_INTR_LOW_LEVEL or GPIO_INTR_HIGH_LEVEL can be used. */ -static inline void gpio_ll_deepsleep_wakeup_enable(gpio_dev_t *hw, uint32_t gpio_num, gpio_int_type_t intr_type) +static inline void gpio_ll_wakeup_enable_on_hp_periph_powerdown_sleep(gpio_dev_t *hw, uint32_t gpio_num, gpio_int_type_t intr_type) { HAL_ASSERT(gpio_num <= GPIO_NUM_5 && "gpio larger than 5 does not support deep sleep wake-up function"); @@ -707,12 +707,12 @@ static inline void gpio_ll_deepsleep_wakeup_enable(gpio_dev_t *hw, uint32_t gpio } /** - * @brief Disable GPIO deep-sleep wake-up function. + * @brief Disable GPIO wake-up on HP periph powerdown sleep function. * * @param hw Peripheral GPIO hardware instance address. * @param gpio_num GPIO number */ -static inline void gpio_ll_deepsleep_wakeup_disable(gpio_dev_t *hw, uint32_t gpio_num) +static inline void gpio_ll_wakeup_disable_on_hp_periph_powerdown_sleep(gpio_dev_t *hw, uint32_t gpio_num) { HAL_ASSERT(gpio_num <= GPIO_NUM_5 && "gpio larger than 5 does not support deep sleep wake-up function"); @@ -721,13 +721,13 @@ static inline void gpio_ll_deepsleep_wakeup_disable(gpio_dev_t *hw, uint32_t gpi } /** - * @brief Get the status of whether an IO is used for deep-sleep wake-up. + * @brief Get the status of whether an IO is used for HP periph powerdown sleep wake-up. * * @param hw Peripheral GPIO hardware instance address. * @param gpio_num GPIO number - * @return True if the pin is enabled to wake up from deep-sleep + * @return True if the pin is enabled to wake up from HP periph powerdown sleep. */ -static inline bool gpio_ll_deepsleep_wakeup_is_enabled(gpio_dev_t *hw, uint32_t gpio_num) +static inline bool gpio_ll_hp_periph_powerdown_sleep_wakeup_is_enabled(gpio_dev_t *hw, uint32_t gpio_num) { HAL_ASSERT(gpio_num <= GPIO_NUM_5 && "gpio larger than 5 does not support deep sleep wake-up function"); diff --git a/components/esp_hal_gpio/esp32c3/include/hal/gpio_ll.h b/components/esp_hal_gpio/esp32c3/include/hal/gpio_ll.h index 9171e5c2f1..ee017567c6 100644 --- a/components/esp_hal_gpio/esp32c3/include/hal/gpio_ll.h +++ b/components/esp_hal_gpio/esp32c3/include/hal/gpio_ll.h @@ -684,13 +684,13 @@ static inline void gpio_ll_sleep_output_enable(gpio_dev_t *hw, uint32_t gpio_num } /** - * @brief Enable GPIO deep-sleep wake-up function. + * @brief Enable GPIO wake-up on HP periph powerdown sleep function. * * @param hw Peripheral GPIO hardware instance address. * @param gpio_num GPIO number. * @param intr_type GPIO wake-up type. Only GPIO_INTR_LOW_LEVEL or GPIO_INTR_HIGH_LEVEL can be used. */ -static inline void gpio_ll_deepsleep_wakeup_enable(gpio_dev_t *hw, uint32_t gpio_num, gpio_int_type_t intr_type) +static inline void gpio_ll_wakeup_enable_on_hp_periph_powerdown_sleep(gpio_dev_t *hw, uint32_t gpio_num, gpio_int_type_t intr_type) { HAL_ASSERT(gpio_num <= GPIO_NUM_5 && "gpio larger than 5 does not support deep sleep wake-up function"); @@ -704,12 +704,12 @@ static inline void gpio_ll_deepsleep_wakeup_enable(gpio_dev_t *hw, uint32_t gpio } /** - * @brief Disable GPIO deep-sleep wake-up function. + * @brief Disable GPIO wake-up on HP periph powerdown sleep function. * * @param hw Peripheral GPIO hardware instance address. * @param gpio_num GPIO number */ -static inline void gpio_ll_deepsleep_wakeup_disable(gpio_dev_t *hw, uint32_t gpio_num) +static inline void gpio_ll_wakeup_disable_on_hp_periph_powerdown_sleep(gpio_dev_t *hw, uint32_t gpio_num) { HAL_ASSERT(gpio_num <= GPIO_NUM_5 && "gpio larger than 5 does not support deep sleep wake-up function"); @@ -718,13 +718,13 @@ static inline void gpio_ll_deepsleep_wakeup_disable(gpio_dev_t *hw, uint32_t gpi } /** - * @brief Get the status of whether an IO is used for deep-sleep wake-up. + * @brief Get the status of whether an IO is used for HP periph powerdown sleep wake-up. * * @param hw Peripheral GPIO hardware instance address. * @param gpio_num GPIO number - * @return True if the pin is enabled to wake up from deep-sleep + * @return True if the pin is enabled to wake up from HP periph powerdown sleep. */ -static inline bool gpio_ll_deepsleep_wakeup_is_enabled(gpio_dev_t *hw, uint32_t gpio_num) +static inline bool gpio_ll_hp_periph_powerdown_sleep_wakeup_is_enabled(gpio_dev_t *hw, uint32_t gpio_num) { HAL_ASSERT(gpio_num <= GPIO_NUM_5 && "gpio larger than 5 does not support deep sleep wake-up function"); diff --git a/components/esp_hal_gpio/esp32h2/include/hal/gpio_ll.h b/components/esp_hal_gpio/esp32h2/include/hal/gpio_ll.h index 91ae29b5ad..72a9d23d34 100644 --- a/components/esp_hal_gpio/esp32h2/include/hal/gpio_ll.h +++ b/components/esp_hal_gpio/esp32h2/include/hal/gpio_ll.h @@ -728,13 +728,13 @@ static inline void gpio_ll_sleep_output_enable(gpio_dev_t *hw, uint32_t gpio_num } /** - * @brief Enable GPIO deep-sleep wake-up function. + * @brief Enable GPIO wake-up on HP periph powerdown sleep function. * * @param hw Peripheral GPIO hardware instance address. * @param gpio_num GPIO number. * @param intr_type GPIO wake-up type. Only GPIO_INTR_LOW_LEVEL or GPIO_INTR_HIGH_LEVEL can be used. */ -static inline void gpio_ll_deepsleep_wakeup_enable(gpio_dev_t *hw, uint32_t gpio_num, gpio_int_type_t intr_type) +static inline void gpio_ll_wakeup_enable_on_hp_periph_powerdown_sleep(gpio_dev_t *hw, uint32_t gpio_num, gpio_int_type_t intr_type) { HAL_ASSERT((gpio_num >= GPIO_NUM_7 && gpio_num <= GPIO_NUM_14) && "only gpio7~14 support deep sleep wake-up function"); @@ -756,12 +756,12 @@ static inline void gpio_ll_deepsleep_wakeup_enable(gpio_dev_t *hw, uint32_t gpio } /** - * @brief Disable GPIO deep-sleep wake-up function. + * @brief Disable GPIO wake-up on HP periph powerdown sleep function. * * @param hw Peripheral GPIO hardware instance address. * @param gpio_num GPIO number */ -static inline void gpio_ll_deepsleep_wakeup_disable(gpio_dev_t *hw, uint32_t gpio_num) +static inline void gpio_ll_wakeup_disable_on_hp_periph_powerdown_sleep(gpio_dev_t *hw, uint32_t gpio_num) { HAL_ASSERT((gpio_num >= GPIO_NUM_7 && gpio_num <= GPIO_NUM_14) && "only gpio7~14 support deep sleep wake-up function"); @@ -772,13 +772,13 @@ static inline void gpio_ll_deepsleep_wakeup_disable(gpio_dev_t *hw, uint32_t gpi } /** - * @brief Get the status of whether an IO is used for deep-sleep wake-up. + * @brief Get the status of whether an IO is used for HP periph powerdown sleep wake-up. * * @param hw Peripheral GPIO hardware instance address. * @param gpio_num GPIO number - * @return True if the pin is enabled to wake up from deep-sleep + * @return True if the pin is enabled to wake up from HP periph powerdown sleep. */ -static inline bool gpio_ll_deepsleep_wakeup_is_enabled(gpio_dev_t *hw, uint32_t gpio_num) +static inline bool gpio_ll_hp_periph_powerdown_sleep_wakeup_is_enabled(gpio_dev_t *hw, uint32_t gpio_num) { HAL_ASSERT((gpio_num >= GPIO_NUM_7 && gpio_num <= GPIO_NUM_14) && "only gpio7~14 support deep sleep wake-up function"); diff --git a/components/esp_hal_gpio/esp32h21/include/hal/gpio_ll.h b/components/esp_hal_gpio/esp32h21/include/hal/gpio_ll.h index 32d7a2a541..82d98b5343 100644 --- a/components/esp_hal_gpio/esp32h21/include/hal/gpio_ll.h +++ b/components/esp_hal_gpio/esp32h21/include/hal/gpio_ll.h @@ -712,13 +712,13 @@ static inline void gpio_ll_sleep_output_enable(gpio_dev_t *hw, uint32_t gpio_num } /** - * @brief Enable GPIO deep-sleep wake-up function. + * @brief Enable GPIO wake-up on HP periph powerdown sleep function. * * @param hw Peripheral GPIO hardware instance address. * @param gpio_num GPIO number. * @param intr_type GPIO wake-up type. Only GPIO_INTR_LOW_LEVEL or GPIO_INTR_HIGH_LEVEL can be used. */ -static inline void gpio_ll_deepsleep_wakeup_enable(gpio_dev_t *hw, uint32_t gpio_num, gpio_int_type_t intr_type) +static inline void gpio_ll_wakeup_enable_on_hp_periph_powerdown_sleep(gpio_dev_t *hw, uint32_t gpio_num, gpio_int_type_t intr_type) { HAL_ASSERT((gpio_num >= GPIO_NUM_5 && gpio_num <= GPIO_NUM_11) && "only gpio5~11 support deep sleep wake-up function"); @@ -740,12 +740,12 @@ static inline void gpio_ll_deepsleep_wakeup_enable(gpio_dev_t *hw, uint32_t gpio } /** - * @brief Disable GPIO deep-sleep wake-up function. + * @brief Disable GPIO wake-up on HP periph powerdown sleep function. * * @param hw Peripheral GPIO hardware instance address. * @param gpio_num GPIO number */ -static inline void gpio_ll_deepsleep_wakeup_disable(gpio_dev_t *hw, uint32_t gpio_num) +static inline void gpio_ll_wakeup_disable_on_hp_periph_powerdown_sleep(gpio_dev_t *hw, uint32_t gpio_num) { HAL_ASSERT((gpio_num >= GPIO_NUM_5 && gpio_num <= GPIO_NUM_11) && "only gpio5~11 support deep sleep wake-up function"); @@ -756,13 +756,13 @@ static inline void gpio_ll_deepsleep_wakeup_disable(gpio_dev_t *hw, uint32_t gpi } /** - * @brief Get the status of whether an IO is used for deep-sleep wake-up. + * @brief Get the status of whether an IO is used for HP periph powerdown sleep wake-up. * * @param hw Peripheral GPIO hardware instance address. * @param gpio_num GPIO number - * @return True if the pin is enabled to wake up from deep-sleep + * @return True if the pin is enabled to wake up from HP periph powerdown sleep. */ -static inline bool gpio_ll_deepsleep_wakeup_is_enabled(gpio_dev_t *hw, uint32_t gpio_num) +static inline bool gpio_ll_hp_periph_powerdown_sleep_wakeup_is_enabled(gpio_dev_t *hw, uint32_t gpio_num) { HAL_ASSERT((gpio_num >= GPIO_NUM_5 && gpio_num <= GPIO_NUM_11) && "only gpio5~11 support deep sleep wake-up function"); diff --git a/components/esp_hal_gpio/include/hal/gpio_hal.h b/components/esp_hal_gpio/include/hal/gpio_hal.h index 80fe43a33a..4613cbb77d 100644 --- a/components/esp_hal_gpio/include/hal/gpio_hal.h +++ b/components/esp_hal_gpio/include/hal/gpio_hal.h @@ -497,33 +497,33 @@ void gpio_hal_matrix_out(gpio_hal_context_t *hal, uint32_t gpio_num, uint32_t si */ #define gpio_hal_sleep_output_enable(hal, gpio_num) gpio_ll_sleep_output_enable((hal)->dev, gpio_num) -#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT == 0) && SOC_DEEP_SLEEP_SUPPORTED +#if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT == 0) /** - * @brief Enable GPIO deep-sleep wake-up function. + * @brief Enable GPIO HP periph powerdown sleep wake-up function. * * @param hal Context of the HAL layer * @param gpio_num GPIO number. * @param intr_type GPIO wake-up type. Only GPIO_INTR_LOW_LEVEL or GPIO_INTR_HIGH_LEVEL can be used. */ -#define gpio_hal_deepsleep_wakeup_enable(hal, gpio_num, intr_type) gpio_ll_deepsleep_wakeup_enable((hal)->dev, gpio_num, intr_type) +#define gpio_hal_wakeup_enable_on_hp_periph_powerdown_sleep(hal, gpio_num, intr_type) gpio_ll_wakeup_enable_on_hp_periph_powerdown_sleep((hal)->dev, gpio_num, intr_type) /** - * @brief Disable GPIO deep-sleep wake-up function. + * @brief Disable GPIO HP periph powerdown sleep wake-up function. * * @param hal Context of the HAL layer * @param gpio_num GPIO number */ -#define gpio_hal_deepsleep_wakeup_disable(hal, gpio_num) gpio_ll_deepsleep_wakeup_disable((hal)->dev, gpio_num) +#define gpio_hal_wakeup_disable_on_hp_periph_powerdown_sleep(hal, gpio_num) gpio_ll_wakeup_disable_on_hp_periph_powerdown_sleep((hal)->dev, gpio_num) /** - * @brief Get the status of whether an IO is used for deep-sleep wake-up. + * @brief Get the status of whether an IO is used for HP periph powerdown sleep wake-up. * * @param hal Context of the HAL layer * @param gpio_num GPIO number * - * @return True if the pin is enabled to wake up from deep-sleep + * @return True if the pin is enabled to wake up from HP periph powerdown sleep */ -#define gpio_hal_deepsleep_wakeup_is_enabled(hal, gpio_num) gpio_ll_deepsleep_wakeup_is_enabled((hal)->dev, gpio_num) +#define gpio_hal_wakeup_is_enabled_on_hp_periph_powerdown_sleep(hal, gpio_num) gpio_ll_hp_periph_powerdown_sleep_wakeup_is_enabled((hal)->dev, gpio_num) #endif //SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT == 0) #if SOC_GPIO_SUPPORT_PIN_HYS_FILTER diff --git a/components/esp_hal_gpio/include/hal/rtc_io_hal.h b/components/esp_hal_gpio/include/hal/rtc_io_hal.h index bdfa4600f2..ada68f6ab5 100644 --- a/components/esp_hal_gpio/include/hal/rtc_io_hal.h +++ b/components/esp_hal_gpio/include/hal/rtc_io_hal.h @@ -314,9 +314,9 @@ void rtcio_hal_isolate(int rtc_num); #if SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && (SOC_RTCIO_PIN_COUNT > 0) -#define gpio_hal_deepsleep_wakeup_enable(hal, gpio_num, intr_type) rtcio_hal_wakeup_enable(rtc_io_num_map[gpio_num], intr_type) -#define gpio_hal_deepsleep_wakeup_disable(hal, gpio_num) rtcio_hal_wakeup_disable(rtc_io_num_map[gpio_num]) -#define gpio_hal_deepsleep_wakeup_is_enabled(hal, gpio_num) rtcio_hal_wakeup_is_enabled(rtc_io_num_map[gpio_num]) +#define gpio_hal_wakeup_enable_on_hp_periph_powerdown_sleep(hal, gpio_num, intr_type) rtcio_hal_wakeup_enable(rtc_io_num_map[gpio_num], intr_type) +#define gpio_hal_wakeup_disable_on_hp_periph_powerdown_sleep(hal, gpio_num) rtcio_hal_wakeup_disable(rtc_io_num_map[gpio_num]) +#define gpio_hal_wakeup_is_enabled_on_hp_periph_powerdown_sleep(hal, gpio_num) rtcio_hal_wakeup_is_enabled(rtc_io_num_map[gpio_num]) #define rtc_hal_gpio_get_wakeup_status() rtcio_hal_get_interrupt_status() #define rtc_hal_gpio_clear_wakeup_status() rtcio_hal_clear_interrupt_status() diff --git a/components/esp_hw_support/sleep_gpio.c b/components/esp_hw_support/sleep_gpio.c index cfd9229970..4e50ddc087 100644 --- a/components/esp_hw_support/sleep_gpio.c +++ b/components/esp_hw_support/sleep_gpio.c @@ -251,10 +251,10 @@ void esp_deep_sleep_wakeup_io_reset(void) }; while (dl_io_mask) { int gpio_num = __builtin_ffs(dl_io_mask) - 1; - bool wakeup_io_enabled = gpio_hal_deepsleep_wakeup_is_enabled(&gpio_hal, gpio_num); + bool wakeup_io_enabled = gpio_hal_wakeup_is_enabled_on_hp_periph_powerdown_sleep(&gpio_hal, gpio_num); if (wakeup_io_enabled) { // Disable the wakeup before releasing hold, such that wakeup status can reflect the correct wakeup pin - gpio_hal_deepsleep_wakeup_disable(&gpio_hal, gpio_num); + gpio_hal_wakeup_disable_on_hp_periph_powerdown_sleep(&gpio_hal, gpio_num); gpio_hal_hold_dis(&gpio_hal, gpio_num); } dl_io_mask &= ~BIT(gpio_num); From 3c44b8fb85460e5d44ed32697399910b546c06fe Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Mon, 19 Jan 2026 21:55:41 +0800 Subject: [PATCH 4/4] change(esp_hw_support): deprecate esp_deep_sleep_enable_gpio_wakeup API rename esp_deep_sleep_enable_gpio_wakeup to esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown rename esp_deepsleep_gpio_wake_up_mode_t to esp_sleep_gpio_wake_up_mode_t --- components/esp_hw_support/include/esp_sleep.h | 13 ++-- components/esp_hw_support/sleep_modes.c | 9 ++- .../wakeup_tests/main/src/io_wakeup_cmd.c | 2 +- docs/en/api-reference/system/sleep_modes.rst | 19 ++++-- .../release-6.x/6.0/system.rst | 61 +++++++++++++++++++ .../api-reference/system/sleep_modes.rst | 19 ++++-- .../release-6.x/6.0/system.rst | 61 +++++++++++++++++++ examples/system/deep_sleep/main/gpio_wakeup.c | 2 +- 8 files changed, 161 insertions(+), 25 deletions(-) diff --git a/components/esp_hw_support/include/esp_sleep.h b/components/esp_hw_support/include/esp_sleep.h index d658c1f652..8fa0bc68b2 100644 --- a/components/esp_hw_support/include/esp_sleep.h +++ b/components/esp_hw_support/include/esp_sleep.h @@ -45,7 +45,7 @@ typedef enum { typedef enum { ESP_GPIO_WAKEUP_GPIO_LOW = 0, ESP_GPIO_WAKEUP_GPIO_HIGH = 1 -} esp_deepsleep_gpio_wake_up_mode_t; +} esp_sleep_gpio_wake_up_mode_t; #endif /** @@ -456,10 +456,11 @@ __attribute__((deprecated("please use 'esp_sleep_enable_ext1_wakeup_io' and 'esp /** * @brief Enable wakeup using specific gpio pins * - * 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 peripheral powerdowned sleep. + * (including deepsleep and peripheral powerdowned lightsleep). * * @note 1.This function does not modify pin configuration. The pins are configured - * inside `esp_deep_sleep_start`, immediately before entering sleep mode. + * inside `esp_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. * @@ -479,9 +480,9 @@ __attribute__((deprecated("please use 'esp_sleep_enable_ext1_wakeup_io' and 'esp * - ESP_GPIO_WAKEUP_GPIO_HIGH: wake up when the gpio turn to high. * @return * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if the mask contains any invalid deep sleep wakeup pin or wakeup mode is invalid + * - ESP_ERR_INVALID_ARG if the mask contains any invalid wakeup pin or wakeup mode is invalid */ -esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepsleep_gpio_wake_up_mode_t mode); +esp_err_t esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown(uint64_t gpio_pin_mask, esp_sleep_gpio_wake_up_mode_t mode); #endif /** @@ -499,7 +500,7 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee * @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 + * You can use `esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown` 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) * diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index 4e8b340e42..792d304651 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -1842,7 +1842,7 @@ bool esp_sleep_is_valid_wakeup_gpio(gpio_num_t gpio_num) #if SOC_RTCIO_PIN_COUNT > 0 return RTC_GPIO_IS_VALID_GPIO(gpio_num); #elif SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP - return GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num); + return GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO(gpio_num); #else return false; #endif @@ -2105,7 +2105,7 @@ static void esp_sleep_gpio_wakeup_prepare_on_hp_periph_powerdown(void) rtc_hal_gpio_clear_wakeup_status(); } -esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepsleep_gpio_wake_up_mode_t mode) +esp_err_t esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown(uint64_t gpio_pin_mask, esp_sleep_gpio_wake_up_mode_t mode) { if (mode > ESP_GPIO_WAKEUP_GPIO_HIGH) { ESP_LOGE(TAG, "invalid mode"); @@ -2118,7 +2118,7 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee if (invalid_io_mask != 0) { for (gpio_num_t gpio_idx = __builtin_ctzll(invalid_io_mask); invalid_io_mask >> gpio_idx; gpio_idx++) { if (invalid_io_mask & BIT64(gpio_idx)) { - ESP_LOGE(TAG, "gpio %d is an invalid deep sleep wakeup IO", gpio_idx); + ESP_LOGE(TAG, "GPIO %d does not support wakeup on peripheral powerdown sleep", gpio_idx); return ESP_ERR_INVALID_ARG; } } @@ -2140,8 +2140,7 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee s_config.wakeup_triggers |= RTC_GPIO_TRIG_EN; return err; } - -#endif //SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED +#endif //SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP esp_err_t esp_sleep_enable_gpio_wakeup(void) { diff --git a/components/esp_hw_support/test_apps/wakeup_tests/main/src/io_wakeup_cmd.c b/components/esp_hw_support/test_apps/wakeup_tests/main/src/io_wakeup_cmd.c index 5bf7b818cf..9530877294 100644 --- a/components/esp_hw_support/test_apps/wakeup_tests/main/src/io_wakeup_cmd.c +++ b/components/esp_hw_support/test_apps/wakeup_tests/main/src/io_wakeup_cmd.c @@ -189,7 +189,7 @@ static int process_rtcio_wakeup(int argc, char **argv) ESP_ERROR_CHECK(gpio_config(&config)); /* Enable wake up from GPIO */ - ESP_ERROR_CHECK(esp_deep_sleep_enable_gpio_wakeup(BIT64(io_wakeup_num), io_wakeup_level)); + ESP_ERROR_CHECK(esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown(BIT64(io_wakeup_num), io_wakeup_level)); } return 0; diff --git a/docs/en/api-reference/system/sleep_modes.rst b/docs/en/api-reference/system/sleep_modes.rst index 87476be68f..0cdf965ae9 100644 --- a/docs/en/api-reference/system/sleep_modes.rst +++ b/docs/en/api-reference/system/sleep_modes.rst @@ -312,7 +312,7 @@ RTC peripherals or RTC memories do not need to be powered on during sleep in thi In Light-sleep mode, if you set Kconfig option :ref:`CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP`, to continue using :cpp:func:`gpio_wakeup_enable` for GPIO wakeup, you need to first call :cpp:func:`rtc_gpio_init` and :cpp:func:`rtc_gpio_set_direction`, setting the RTCIO to input mode. - Alternatively,you can use :cpp:func:`esp_deep_sleep_enable_gpio_wakeup` directly in that condition for GPIO wakeup, because the digital IO power domain is being powered off, where the situation is the same as entering Deep-sleep. + Alternatively,you can use :cpp:func:`esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown` directly in that condition for GPIO wakeup, because the digital IO power domain is being powered off. .. only:: not SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP @@ -323,17 +323,24 @@ RTC peripherals or RTC memories do not need to be powered on during sleep in thi GPIO Wakeup ^^^^^^^^^^^ - Any IO can be used as the external input to wake up the chip from Light-sleep. Each pin can be individually configured to trigger wakeup on high or low level using the :cpp:func:`gpio_wakeup_enable` function. Then the :cpp:func:`esp_sleep_enable_gpio_wakeup` function should be called to enable this wakeup source. + There are two GPIO wakeup APIs available, each designed for different sleep scenarios: - Additionally, IOs that are powered by the VDD3P3_RTC power domain can be used to wake up the chip from Deep-sleep. The wakeup pin and wakeup trigger level can be configured by calling :cpp:func:`esp_deep_sleep_enable_gpio_wakeup`. The function will enable the Deep-sleep wakeup for the selected pin. + **1. :cpp:func:`esp_sleep_enable_gpio_wakeup` - For Light-sleep (GPIO module powered on)** - .. only:: SOC_PM_SUPPORT_TOP_PD + Any IO can be used as the external input to wake up the chip from Light-sleep when the GPIO module remains powered on. Each pin can be individually configured to trigger wakeup on high or low level using the :cpp:func:`gpio_wakeup_enable` function. Then the :cpp:func:`esp_sleep_enable_gpio_wakeup` function should be called to enable this wakeup source. .. note:: + This API is **not available** when :ref:`CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP` is enabled, because the GPIO module is powered down during sleep in this case. Use :cpp:func:`esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown` instead. - .. only:: SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP + **2. :cpp:func:`esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown` - For Deep-sleep and Light-sleep (peripheral powerdown)** - In Light-sleep mode, if you set Kconfig option :ref:`CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP`, you can use :cpp:func:`esp_deep_sleep_enable_gpio_wakeup` directly for GPIO wakeup, because the digital IO power domain is being powered off, where the situation is the same as entering Deep-sleep. + IOs that are powered by the VDD3P3_RTC power domain can be used to wake up the chip from Deep-sleep or Light-sleep when the peripheral power domain is powered down. The wakeup pin and wakeup trigger level can be configured by calling :cpp:func:`esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown`. This function works for: + + - Deep-sleep mode (always) + - Light-sleep mode when :ref:`CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP` is enabled + + .. note:: + Only GPIOs powered by the VDD3P3_RTC power domain (RTC IOs) can be used with this API. The exact set of supported pins can be checked in the `datasheet <{IDF_TARGET_DATASHEET_EN_URL}>`__ > Section IO Pins. .. only:: esp32h2 diff --git a/docs/en/migration-guides/release-6.x/6.0/system.rst b/docs/en/migration-guides/release-6.x/6.0/system.rst index b1e92424e3..a82058e5cc 100644 --- a/docs/en/migration-guides/release-6.x/6.0/system.rst +++ b/docs/en/migration-guides/release-6.x/6.0/system.rst @@ -107,6 +107,67 @@ Update to: handle_timer_wakeup(); } +.. _gpio_wakeup_api_changes: + +GPIO Wakeup API Changes +^^^^^^^^^^^^^^^^^^^^^^^^ + +The following APIs and types have been removed and replaced with new ones that support both Deep Sleep and Light Sleep (when peripheral power domain is powered down): + +**Removed APIs:** + +- :func:`esp_deep_sleep_enable_gpio_wakeup` - Use :func:`esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown` instead +- :func:`gpio_deep_sleep_wakeup_enable` - Use :func:`gpio_wakeup_enable_on_hp_periph_powerdown_sleep` instead +- :func:`gpio_deep_sleep_wakeup_disable` - Use :func:`gpio_wakeup_disable_on_hp_periph_powerdown_sleep` instead + +**Removed Types:** + +- :cpp:type:`esp_deepsleep_gpio_wake_up_mode_t` - Use :cpp:type:`esp_sleep_gpio_wake_up_mode_t` instead + +**Removed Macros:** + +- ``GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO()`` - Use ``GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO()`` instead + +**Migration Example:** + +Old code: + +.. code-block:: c + + #include "esp_sleep.h" + #include "driver/gpio.h" + + // Enable GPIO wakeup for deep sleep + esp_deep_sleep_enable_gpio_wakeup(BIT(GPIO_NUM_0), ESP_GPIO_WAKEUP_GPIO_LOW); + + // Or using GPIO driver API + gpio_deep_sleep_wakeup_enable(GPIO_NUM_0, GPIO_INTR_LOW_LEVEL); + + // Check if GPIO is valid for deep sleep wakeup + if (GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(GPIO_NUM_0)) { + // ... + } + +New code: + +.. code-block:: c + + #include "esp_sleep.h" + #include "driver/gpio.h" + + // Enable GPIO wakeup for deep sleep or light sleep (when peripheral power domain is powered down) + esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown(BIT(GPIO_NUM_0), ESP_GPIO_WAKEUP_GPIO_LOW); + + // Or using GPIO driver API + gpio_wakeup_enable_on_hp_periph_powerdown_sleep(GPIO_NUM_0, GPIO_INTR_LOW_LEVEL); + + // Check if GPIO is valid for wakeup on peripheral powerdown sleep + if (GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO(GPIO_NUM_0)) { + // ... + } + +**Note:** The new APIs work for both Deep Sleep and Light Sleep modes when the peripheral power domain is powered down (``PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP`` enabled in menuconfig). + Bootloader ---------- diff --git a/docs/zh_CN/api-reference/system/sleep_modes.rst b/docs/zh_CN/api-reference/system/sleep_modes.rst index bc3d2d1ea3..ae6dec901d 100644 --- a/docs/zh_CN/api-reference/system/sleep_modes.rst +++ b/docs/zh_CN/api-reference/system/sleep_modes.rst @@ -312,7 +312,7 @@ RTC 控制器中内嵌定时器,可用于在预定义的时间到达后唤醒 在 Light-sleep 模式下,如果设置 Kconfig 选项 :ref:`CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP`,为了继续使用 :cpp:func:`gpio_wakeup_enable` 用于 GPIO 唤醒, 需要先调用 :cpp:func:`rtc_gpio_init` 和 :cpp:func:`rtc_gpio_set_direction`,用于设置 RTC IO 为输入模式。 - 或者, 可以使用直接调用 :cpp:func:`esp_deep_sleep_enable_gpio_wakeup` 用于 GPIO 唤醒,因为此时 digital IO 的电源域已经被关闭,这个情况类似于进入 Deep-sleep。 + 或者, 可以使用直接调用 :cpp:func:`esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown` 用于 GPIO 唤醒,因为此时 digital IO 的电源域已经被关闭。 .. only:: not SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP @@ -323,17 +323,24 @@ RTC 控制器中内嵌定时器,可用于在预定义的时间到达后唤醒 GPIO 唤醒 ^^^^^^^^^^^ - 任何一个 IO 都可以用作外部输入管脚,将芯片从 Light-sleep 状态唤醒。调用 :cpp:func:`gpio_wakeup_enable` 函数可以将任意管脚单独配置为在高电平或低电平触发唤醒。此后,应调用 :cpp:func:`esp_sleep_enable_gpio_wakeup` 函数来启用此唤醒源。 + 有两种 GPIO 唤醒 API 可供使用,分别适用于不同的睡眠场景: - 此外,可将由 VDD3P3_RTC 电源域供电的 IO 用于芯片的 Deep-sleep 唤醒。调用 :cpp:func:`esp_deep_sleep_enable_gpio_wakeup` 函数可以配置相应的唤醒管脚和唤醒触发电平,该函数用于启用相应管脚的 Deep-sleep 唤醒功能。 + **1. :cpp:func:`esp_sleep_enable_gpio_wakeup` - 适用于 Light-sleep(GPIO 模块保持上电)** - .. only:: SOC_PM_SUPPORT_TOP_PD + 当 GPIO 模块在睡眠期间保持上电时,任何 IO 都可以用作外部输入管脚,将芯片从 Light-sleep 状态唤醒。调用 :cpp:func:`gpio_wakeup_enable` 函数可以将任意管脚单独配置为在高电平或低电平触发唤醒。此后,应调用 :cpp:func:`esp_sleep_enable_gpio_wakeup` 函数来启用此唤醒源。 .. note:: + 当启用 :ref:`CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP` 时,此 API **不可用**,因为 GPIO 模块在睡眠期间会被断电。请使用 :cpp:func:`esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown` 替代。 - .. only:: SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP + **2. :cpp:func:`esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown` - 适用于 Deep-sleep 和外设掉电的 Light-sleep** - 在 Light-sleep 模式下,如果设置 Kconfig 选项 :ref:`CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP`,可以使用直接调用 :cpp:func:`esp_deep_sleep_enable_gpio_wakeup` 用于 GPIO 唤醒,因为此时 digital IO 的电源域会被断电,行为与进入 Deep-sleep 模式时相同。 + 可将由 VDD3P3_RTC 电源域供电的 IO 用于芯片的 Deep-sleep 唤醒,或在外设电源域掉电时的 Light-sleep 唤醒。调用 :cpp:func:`esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown` 函数可以配置相应的唤醒管脚和唤醒触发电平。此函数适用于: + + - Deep-sleep 模式(始终可用) + - 启用 :ref:`CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP` 时的 Light-sleep 模式 + + .. note:: + 只有由 VDD3P3_RTC 电源域供电的 GPIO(RTC IO)可以与此 API 一起使用。具体支持的管脚请参考 `datasheet <{IDF_TARGET_DATASHEET_CN_URL}>`__ > IO 管脚。 .. only:: esp32h2 diff --git a/docs/zh_CN/migration-guides/release-6.x/6.0/system.rst b/docs/zh_CN/migration-guides/release-6.x/6.0/system.rst index 6d6b93fa7b..3bfd5b8cca 100644 --- a/docs/zh_CN/migration-guides/release-6.x/6.0/system.rst +++ b/docs/zh_CN/migration-guides/release-6.x/6.0/system.rst @@ -107,6 +107,67 @@ Xtensa 特殊寄存器头文件已更新,使用新的命名约定。旧的 ``s handle_timer_wakeup(); } +.. _gpio_wakeup_api_changes: + +GPIO 唤醒 API 变更 +^^^^^^^^^^^^^^^^^^ + +以下 API 和类型已被移除,并替换为支持 Deep Sleep 和 Light Sleep(当外设电源域掉电时)的新 API: + +**已移除的 API:** + +- :func:`esp_deep_sleep_enable_gpio_wakeup` - 请使用 :func:`esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown` 替代 +- :func:`gpio_deep_sleep_wakeup_enable` - 请使用 :func:`gpio_wakeup_enable_on_hp_periph_powerdown_sleep` 替代 +- :func:`gpio_deep_sleep_wakeup_disable` - 请使用 :func:`gpio_wakeup_disable_on_hp_periph_powerdown_sleep` 替代 + +**已移除的类型:** + +- :cpp:type:`esp_deepsleep_gpio_wake_up_mode_t` - 请使用 :cpp:type:`esp_sleep_gpio_wake_up_mode_t` 替代 + +**已移除的宏:** + +- ``GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO()`` - 请使用 ``GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO()`` 替代 + +**迁移示例:** + +旧代码: + +.. code-block:: c + + #include "esp_sleep.h" + #include "driver/gpio.h" + + // 为深度睡眠启用 GPIO 唤醒 + esp_deep_sleep_enable_gpio_wakeup(BIT(GPIO_NUM_0), ESP_GPIO_WAKEUP_GPIO_LOW); + + // 或使用 GPIO 驱动 API + gpio_deep_sleep_wakeup_enable(GPIO_NUM_0, GPIO_INTR_LOW_LEVEL); + + // 检查 GPIO 是否可用于深度睡眠唤醒 + if (GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(GPIO_NUM_0)) { + // ... + } + +新代码: + +.. code-block:: c + + #include "esp_sleep.h" + #include "driver/gpio.h" + + // 为深度睡眠或轻量睡眠(当外设电源域掉电时)启用 GPIO 唤醒 + esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown(BIT(GPIO_NUM_0), ESP_GPIO_WAKEUP_GPIO_LOW); + + // 或使用 GPIO 驱动 API + gpio_wakeup_enable_on_hp_periph_powerdown_sleep(GPIO_NUM_0, GPIO_INTR_LOW_LEVEL); + + // 检查 GPIO 是否可用于外设电源域掉电睡眠唤醒 + if (GPIO_IS_HP_PERIPH_PD_WAKEUP_VALID_IO(GPIO_NUM_0)) { + // ... + } + +**注意:** 新的 API 同时支持 Deep Sleep 和 Light Sleep 模式(当在 menuconfig 中启用 ``PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP`` 时)。 + 引导加载程序 ------------ diff --git a/examples/system/deep_sleep/main/gpio_wakeup.c b/examples/system/deep_sleep/main/gpio_wakeup.c index 6af2f0358c..fd9f889b00 100644 --- a/examples/system/deep_sleep/main/gpio_wakeup.c +++ b/examples/system/deep_sleep/main/gpio_wakeup.c @@ -25,7 +25,7 @@ void example_deep_sleep_register_gpio_wakeup(void) }; ESP_ERROR_CHECK(gpio_config(&config)); - ESP_ERROR_CHECK(esp_deep_sleep_enable_gpio_wakeup(BIT(DEFAULT_WAKEUP_PIN), DEFAULT_WAKEUP_LEVEL)); + ESP_ERROR_CHECK(esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown(BIT(DEFAULT_WAKEUP_PIN), DEFAULT_WAKEUP_LEVEL)); printf("Enabling GPIO wakeup on pins GPIO%d\n", DEFAULT_WAKEUP_PIN); }