From d95e7a3572ff8dc0bf906d6b50cada83b3a02a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Wed, 28 Oct 2015 07:38:12 +0100 Subject: [PATCH] xtimer: Handle overflows in xtimer_spin() --- sys/include/xtimer.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/include/xtimer.h b/sys/include/xtimer.h index 8b7b93f41b..7f86205c22 100644 --- a/sys/include/xtimer.h +++ b/sys/include/xtimer.h @@ -484,7 +484,12 @@ static inline void xtimer_spin_until(uint32_t target) { static inline void xtimer_spin(uint32_t offset) { uint32_t start = _lltimer_now(); +#if XTIMER_MASK + offset = _lltimer_mask(offset); + while (_lltimer_mask(_lltimer_now() - start) < offset); +#else while ((_lltimer_now() - start) < offset); +#endif } static inline void xtimer_usleep(uint32_t microseconds)