diff --git a/sys/include/xtimer.h b/sys/include/xtimer.h index b717e147fd..961b9043a3 100644 --- a/sys/include/xtimer.h +++ b/sys/include/xtimer.h @@ -434,7 +434,7 @@ static inline void xtimer_spin_until(uint32_t value); /** * @brief ignore some bits when comparing timer values * - * (only relevant when XTIMER_MASK != 0, e.g., timers < 16bit.) + * (only relevant when XTIMER_MASK != 0, e.g., timers < 32bit.) * * When combining _xtimer_now() and _high_cnt, we have to get the same value in * order to work around a race between overflowing _xtimer_now() and OR'ing the diff --git a/sys/xtimer/xtimer.c b/sys/xtimer/xtimer.c index 1cb2fd25c7..a03cb55bd9 100644 --- a/sys/xtimer/xtimer.c +++ b/sys/xtimer/xtimer.c @@ -155,16 +155,16 @@ void xtimer_set_wakeup64(xtimer_t *timer, uint64_t offset, kernel_pid_t pid) * This is to avoid using long integer division functions * the compiler otherwise links in. */ -static inline uint64_t _ms_to_sec(uint64_t ms) +static inline uint64_t _us_to_sec(uint64_t us) { - return (unsigned long long)(ms * 0x431bde83) >> (0x12 + 32); + return (unsigned long long)(us * 0x431bde83) >> (0x12 + 32); } void xtimer_now_timex(timex_t *out) { uint64_t now = xtimer_now64(); - out->seconds = _ms_to_sec(now); + out->seconds = _us_to_sec(now); out->microseconds = now - (out->seconds * SEC_IN_USEC); } diff --git a/sys/xtimer/xtimer_core.c b/sys/xtimer/xtimer_core.c index 0b635362b8..b882dd8f74 100644 --- a/sys/xtimer/xtimer_core.c +++ b/sys/xtimer/xtimer_core.c @@ -120,13 +120,13 @@ void xtimer_set(xtimer_t *timer, uint32_t offset) } xtimer_remove(timer); - uint32_t target = xtimer_now() + offset; if (offset < XTIMER_BACKOFF) { xtimer_spin(offset); _shoot(timer); } else { + uint32_t target = xtimer_now() + offset; _xtimer_set_absolute(timer, target); } }