From a8dd69f20696d8135b6c4e05b9f1b2c934fad4a3 Mon Sep 17 00:00:00 2001 From: Pascal Brunot Date: Mon, 23 Oct 2023 20:28:38 +0200 Subject: [PATCH] esp32/modmachine: Fix deepsleep() when previous sleep delay was set. Fixes issue #7158. Signed-off-by: Pascal Brunot --- ports/esp32/modmachine.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/esp32/modmachine.c b/ports/esp32/modmachine.c index be5348f0e6..1e83935a8b 100644 --- a/ports/esp32/modmachine.c +++ b/ports/esp32/modmachine.c @@ -115,6 +115,9 @@ STATIC mp_obj_t machine_sleep_helper(wake_type_t wake_type, size_t n_args, const mp_int_t expiry = args[ARG_sleep_ms].u_int; + // First, disable any previously set wake-up source + esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL); + if (expiry != 0) { esp_sleep_enable_timer_wakeup(((uint64_t)expiry) * 1000); }