From d075e55bb484fd414bc6aaac2c860b8b4fb0d78e Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 12 Jul 2019 11:14:31 +0200 Subject: [PATCH] cpu/cortexm_common: replace irq_restore by __set_PRIMASK for stm32l152re - The __NOP() that was added in #8518 is now remooved. - When DBG_STANDBY, DBG_STOP or DBG_SLEEP are set in DBG_CR a hardfault occurs on wakeup from sleep. This was first diagnosed in #8518. When enabled, a hardfault occured when returning from a branch to irq_restore() we avoid the call by inlining the function call. See #11830 for more details. --- cpu/cortexm_common/include/cpu.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cpu/cortexm_common/include/cpu.h b/cpu/cortexm_common/include/cpu.h index 7bab7a80bc..a3ffd23ac6 100644 --- a/cpu/cortexm_common/include/cpu.h +++ b/cpu/cortexm_common/include/cpu.h @@ -171,10 +171,11 @@ static inline void cortexm_sleep(int deep) __DSB(); __WFI(); #if defined(CPU_MODEL_STM32L152RE) - /* STM32L152RE crashes without this __NOP(). See #8518. */ - __NOP(); -#endif + /* STM32L152RE crashes if branching to irq_restore(state). See #11830. */ + __set_PRIMASK(state); +#else irq_restore(state); +#endif } /**