57#define XTIMER_WIDTH (32)
58#define XTIMER_MASK (0)
65#define XTIMER_BACKOFF 1
72#define _XTIMER_BACKEND_NOT_IMPLEMENTED \
73 extern void xtimer_function_called_but_no_backend_available(void); \
74 xtimer_function_called_but_no_backend_available()
81static inline uint32_t _div_round_up_u32(uint32_t a, uint32_t b)
83 return (a + b - 1) / b;
86static inline uint32_t _div_round_up_u64(uint64_t a, uint32_t b)
88 return (a + b - 1) / b;
113 return _div_round_up_u32(ticks,
US_PER_MS);
128 if (
IS_USED(MODULE_ZTIMER_USEC)) {
131 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
135 _XTIMER_BACKEND_NOT_IMPLEMENTED;
145static inline uint32_t xtimer_now_msec(
void)
147 if (
IS_USED(MODULE_ZTIMER_MSEC)) {
150 if (
IS_USED(MODULE_ZTIMER_USEC)) {
154 _XTIMER_BACKEND_NOT_IMPLEMENTED;
161 if (
IS_USED(MODULE_ZTIMER_USEC)) {
164 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
168 _XTIMER_BACKEND_NOT_IMPLEMENTED;
212 else if (
IS_USED(MODULE_ZTIMER_USEC)) {
222 if (
IS_USED(MODULE_ZTIMER_USEC)) {
225 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
235 if (
IS_USED(MODULE_ZTIMER_USEC)) {
238 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
242 _XTIMER_BACKEND_NOT_IMPLEMENTED;
248 if (
IS_USED(MODULE_ZTIMER_USEC)) {
251 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
255 _XTIMER_BACKEND_NOT_IMPLEMENTED;
267 if (
IS_USED(MODULE_ZTIMER_USEC)) {
270 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
275 _XTIMER_BACKEND_NOT_IMPLEMENTED;
282 if (
IS_USED(MODULE_ZTIMER_USEC)) {
285 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
289 _XTIMER_BACKEND_NOT_IMPLEMENTED;
295 if (
IS_USED(MODULE_ZTIMER_USEC)) {
298 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
302 _XTIMER_BACKEND_NOT_IMPLEMENTED;
310 if (
IS_USED(MODULE_ZTIMER_USEC)) {
313 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
317 _XTIMER_BACKEND_NOT_IMPLEMENTED;
325 if (
IS_USED(MODULE_ZTIMER_USEC)) {
328 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
333 _XTIMER_BACKEND_NOT_IMPLEMENTED;
345 if (
IS_USED(MODULE_ZTIMER_USEC)) {
348 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
353 _XTIMER_BACKEND_NOT_IMPLEMENTED;
363 if (
IS_USED(MODULE_ZTIMER_USEC)) {
366 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
370 _XTIMER_BACKEND_NOT_IMPLEMENTED;
376 if (
IS_USED(MODULE_ZTIMER_USEC)) {
379 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
383 _XTIMER_BACKEND_NOT_IMPLEMENTED;
389 if (
IS_USED(MODULE_ZTIMER_USEC)) {
392 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
454#if defined(MODULE_CORE_MSG) || defined(DOXYGEN)
458 if (
IS_USED(MODULE_ZTIMER_USEC)) {
461 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
463 _div_round_up_u64(offset,
US_PER_MS), msg, target_pid);
466 _XTIMER_BACKEND_NOT_IMPLEMENTED;
472 if (
IS_USED(MODULE_ZTIMER_USEC)) {
475 else if (
IS_USED(MODULE_ZTIMER_MSEC)) {
480 _XTIMER_BACKEND_NOT_IMPLEMENTED;
POSIX.1-2008 compliant version of the assert macro.
#define assume(cond)
Behaves like an assert(), but tells the compiler that cond can never be false.
static uint64_t div_u64_by_1000000(uint64_t val)
Integer divide val by 1000000.
int16_t kernel_pid_t
Unique process identifier.
#define US_PER_MS
The number of microseconds per millisecond.
#define US_PER_SEC
The number of microseconds per second.
void xtimer_set_timeout_flag64(xtimer_t *t, uint64_t timeout)
Set timeout thread flag after timeout.
static void xtimer_usleep(uint32_t microseconds)
Pause the execution of a thread for some microseconds.
static xtimer_ticks32_t xtimer_diff(xtimer_ticks32_t a, xtimer_ticks32_t b)
Compute difference between two xtimer time stamps.
static uint32_t xtimer_now_usec(void)
get the current system time in microseconds since start
static xtimer_ticks64_t xtimer_ticks_from_usec64(uint64_t usec)
Convert microseconds to xtimer ticks, 64 bit version.
static void xtimer_set_msg64(xtimer_t *timer, uint64_t offset, msg_t *msg, kernel_pid_t target_pid)
Set a timer that sends a message, 64bit version.
void xtimer_remove(xtimer_t *timer)
remove a timer
static void xtimer_set_wakeup64(xtimer_t *timer, uint64_t offset, kernel_pid_t pid)
Set a timer that wakes up a thread, 64bit version.
static bool xtimer_less64(xtimer_ticks64_t a, xtimer_ticks64_t b)
Compare two xtimer time stamps, 64 bit version.
static xtimer_ticks64_t xtimer_now64(void)
get the current system time as 64bit time stamp
static void xtimer_set64(xtimer_t *timer, uint64_t offset_us)
Set a timer to execute a callback at some time in the future, 64bit version.
void(* xtimer_callback_t)(void *)
xtimer callback type
static void xtimer_tsleep32(xtimer_ticks32_t ticks)
Stop execution of a thread for some time, 32bit version.
static void xtimer_msleep(uint32_t milliseconds)
Pause the execution of a thread for some milliseconds.
static void xtimer_sleep(uint32_t seconds)
Pause the execution of a thread for some seconds.
static xtimer_ticks32_t xtimer_diff32_64(xtimer_ticks64_t a, xtimer_ticks64_t b)
Compute 32 bit difference between two 64 bit xtimer time stamps.
int xtimer_rmutex_lock_timeout(rmutex_t *rmutex, uint64_t us)
lock a rmutex but with timeout
static xtimer_ticks64_t xtimer_ticks64(uint64_t ticks)
Create an xtimer time stamp, 64 bit version.
static void xtimer_periodic_wakeup(xtimer_ticks32_t *last_wakeup, uint32_t period)
will cause the calling thread to be suspended until the absolute time (last_wakeup + period).
static void xtimer_set_msg(xtimer_t *timer, uint32_t offset, msg_t *msg, kernel_pid_t target_pid)
Set a timer that sends a message.
static bool xtimer_less(xtimer_ticks32_t a, xtimer_ticks32_t b)
Compare two xtimer time stamps.
static uint32_t xtimer_usec_from_ticks(xtimer_ticks32_t ticks)
Convert xtimer ticks to microseconds.
static xtimer_ticks64_t xtimer_diff64(xtimer_ticks64_t a, xtimer_ticks64_t b)
Compute difference between two xtimer time stamps, 64 bit version.
int xtimer_mutex_lock_timeout(mutex_t *mutex, uint64_t us)
lock a mutex but with timeout
static void xtimer_usleep64(uint64_t microseconds)
Pause the execution of a thread for some microseconds.
static int xtimer_msg_receive_timeout(msg_t *msg, uint32_t timeout)
receive a message blocking but with timeout
void xtimer_now_timex(timex_t *out)
get the current system time into a timex_t
void xtimer_set_timeout_flag(xtimer_t *t, uint32_t timeout)
Set timeout thread flag after timeout.
static void xtimer_tsleep64(xtimer_ticks64_t ticks)
Stop execution of a thread for some time, 64bit version.
static void xtimer_set_wakeup(xtimer_t *timer, uint32_t offset, kernel_pid_t pid)
Set a timer that wakes up a thread.
void xtimer_init(void)
xtimer initialization function
static void xtimer_spin(xtimer_ticks32_t ticks)
Stop execution of a thread for some time, blocking.
static uint64_t xtimer_now_usec64(void)
get the current system time in microseconds since start
static void xtimer_set(xtimer_t *timer, uint32_t offset)
Set a timer to execute a callback at some time in the future.
static xtimer_ticks32_t xtimer_ticks_from_usec(uint32_t usec)
Convert microseconds to xtimer ticks.
struct xtimer xtimer_t
xtimer timer structure
static xtimer_ticks32_t xtimer_ticks(uint32_t ticks)
Create an xtimer time stamp.
static xtimer_ticks32_t xtimer_now(void)
get the current system time as 32bit time stamp value
static bool xtimer_is_set(const xtimer_t *timer)
state if an xtimer is currently set (waiting to be expired)
static uint64_t xtimer_usec_from_ticks64(xtimer_ticks64_t ticks)
Convert xtimer ticks to microseconds, 64 bit version.
static int xtimer_msg_receive_timeout64(msg_t *msg, uint64_t timeout)
receive a message blocking but with timeout, 64bit version
void ztimer64_init(void)
Initialize the board-specific default ztimer configuration.
unsigned ztimer64_is_set(const ztimer64_t *timer)
Check if a timer is currently active.
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)
void ztimer64_remove(ztimer64_clock_t *clock, ztimer64_t *timer)
Remove a timer from a clock.
static void ztimer64_set_timeout_flag(ztimer64_clock_t *clock, ztimer64_t *timer, uint64_t timeout)
Set timeout thread flag after timeout.
uint64_t ztimer64_now(ztimer64_clock_t *clock)
Get the current time from a clock.
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)
static int ztimer64_msg_receive_timeout(ztimer64_clock_t *clock, msg_t *msg, uint64_t timeout)
receive a message (blocking, with relative timeout)
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.
static void ztimer64_set(ztimer64_clock_t *clock, ztimer64_t *timer, uint64_t offset)
Set a timer on a clock (relative version)
static void ztimer64_sleep(ztimer64_clock_t *clock, uint64_t duration)
Put the calling thread to sleep for the specified number of ticks.
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.
ztimer64_clock_t *const ZTIMER64_USEC
Default ztimer microsecond clock.
ztimer64_clock_t *const ZTIMER64_MSEC
Default ztimer millisecond clock.
void ztimer_periodic_wakeup(ztimer_clock_t *clock, uint32_t *last_wakeup, uint32_t period)
Suspend the calling thread until the time (last_wakeup + period)
ztimer_clock_t *const ZTIMER_USEC
Default ztimer microsecond clock.
static void ztimer_spin(ztimer_clock_t *clock, uint32_t duration)
Busy-wait specified duration.
static ztimer_now_t ztimer_now(ztimer_clock_t *clock)
Get the current time from a clock.
int ztimer_msg_receive_timeout(ztimer_clock_t *clock, msg_t *msg, uint32_t timeout)
receive a message (blocking, with timeout)
void ztimer_sleep(ztimer_clock_t *clock, uint32_t duration)
Put the calling thread to sleep for the specified number of ticks.
ztimer_clock_t *const ZTIMER_MSEC
Default ztimer millisecond clock.
uint32_t _xtimer_now(void)
xtimer internal stuff
#define IS_USED(module)
Checks whether a module is being used or not.
#define IS_ACTIVE(macro)
Allows to verify a macro definition outside the preprocessor.
Mutex for thread synchronization.
time_point now()
Returns the current time saved in a time point.
Describes a message object which can be sent between threads.
uint32_t seconds
number of seconds
uint32_t microseconds
number of microseconds
xtimer timestamp (32 bit)
xtimer timestamp (64 bit)
Utility library for comparing and computing timestamps.