From 6d9d880f38a696d4e2e13c165e9f0bbc4fb63ede Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 26 Jan 2026 01:03:20 +1100 Subject: [PATCH] alif/modmachine: Disable IRQs before going to sleep. Per the Alif example code and documentation for these functions. Signed-off-by: Damien George --- ports/alif/modmachine.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ports/alif/modmachine.c b/ports/alif/modmachine.c index 71b5be5193..fe84222788 100644 --- a/ports/alif/modmachine.c +++ b/ports/alif/modmachine.c @@ -99,10 +99,14 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) { MICROPY_BOARD_ENTER_STANDBY(); #endif + __disable_irq(); + // This enters the deepest possible CPU sleep state, without // losing CPU state. CPU and subsystem power will remain on. pm_core_enter_deep_sleep(); + __enable_irq(); + #ifdef MICROPY_BOARD_EXIT_STANDBY MICROPY_BOARD_EXIT_STANDBY(); #endif @@ -121,6 +125,8 @@ MP_NORETURN static void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args MICROPY_BOARD_ENTER_STOP(); #endif + __disable_irq(); + // If power is removed from the subsystem, the function does // not return, and the CPU will reboot when/if the subsystem // is next powered up.