blob: d6c914886a6e4fed3b1d663d3ad1e34b833dd1e9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#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;
}
// 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
}
}
|