From badef66538ec6deb494687c9a14eeab883eadb83 Mon Sep 17 00:00:00 2001 From: Lou Tianhao Date: Tue, 18 Jul 2023 19:33:30 +0800 Subject: [PATCH] change(pm/deepsleep): rewrite the option all low as any low for esp32s2, esp32s3, esp32c6 and esp32h2 --- components/esp_hw_support/include/esp_sleep.h | 6 +++- components/esp_hw_support/sleep_modes.c | 2 +- .../esp_system_unity_tests/main/test_sleep.c | 8 +++++ .../hal/esp32c6/include/hal/lp_aon_ll.h | 2 +- .../hal/esp32h2/include/hal/lp_aon_ll.h | 2 +- .../system/deep_sleep/main/Kconfig.projbuild | 34 ------------------- examples/system/deep_sleep/main/ext_wakeup.c | 7 +--- 7 files changed, 17 insertions(+), 44 deletions(-) diff --git a/components/esp_hw_support/include/esp_sleep.h b/components/esp_hw_support/include/esp_sleep.h index 7a83c09a02..f0f3f26ab9 100644 --- a/components/esp_hw_support/include/esp_sleep.h +++ b/components/esp_hw_support/include/esp_sleep.h @@ -26,6 +26,7 @@ typedef void (*esp_deep_sleep_cb_t)(void); /** * @brief Logic function used for EXT1 wakeup mode. */ +#if SOC_PM_SUPPORT_EXT1_WAKEUP #if CONFIG_IDF_TARGET_ESP32 typedef enum { ESP_EXT1_WAKEUP_ALL_LOW = 0, //!< Wake the chip when all selected GPIOs go low @@ -34,9 +35,12 @@ typedef enum { #else typedef enum { ESP_EXT1_WAKEUP_ANY_LOW = 0, //!< Wake the chip when any of the selected GPIOs go low - ESP_EXT1_WAKEUP_ANY_HIGH = 1 //!< Wake the chip when any of the selected GPIOs go high + ESP_EXT1_WAKEUP_ANY_HIGH = 1, //!< Wake the chip when any of the selected GPIOs go high + ESP_EXT1_WAKEUP_ALL_LOW __attribute__((deprecated("wakeup mode \"ALL_LOW\" is no longer supported after ESP32, \ + please use ESP_EXT1_WAKEUP_ANY_LOW instead"))) = ESP_EXT1_WAKEUP_ANY_LOW } esp_sleep_ext1_wakeup_mode_t; #endif +#endif #if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP typedef enum { diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index e76eac04bb..680cb06660 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -1393,7 +1393,7 @@ static void ext1_wakeup_prepare(void) // Clear state from previous wakeup rtc_hal_ext1_clear_wakeup_status(); - // Set RTC IO pins and mode (any high, all low) to be used for wakeup + // Set RTC IO pins and mode to be used for wakeup rtc_hal_ext1_set_wakeup_pins(s_config.ext1_rtc_gpio_mask, s_config.ext1_trigger_mode); } diff --git a/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c b/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c index 2d53aeeb52..84ba150bdc 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c +++ b/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c @@ -419,7 +419,11 @@ TEST_CASE("wake up using ext1 when RTC_PERIPH is off (13 low)", "[deepsleep][ign { // This test needs external pullup ESP_ERROR_CHECK(rtc_gpio_init(GPIO_NUM_13)); +#if CONFIG_IDF_TARGET_ESP32 ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ALL_LOW)); +#else + ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ANY_LOW)); +#endif esp_deep_sleep_start(); } @@ -439,7 +443,11 @@ TEST_CASE("wake up using ext1 when RTC_PERIPH is on (13 low)", "[deepsleep][igno ESP_ERROR_CHECK(gpio_pullup_en(GPIO_NUM_13)); ESP_ERROR_CHECK(gpio_pulldown_dis(GPIO_NUM_13)); ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON)); +#if CONFIG_IDF_TARGET_ESP32 ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ALL_LOW)); +#else + ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup(BIT(GPIO_NUM_13), ESP_EXT1_WAKEUP_ANY_LOW)); +#endif esp_deep_sleep_start(); } #endif // SOC_PM_SUPPORT_EXT1_WAKEUP diff --git a/components/hal/esp32c6/include/hal/lp_aon_ll.h b/components/hal/esp32c6/include/hal/lp_aon_ll.h index db08715964..22ae12dbf6 100644 --- a/components/hal/esp32c6/include/hal/lp_aon_ll.h +++ b/components/hal/esp32c6/include/hal/lp_aon_ll.h @@ -40,7 +40,7 @@ static inline void lp_aon_ll_ext1_clear_wakeup_status(void) /** * @brief Set the wake-up LP_IO of the ext1 wake-up source * @param mask wakeup LP_IO bitmap, bit 0~7 corresponds to LP_IO 0~7 - * @param mode 0: Wake the chip when all selected GPIOs go low + * @param mode 0: Wake the chip when any of the selected GPIOs go low * 1: Wake the chip when any of the selected GPIOs go high */ static inline void lp_aon_ll_ext1_set_wakeup_pins(uint32_t mask, int mode) diff --git a/components/hal/esp32h2/include/hal/lp_aon_ll.h b/components/hal/esp32h2/include/hal/lp_aon_ll.h index 23eacccb53..f556def282 100644 --- a/components/hal/esp32h2/include/hal/lp_aon_ll.h +++ b/components/hal/esp32h2/include/hal/lp_aon_ll.h @@ -40,7 +40,7 @@ static inline void lp_aon_ll_ext1_clear_wakeup_status(void) /** * @brief Set the wake-up LP_IO of the ext1 wake-up source * @param mask wakeup LP_IO bitmap, bit 0~7 corresponds to LP_IO 0~7 - * @param mode 0: Wake the chip when all selected GPIOs go low + * @param mode 0: Wake the chip when any of the selected GPIOs go low * 1: Wake the chip when any of the selected GPIOs go high */ static inline void lp_aon_ll_ext1_set_wakeup_pins(uint32_t mask, int mode) diff --git a/examples/system/deep_sleep/main/Kconfig.projbuild b/examples/system/deep_sleep/main/Kconfig.projbuild index 0c16340f73..281703bcd9 100644 --- a/examples/system/deep_sleep/main/Kconfig.projbuild +++ b/examples/system/deep_sleep/main/Kconfig.projbuild @@ -186,7 +186,6 @@ menu "Example Configuration" choice EXAMPLE_EXT1_WAKEUP_MODE_SEL prompt "Select wakeup mode from EXT1" default ESP_EXT1_WAKEUP_ANY_HIGH - depends on !SOC_PM_SUPPORT_EXT1_MULTI_BIT_TRIGGER config ESP_EXT1_WAKEUP_ANY_LOW bool "GPIO any low level" depends on !IDF_TARGET_ESP32 @@ -199,43 +198,10 @@ menu "Example Configuration" config EXAMPLE_EXT1_WAKEUP_MODE int - depends on !SOC_PM_SUPPORT_EXT1_MULTI_BIT_TRIGGER default 0 if ESP_EXT1_WAKEUP_ANY_LOW default 0 if ESP_EXT1_WAKEUP_ALL_LOW default 1 if ESP_EXT1_WAKEUP_ANY_HIGH - choice EXAMPLE_EXT1_WAKEUP_PIN_1_MODE_SEL - prompt "Select pin_1 wakeup mode from EXT1" - default ESP_EXT1_WAKEUP_PIN_1_HIGH - depends on SOC_PM_SUPPORT_EXT1_MULTI_BIT_TRIGGER - config ESP_EXT1_WAKEUP_PIN_1_LOW - bool "GPIO low level" - config ESP_EXT1_WAKEUP_PIN_1_HIGH - bool "GPIO high level" - endchoice - - config EXAMPLE_EXT1_WAKEUP_MODE_PIN_1 - int - depends on SOC_PM_SUPPORT_EXT1_MULTI_BIT_TRIGGER - default 0 if ESP_EXT1_WAKEUP_PIN_1_LOW - default 1 if ESP_EXT1_WAKEUP_PIN_1_HIGH - - choice EXAMPLE_EXT1_WAKEUP_PIN_2_MODE_SEL - prompt "Select pin_2 wakeup mode from EXT1" - default ESP_EXT1_WAKEUP_PIN_2_HIGH - depends on SOC_PM_SUPPORT_EXT1_MULTI_BIT_TRIGGER - config ESP_EXT1_WAKEUP_PIN_2_LOW - bool "GPIO low level" - config ESP_EXT1_WAKEUP_PIN_2_HIGH - bool "GPIO high level" - endchoice - - config EXAMPLE_EXT1_WAKEUP_MODE_PIN_2 - int - depends on SOC_PM_SUPPORT_EXT1_MULTI_BIT_TRIGGER - default 0 if ESP_EXT1_WAKEUP_PIN_2_LOW - default 1 if ESP_EXT1_WAKEUP_PIN_2_HIGH - config EXAMPLE_EXT1_USE_INTERNAL_PULLUPS bool "Use internal pull-up/downs for EXT1 wakeup source" default n diff --git a/examples/system/deep_sleep/main/ext_wakeup.c b/examples/system/deep_sleep/main/ext_wakeup.c index 3f2590be35..e6cc7ac10a 100644 --- a/examples/system/deep_sleep/main/ext_wakeup.c +++ b/examples/system/deep_sleep/main/ext_wakeup.c @@ -38,12 +38,7 @@ void example_deep_sleep_register_ext1_wakeup(void) const uint64_t ext_wakeup_pin_1_mask = 1ULL << ext_wakeup_pin_1; const uint64_t ext_wakeup_pin_2_mask = 1ULL << ext_wakeup_pin_2; printf("Enabling EXT1 wakeup on pins GPIO%d, GPIO%d\n", ext_wakeup_pin_1, ext_wakeup_pin_2); -#if SOC_PM_SUPPORT_EXT1_MULTI_BIT_TRIGGER const esp_sleep_ext1_wakeup_mode_t ext_wakeup_mode = CONFIG_EXAMPLE_EXT1_WAKEUP_MODE; -#else - const esp_sleep_ext1_wakeup_mode_t ext_wakeup_mode = CONFIG_EXAMPLE_EXT1_WAKEUP_MODE_PIN_1 << ext_wakeup_pin_1 | \ - CONFIG_EXAMPLE_EXT1_WAKEUP_MODE_PIN_2 << ext_wakeup_pin_2; -#endif ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup(ext_wakeup_pin_1_mask | ext_wakeup_pin_2_mask, ext_wakeup_mode)); @@ -77,7 +72,7 @@ void example_deep_sleep_register_ext1_wakeup(void) ESP_ERROR_CHECK(gpio_pullup_en(ext_wakeup_pin_2)); } #endif -#endif //CONFIG_EXAMPLE_EXT1_USE_INTERNAL_PULLUPS +#endif // CONFIG_EXAMPLE_EXT1_USE_INTERNAL_PULLUPS } #endif // CONFIG_EXAMPLE_EXT1_WAKEUP