cpu/cortexm_common: added sleep_until_event

This commit is contained in:
Hauke Petersen 2016-03-01 23:13:55 +01:00
parent a182a44147
commit eb79646ab1
2 changed files with 15 additions and 0 deletions

View File

@ -49,4 +49,7 @@ void cortexm_init(void)
for (IRQn_Type i = 0; i < (int) CPU_IRQ_NUMOF; i++) { for (IRQn_Type i = 0; i < (int) CPU_IRQ_NUMOF; i++) {
NVIC_SetPriority(i, CPU_DEFAULT_IRQ_PRIO); NVIC_SetPriority(i, CPU_DEFAULT_IRQ_PRIO);
} }
/* enable wake up on events for __WFE CPU sleep */
SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
} }

View File

@ -102,6 +102,18 @@ static inline void cpu_print_last_instruction(void)
printf("%p\n", (void*) lr_ptr); printf("%p\n", (void*) lr_ptr);
} }
/**
* @brief Put the CPU into the 'wait for event' sleep mode
*
* This function is meant to be used for short periods of time, where it is not
* feasible to switch to the idle thread and back.
*/
static inline void cpu_sleep_until_event(void)
{
__SEV();
__WFE();
}
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif