micropython/stmhal/systick.c

17 wiersze
587 B
C
Czysty Zwykły widok Historia

2014-03-13 01:06:26 +00:00
#include <stm32f4xx_hal.h>
#include "misc.h"
#include "systick.h"
bool sys_tick_has_passed(uint32_t start_tick, uint32_t delay_ms) {
return HAL_GetTick() - start_tick >= delay_ms;
2014-03-13 01:06:26 +00:00
}
// waits until at least delay_ms milliseconds have passed from the sampling of
// startTick. Handles overflow properly. Assumes stc was taken from
// HAL_GetTick() some time before calling this function.
void sys_tick_wait_at_least(uint32_t start_tick, uint32_t delay_ms) {
while (!sys_tick_has_passed(start_tick, delay_ms)) {
__WFI(); // enter sleep mode, waiting for interrupt
2014-03-13 01:06:26 +00:00
}
}