ztimer 64bit version More...
ztimer 64bit version
This module implements a 64bit version of the ztimer API. All ztimer_* functions have a ztimer64_* equivalent that behaves the same, but allowing offsets >= 2^32.
In addition to that, ztimer64 offers functions taking absolute target times as parameter. If the absolute target time is in the past, a timer would trigger right away.
Here's a table for absolute variants:
ztimer64 provides automatic setup of ZTIMER64_SEC, ZTIMER64_MSEC and ZTIMER64_USEC, using the ztimer(32) clocks as base clocks. Enable them by depending on ztimer64_sec, ztimer64_msec and / or ztimer64_usec.
TODO:
Modules | |
| ztimer64_xtimer_compat: 64 Bit xtimer wrapper | |
Files | |
| file | ztimer64.h |
| ztimer 64bit API | |
Data Structures | |
| struct | ztimer64_base |
| Minimum information for each timer. More... | |
| struct | ztimer64_t |
| ztimer64 structure More... | |
| struct | ztimer64_clock |
| ztimer64 clock structure More... | |
Macros | |
| #define | MSG_ZTIMER64 0xc83f |
| msg type used by ztimer64_msg_receive_timeout | |
Typedefs | |
| typedef struct ztimer64_base | ztimer64_base_t |
| ztimer64_t forward declaration | |
| typedef struct ztimer64_clock | ztimer64_clock_t |
| ztimer64_clock_t forward declaration | |
Functions | |
| uint64_t | ztimer64_now (ztimer64_clock_t *clock) |
| Get the current time from a clock. More... | |
| static uint64_t | ztimer64_offset2absolute (ztimer64_clock_t *clock, uint64_t offset) |
| Get absolute target time for a clock given offset. More... | |
| void | ztimer64_set_at (ztimer64_clock_t *clock, ztimer64_t *timer, uint64_t target) |
| Set a timer on a clock (absolute version) More... | |
| static void | ztimer64_set (ztimer64_clock_t *clock, ztimer64_t *timer, uint64_t offset) |
| Set a timer on a clock (relative version) More... | |
| unsigned | ztimer64_is_set (const ztimer64_t *timer) |
| Check if a timer is currently active. More... | |
| void | ztimer64_remove (ztimer64_clock_t *clock, ztimer64_t *timer) |
| Remove a timer from a clock. More... | |
| void | ztimer64_set_msg_at (ztimer64_clock_t *clock, ztimer64_t *timer, uint64_t target, msg_t *msg, kernel_pid_t target_pid) |
| Post a message at a specified time. More... | |
| static void | ztimer64_set_msg (ztimer64_clock_t *clock, ztimer64_t *timer, uint64_t offset, msg_t *msg, kernel_pid_t target_pid) |
| Post a message after a delay (relative version) More... | |
| int | ztimer64_msg_receive_until (ztimer64_clock_t *clock, msg_t *msg, uint64_t target) |
| receive a message (blocking, with absolute timeout) More... | |
| static int | ztimer64_msg_receive_timeout (ztimer64_clock_t *clock, msg_t *msg, uint64_t timeout) |
| receive a message (blocking, with relative timeout) More... | |
| void | ztimer64_periodic_wakeup (ztimer64_clock_t *clock, uint64_t *last_wakeup, uint64_t period) |
Suspend the calling thread until the time (last_wakeup + period) More... | |
| void | ztimer64_sleep_until (ztimer64_clock_t *clock, uint64_t target) |
| Put the calling thread to sleep until the specified time. More... | |
| static void | ztimer64_sleep (ztimer64_clock_t *clock, uint64_t duration) |
| Put the calling thread to sleep for the specified number of ticks. More... | |
| static void | ztimer64_spin_until (ztimer64_clock_t *clock, uint64_t target) |
| Busy-wait until specified target time. More... | |
| void | ztimer64_set_wakeup_at (ztimer64_clock_t *clock, ztimer64_t *timer, uint64_t target, kernel_pid_t pid) |
| Set a timer that wakes up a thread (absolute version) More... | |
| static void | ztimer64_set_wakeup (ztimer64_clock_t *clock, ztimer64_t *timer, uint64_t offset, kernel_pid_t pid) |
| Set a timer that wakes up a thread (relative version) More... | |
| void | ztimer64_set_timeout_flag_at (ztimer64_clock_t *clock, ztimer64_t *timer, uint64_t target) |
Set timeout thread flag at target time. More... | |
| static void | ztimer64_set_timeout_flag (ztimer64_clock_t *clock, ztimer64_t *timer, uint64_t timeout) |
Set timeout thread flag after timeout. More... | |
| int | ztimer64_mutex_lock_until (ztimer64_clock_t *clock, mutex_t *mutex, uint64_t target) |
Try to lock the given mutex, but give up at target time. More... | |
| static int | ztimer64_mutex_lock_timeout (ztimer64_clock_t *clock, mutex_t *mutex, uint64_t timeout) |
Try to lock the given mutex, but give up after timeout. More... | |
| int | ztimer64_rmutex_lock_until (ztimer64_clock_t *clock, rmutex_t *rmutex, uint64_t target) |
Try to lock the given rmutex, but give up at time. More... | |
| static int | ztimer64_rmutex_lock_timeout (ztimer64_clock_t *clock, rmutex_t *rmutex, uint64_t timeout) |
Try to lock the given rmutex, but give up after timeout. More... | |
| void | ztimer64_update_head_offset (ztimer64_clock_t *clock) |
| Update ztimer clock head list offset. | |
| void | ztimer64_init (void) |
| Initialize the board-specific default ztimer configuration. | |
| void | ztimer64_clock_init (ztimer64_clock_t *clock, ztimer_clock_t *base_clock) |
Initialize clock to be run from base_clock. More... | |
| int64_t | ztimer64_overhead (ztimer64_clock_t *clock, uint64_t base) |
| Measure ztimer64 overhead. More... | |
Variables | |
| ztimer64_clock_t *const | ZTIMER64_USEC |
| Default ztimer microsecond clock. | |
| ztimer64_clock_t *const | ZTIMER64_MSEC |
| Default ztimer millisecond clock. | |
| ztimer64_clock_t *const | ZTIMER64_SEC |
| Default ztimer second clock. | |
| void ztimer64_clock_init | ( | ztimer64_clock_t * | clock, |
| ztimer_clock_t * | base_clock | ||
| ) |
Initialize clock to be run from base_clock.
| [in,out] | clock | Clock to initialize |
| [in] | base_clock | Base clock to use |
| unsigned ztimer64_is_set | ( | const ztimer64_t * | timer | ) |
Check if a timer is currently active.
| [in] | timer | timer to check |
|
inlinestatic |
receive a message (blocking, with relative timeout)
Similar to msg_receive(), but with a timeout parameter. The function will return after waiting at most timeout ticks.
| [in] | clock | ztimer64 clock to operate on |
| [out] | msg | pointer to buffer which will be filled if a message is received |
| [in] | timeout | relative timeout, in clock time units |
Definition at line 287 of file ztimer64.h.
| int ztimer64_msg_receive_until | ( | ztimer64_clock_t * | clock, |
| msg_t * | msg, | ||
| uint64_t | target | ||
| ) |
receive a message (blocking, with absolute timeout)
Similar to msg_receive(), but with a timeout parameter. The function will return after waiting at most until target.
| [in] | clock | ztimer64 clock to operate on |
| [out] | msg | pointer to buffer which will be filled if a message is received |
| [in] | target | absolute target, in clock time |
|
inlinestatic |
Try to lock the given mutex, but give up after timeout.
| [in] | clock | ztimer64 clock to operate on |
| [in,out] | mutex | Mutex object to lock |
| [in] | timeout | timeout after which to give up |
| 0 | Success, caller has the mutex |
| -ECANCELED | Failed to obtain mutex within timeout |
Definition at line 440 of file ztimer64.h.
| int ztimer64_mutex_lock_until | ( | ztimer64_clock_t * | clock, |
| mutex_t * | mutex, | ||
| uint64_t | target | ||
| ) |
Try to lock the given mutex, but give up at target time.
| [in] | clock | ztimer64 clock to operate on |
| [in,out] | mutex | Mutex object to lock |
| [in] | target | time after which to give up |
| 0 | Success, caller has the mutex |
| -ECANCELED | Failed to obtain mutex within timeout |
| uint64_t ztimer64_now | ( | ztimer64_clock_t * | clock | ) |
Get the current time from a clock.
| [in] | clock | ztimer clock to operate on |
clock
|
inlinestatic |
Get absolute target time for a clock given offset.
| [in] | clock | ztimer64 clock to operate on |
| [in] | offset | relative target time |
Definition at line 139 of file ztimer64.h.
| int64_t ztimer64_overhead | ( | ztimer64_clock_t * | clock, |
| uint64_t | base | ||
| ) |
Measure ztimer64 overhead.
This function can be used to measure the overhead incurred by ztimer64. It will configure a callback to trigger after base ticks, then return the number of ticks that have passed, minus base.
| [in] | clock | ztimer64 clock to operate on |
| [in] | base | base interval to use |
| void ztimer64_periodic_wakeup | ( | ztimer64_clock_t * | clock, |
| uint64_t * | last_wakeup, | ||
| uint64_t | period | ||
| ) |
Suspend the calling thread until the time (last_wakeup + period)
This function can be used to create periodic wakeups.
When the function returns, last_wakeup is set to (last_wakeup + period).
last_wakeup should be set to ztimer64_now(clock) before first call of the function.
If the time (last_wakeup + period) has already passed, the function sets last_wakeup to last_wakeup + period and returns immediately.
| [in] | clock | ztimer64 clock to operate on |
| [in] | last_wakeup | base time stamp for the wakeup |
| [in] | period | time in ticks that will be added to last_wakeup |
| void ztimer64_remove | ( | ztimer64_clock_t * | clock, |
| ztimer64_t * | timer | ||
| ) |
Remove a timer from a clock.
This will place timer in the timer targets queue for clock.
This function does nothing if timer is not found in the timer queue of clock.
| [in] | clock | ztimer64 clock to operate on |
| [in] | timer | timer entry to remove |
|
inlinestatic |
Try to lock the given rmutex, but give up after timeout.
| [in] | clock | ztimer64 clock to operate on |
| [in,out] | rmutex | rmutex object to lock |
| [in] | timeout | timeout after which to give up |
| 0 | Success, caller has the rmutex |
| -ECANCELED | Failed to obtain rmutex within timeout |
Definition at line 471 of file ztimer64.h.
| int ztimer64_rmutex_lock_until | ( | ztimer64_clock_t * | clock, |
| rmutex_t * | rmutex, | ||
| uint64_t | target | ||
| ) |
Try to lock the given rmutex, but give up at time.
| [in] | clock | ztimer64 clock to operate on |
| [in,out] | rmutex | rmutex object to lock |
| [in] | target | time after which to give up |
| 0 | Success, caller has the rmutex |
| -ECANCELED | Failed to obtain rmutex before time |
|
inlinestatic |
Set a timer on a clock (relative version)
This will place timer in the timer targets queue of clock.
timer is not copied and must remain in scope until the callback is fired or the timer is removed via ztimer64_remove| [in] | clock | ztimer64 clock to operate on |
| [in] | timer | timer entry to set |
| [in] | offset | relative target time |
Definition at line 178 of file ztimer64.h.
| void ztimer64_set_at | ( | ztimer64_clock_t * | clock, |
| ztimer64_t * | timer, | ||
| uint64_t | target | ||
| ) |
Set a timer on a clock (absolute version)
This will place timer in the timer targets queue of clock.
timer is not copied and must remain in scope until the callback is fired or the timer is removed via ztimer64_remove| [in] | clock | ztimer64 clock to operate on |
| [in] | timer | timer entry to set |
| [in] | target | absolute target time |
|
inlinestatic |
Post a message after a delay (relative version)
This function sets a timer that will send a message offset ticks from now.
timer and msg will not be copied, i.e. *timer and *msg needs to remain valid until the timer has triggered.| [in] | clock | ztimer64 clock to operate on |
| [in] | timer | ztimer64 timer struct to use |
| [in] | offset | relative target time |
| [in] | msg | pointer to msg that will be sent |
| [in] | target_pid | pid the message will be sent to |
Definition at line 241 of file ztimer64.h.
| void ztimer64_set_msg_at | ( | ztimer64_clock_t * | clock, |
| ztimer64_t * | timer, | ||
| uint64_t | target, | ||
| msg_t * | msg, | ||
| kernel_pid_t | target_pid | ||
| ) |
Post a message at a specified time.
This function sets a timer that will send a message at time target.
timer and msg will not be copied, i.e. *timer and *msg needs to remain valid until the timer has triggered.| [in] | clock | ztimer64 clock to operate on |
| [in] | timer | ztimer64 timer struct to use |
| [in] | target | absolute target time |
| [in] | msg | pointer to msg that will be sent |
| [in] | target_pid | pid the message will be sent to |
|
inlinestatic |
Set timeout thread flag after timeout.
This function will set THREAD_FLAG_TIMEOUT on the current thread after timeout usec have passed.
| [in] | clock | ztimer64 clock to operate on |
| [in] | timer | timer struct to use |
| [in] | timeout | timeout in ztimer64_clock's ticks |
Definition at line 409 of file ztimer64.h.
| void ztimer64_set_timeout_flag_at | ( | ztimer64_clock_t * | clock, |
| ztimer64_t * | timer, | ||
| uint64_t | target | ||
| ) |
Set timeout thread flag at target time.
This function will set THREAD_FLAG_TIMEOUT on the current thread at time target.
| [in] | clock | ztimer64 clock to operate on |
| [in] | timer | timer struct to use |
| [in] | target | target in clock time |
|
inlinestatic |
Set a timer that wakes up a thread (relative version)
This function sets a timer that will wake up a thread when the timer has expired.
| [in] | clock | ztimer64 clock to operate on |
| [in] | timer | timer struct to work with. |
| [in] | offset | clock ticks from now |
| [in] | pid | pid of the thread that will be woken up |
Definition at line 378 of file ztimer64.h.
| void ztimer64_set_wakeup_at | ( | ztimer64_clock_t * | clock, |
| ztimer64_t * | timer, | ||
| uint64_t | target, | ||
| kernel_pid_t | pid | ||
| ) |
Set a timer that wakes up a thread (absolute version)
This function sets a timer that will wake up a thread when the timer has expired.
| [in] | clock | ztimer64 clock to operate on |
| [in] | timer | timer struct to work with. |
| [in] | target | wakeup time |
| [in] | pid | pid of the thread that will be woken up |
|
inlinestatic |
Put the calling thread to sleep for the specified number of ticks.
| [in] | clock | ztimer64 clock to use |
| [in] | duration | duration of sleep, in ztimer time units |
Definition at line 334 of file ztimer64.h.
| void ztimer64_sleep_until | ( | ztimer64_clock_t * | clock, |
| uint64_t | target | ||
| ) |
Put the calling thread to sleep until the specified time.
| [in] | clock | ztimer64 clock to use |
| [in] | target | wakeup time, in clock time |
|
inlinestatic |
Busy-wait until specified target time.
| [in] | clock | ztimer64 clock to use |
| [in] | target | time when spinning should end, in clock time |
Definition at line 347 of file ztimer64.h.