cpu/cortexm_common: added sleep_until_event
This commit is contained in:
parent
a182a44147
commit
eb79646ab1
@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user