mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
ztimer: add ztimer_spin()
This adds a simple busy waiting function intended for blocking, but very precise short delays.
This commit is contained in:
parent
4db8a1f602
commit
fb7e285acd
@ -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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user