1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-31 17:31:18 +01:00

Merge pull request #15005 from kaspar030/ztimer_spin

ztimer: add ztimer_spin()
This commit is contained in:
Koen Zandberg 2020-09-11 10:45:47 +02:00 committed by GitHub
commit cc735805c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -444,6 +444,19 @@ void ztimer_periodic_wakeup(ztimer_clock_t *clock, uint32_t *last_wakeup,
*/
void ztimer_sleep(ztimer_clock_t *clock, uint32_t duration);
/**
* @brief Busy-wait specified duration
*
* @note: This blocks lower priority threads. Use only for *very* short delays.
*
* @param[in] clock ztimer clock to use
* @param[in] duration duration to spin, in @p clock time units
*/
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) {}
}
/**
* @brief Set a timer that wakes up a thread
*