From b0fef9a5cdfd463c71d12df640cd1825e51d8c98 Mon Sep 17 00:00:00 2001 From: danny Date: Sat, 20 Jan 2024 08:26:14 +0100 Subject: [PATCH] Improved deep sleep --- components/cmd_system/cmd_system.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/components/cmd_system/cmd_system.c b/components/cmd_system/cmd_system.c index 70de231..973ab7f 100644 --- a/components/cmd_system/cmd_system.c +++ b/components/cmd_system/cmd_system.c @@ -228,7 +228,7 @@ static int deep_sleep(int argc, char **argv) if (deep_sleep_args.wakeup_gpio_num->count) { int io_num = deep_sleep_args.wakeup_gpio_num->ival[0]; - if (!rtc_gpio_is_valid_gpio(io_num)) + if (!GPIO_IS_VALID_DIGITAL_IO_PAD(io_num)) { ESP_LOGE(TAG, "GPIO %d is not an RTC IO", io_num); return 1; @@ -245,15 +245,16 @@ static int deep_sleep(int argc, char **argv) } ESP_LOGI(TAG, "Enabling wakeup on GPIO%d, wakeup on %s level", io_num, level ? "HIGH" : "LOW"); - ESP_ERROR_CHECK(esp_sleep_enable_wifi_wakeup()); + +#if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S2) + ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup(1ULL << io_num, level)); +#endif } -#if SOC_RTCIO_HOLD_SUPPORTED +#if defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S2) rtc_gpio_isolate(GPIO_NUM_12); -#endif // WITH_TASKS_INFO +#endif esp_deep_sleep_start(); - return 0; } - static void register_deep_sleep(void) { deep_sleep_args.wakeup_time =