From b219910a95cbcb49364fb1889808ba0d7cdd7fe9 Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Fri, 25 Apr 2025 11:52:15 +0800 Subject: [PATCH] fix(example): fix uninitialized gpio/rtcio in deepsleep example --- examples/system/deep_sleep/main/ext_wakeup.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/system/deep_sleep/main/ext_wakeup.c b/examples/system/deep_sleep/main/ext_wakeup.c index d0e44374ae..d04736a01d 100644 --- a/examples/system/deep_sleep/main/ext_wakeup.c +++ b/examples/system/deep_sleep/main/ext_wakeup.c @@ -7,6 +7,7 @@ #include #include "esp_sleep.h" #include "sdkconfig.h" +#include "driver/gpio.h" #include "driver/rtc_io.h" #include "driver/gpio.h" @@ -25,6 +26,7 @@ void example_deep_sleep_register_ext0_wakeup(void) // Configure pullup/downs via RTCIO to tie wakeup pins to inactive level during deepsleep. // EXT0 resides in the same power domain (RTC_PERIPH) as the RTC IO pullup/downs. // No need to keep that power domain explicitly, unlike EXT1. + ESP_ERROR_CHECK(rtc_gpio_init(ext_wakeup_pin_0)); ESP_ERROR_CHECK(rtc_gpio_pullup_dis(ext_wakeup_pin_0)); ESP_ERROR_CHECK(rtc_gpio_pulldown_en(ext_wakeup_pin_0)); } @@ -52,6 +54,8 @@ void example_deep_sleep_register_ext1_wakeup(void) * domain, we will use the HOLD feature to maintain the pull-up and pull-down on the pins during sleep.*/ #if CONFIG_EXAMPLE_EXT1_USE_INTERNAL_PULLUPS #if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED + ESP_ERROR_CHECK(rtc_gpio_init(ext_wakeup_pin_1)); + ESP_ERROR_CHECK(rtc_gpio_init(ext_wakeup_pin_2)); #if SOC_PM_SUPPORT_EXT1_WAKEUP_MODE_PER_PIN if (CONFIG_EXAMPLE_EXT1_WAKEUP_MODE_PIN_1) { ESP_ERROR_CHECK(rtc_gpio_pullup_dis(ext_wakeup_pin_1)); @@ -81,6 +85,11 @@ void example_deep_sleep_register_ext1_wakeup(void) } #endif #else // ! SOC_RTCIO_INPUT_OUTPUT_SUPPORTED + const gpio_config_t config = { + .pin_bit_mask = BIT(ext_wakeup_pin_1) | BIT(ext_wakeup_pin_2), + .mode = GPIO_MODE_INPUT, + }; + ESP_ERROR_CHECK(gpio_config(&config)); #if SOC_PM_SUPPORT_EXT1_WAKEUP_MODE_PER_PIN if (CONFIG_EXAMPLE_EXT1_WAKEUP_MODE_PIN_1) { gpio_pullup_dis(ext_wakeup_pin_1);