1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/nrf52: add CPU specific sleep function

This function is supposed to be used for putting the CPU into
sleep mode for short amounts of time (e.g. in typical polling
loops used in periph drivers).
This commit is contained in:
Hauke Petersen 2018-01-19 22:17:48 +01:00
parent 959e838836
commit 787d69c676
2 changed files with 13 additions and 0 deletions

View File

@ -78,6 +78,9 @@ void cpu_init(void)
NVIC_SetPriority(SWI0_EGU0_IRQn, 6);
#endif
/* enable wake up on events for __WFE CPU sleep */
SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
/* trigger static peripheral initialization */
periph_init();
}

View File

@ -75,6 +75,16 @@ extern "C" {
#endif /* SOFTDEVICE_PRESENT */
/** @} */
/**
* @brief Put the CPU in the low-power 'wait for event' state
*/
static inline void nrf52_sleep(void)
{
__SEV();
__WFE();
__asm("nop");
}
#ifdef __cplusplus
}
#endif