Skip to content

Commit

Permalink
cpu/cortexm_common: replace irq_restore by __set_PRIMASK for stm32l152re
Browse files Browse the repository at this point in the history
- 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 #xxxxx for more
  details.
  • Loading branch information
fjmolinas committed Jul 12, 2019
1 parent ecdccdd commit 5d96127
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions cpu/cortexm_common/include/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,15 @@ static inline void cortexm_sleep(int deep)
else {
SCB->SCR &= ~(SCB_SCR_SLEEPDEEP_Msk);
}

/* ensure that all memory accesses have completed and trigger sleeping */
unsigned state = irq_disable();
__DSB();
__WFI();
#if defined(CPU_MODEL_STM32L152RE)
/* STM32L152RE crashes without this __NOP(). See #8518. */
__NOP();
#endif
__set_PRIMASK(state);
#else
irq_restore(state);
#endif
}

/**
Expand Down

0 comments on commit 5d96127

Please # to comment.