mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #15113 from kaspar030/fix_ztimer_spin
ztimer: fix ztimer_spin() time_left == duration case
This commit is contained in:
commit
9970a26277
@ -456,7 +456,10 @@ void ztimer_sleep(ztimer_clock_t *clock, uint32_t duration);
|
||||
*/
|
||||
static inline void ztimer_spin(ztimer_clock_t *clock, uint32_t duration) {
|
||||
uint32_t end = ztimer_now(clock) + duration;
|
||||
while ((end - ztimer_now(clock)) < duration) {}
|
||||
|
||||
/* Rely on integer overflow. `end - now` will be smaller than `duration`,
|
||||
* counting down, until it underflows to UINT32_MAX. Loop ends then. */
|
||||
while ((end - ztimer_now(clock)) <= duration) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user