diff options
| author | Damien George | 2018-11-28 12:44:54 +1100 |
|---|---|---|
| committer | Damien George | 2018-11-28 12:44:54 +1100 |
| commit | afd1ce0c1543ec1f621ae9ff1e8e25075ee943ff (patch) | |
| tree | f8c760e799cb3b8ab3ccc7a4fa3883bac153e007 | |
| parent | 66ca8e9b2c3c2d833e01e8d62dfdfe4016a46ced (diff) | |
stm32/powerctrl: Disable IRQs during stop mode to allow reconfig on wake
| -rw-r--r-- | ports/stm32/powerctrl.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ports/stm32/powerctrl.c b/ports/stm32/powerctrl.c index 45e886e13..d4590029c 100644 --- a/ports/stm32/powerctrl.c +++ b/ports/stm32/powerctrl.c @@ -260,6 +260,10 @@ set_clk: #endif void powerctrl_enter_stop_mode(void) { + // Disable IRQs so that the IRQ that wakes the device from stop mode is not + // executed until after the clocks are reconfigured + uint32_t irq_state = disable_irq(); + #if defined(STM32L4) // Configure the MSI as the clock source after waking up __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_MSI); @@ -331,6 +335,9 @@ void powerctrl_enter_stop_mode(void) { #endif #endif + + // Enable IRQs now that all clocks are reconfigured + enable_irq(irq_state); } #if !defined(STM32L4) |
