diff --git a/cpu/nrf52/cpu.c b/cpu/nrf52/cpu.c index 1a0d6672d4..2d01ff28ff 100644 --- a/cpu/nrf52/cpu.c +++ b/cpu/nrf52/cpu.c @@ -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(); } diff --git a/cpu/nrf52/include/cpu_conf.h b/cpu/nrf52/include/cpu_conf.h index 0ef8d767f5..32d9b9da65 100644 --- a/cpu/nrf52/include/cpu_conf.h +++ b/cpu/nrf52/include/cpu_conf.h @@ -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