Fix sleep function for NRF52.

An active IRQ from the FPU can prevent the micro to go to sleep, even if this
IRQ is not enabled and not implemented. As a workaround, the FPU IRQ is cleared
before enterring sleep.
pull/3108/head
Vincent Coubard 2016-10-21 14:47:44 +01:00
parent d1a71eb9fc
commit bd1ad99452
1 changed files with 7 additions and 0 deletions

View File

@ -31,6 +31,13 @@ void sleep(void)
// the processor from disabled interrupts.
SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
#ifdef NRF52
/* Clear exceptions and PendingIRQ from the FPU unit */
__set_FPSCR(__get_FPSCR() & ~(FPU_EXCEPTION_MASK));
(void) __get_FPSCR();
NVIC_ClearPendingIRQ(FPU_IRQn);
#endif
// If the SoftDevice is enabled, its API must be used to go to sleep.
if (softdevice_handler_isEnabled()) {
sd_power_mode_set(NRF_POWER_MODE_LOWPWR);