xtimer.h File Reference

xtimer interface definitions More...

Detailed Description

xtimer interface definitions

Author
Kaspar Schleiser kaspa.nosp@m.r@sc.nosp@m.hleis.nosp@m.er.d.nosp@m.e
Joakim NohlgÄrd joaki.nosp@m.m.no.nosp@m.hlgar.nosp@m.d@ei.nosp@m.stec..nosp@m.se

Definition in file xtimer.h.

#include <stdbool.h>
#include <stdint.h>
#include "timex.h"
#include "mutex.h"
#include "sched.h"
#include "rmutex.h"
#include "board.h"
#include "periph_conf.h"
#include "xtimer/tick_conversion.h"
#include "xtimer/implementation.h"
+ Include dependency graph for xtimer.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  xtimer_ticks64_t
 xtimer timestamp (64 bit) More...
 
struct  xtimer_ticks32_t
 xtimer timestamp (32 bit) More...
 
struct  xtimer
 xtimer timer structure More...
 

Macros

#define XTIMER_BACKOFF   30
 xtimer backoff value More...
 
#define XTIMER_ISR_BACKOFF   20
 xtimer IRQ backoff time, in hardware ticks More...
 
#define XTIMER_DEV   TIMER_DEV(0)
 Underlying hardware timer device to assign to xtimer.
 
#define XTIMER_CHAN   (0)
 Underlying hardware timer channel to assign to xtimer.
 
#define XTIMER_WIDTH   (32)
 xtimer timer width More...
 
#define XTIMER_MASK   ((0xffffffff >> XTIMER_WIDTH) << XTIMER_WIDTH)
 xtimer timer mask More...
 
#define XTIMER_HZ_BASE   (1000000ul)
 Base frequency of xtimer is 1 MHz.
 
#define XTIMER_HZ   XTIMER_HZ_BASE
 Frequency of the underlying hardware timer.
 
#define XTIMER_SHIFT   (1)
 

Typedefs

typedef void(* xtimer_callback_t) (void *)
 xtimer callback type
 
typedef struct xtimer xtimer_t
 xtimer timer structure
 

Functions

static xtimer_ticks32_t xtimer_now (void)
 get the current system time as 32bit time stamp value More...
 
static xtimer_ticks64_t xtimer_now64 (void)
 get the current system time as 64bit time stamp More...
 
void xtimer_now_timex (timex_t *out)
 get the current system time into a timex_t More...
 
static uint32_t xtimer_now_usec (void)
 get the current system time in microseconds since start More...
 
static uint64_t xtimer_now_usec64 (void)
 get the current system time in microseconds since start More...
 
void xtimer_init (void)
 xtimer initialization function More...
 
static void xtimer_sleep (uint32_t seconds)
 Pause the execution of a thread for some seconds. More...
 
static void xtimer_msleep (uint32_t milliseconds)
 Pause the execution of a thread for some milliseconds. More...
 
static void xtimer_usleep (uint32_t microseconds)
 Pause the execution of a thread for some microseconds. More...
 
static void xtimer_usleep64 (uint64_t microseconds)
 Pause the execution of a thread for some microseconds. More...
 
static void xtimer_nanosleep (uint32_t nanoseconds)
 Stop execution of a thread for some time. More...
 
static void xtimer_tsleep32 (xtimer_ticks32_t ticks)
 Stop execution of a thread for some time, 32bit version. More...
 
static void xtimer_tsleep64 (xtimer_ticks64_t ticks)
 Stop execution of a thread for some time, 64bit version. More...
 
static void xtimer_spin (xtimer_ticks32_t ticks)
 Stop execution of a thread for some time, blocking. More...
 
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). More...
 
static void xtimer_set_wakeup (xtimer_t *timer, uint32_t offset, kernel_pid_t pid)
 Set a timer that wakes up a thread. More...
 
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. More...
 
static void xtimer_set (xtimer_t *timer, uint32_t offset)
 Set a timer to execute a callback at some time in the future. More...
 
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. More...
 
void xtimer_remove (xtimer_t *timer)
 remove a timer More...
 
static xtimer_ticks32_t xtimer_ticks_from_usec (uint32_t usec)
 Convert microseconds to xtimer ticks. More...
 
static xtimer_ticks64_t xtimer_ticks_from_usec64 (uint64_t usec)
 Convert microseconds to xtimer ticks, 64 bit version. More...
 
static uint32_t xtimer_usec_from_ticks (xtimer_ticks32_t ticks)
 Convert xtimer ticks to microseconds. More...
 
static uint64_t xtimer_usec_from_ticks64 (xtimer_ticks64_t ticks)
 Convert xtimer ticks to microseconds, 64 bit version. More...
 
static xtimer_ticks32_t xtimer_ticks (uint32_t ticks)
 Create an xtimer time stamp. More...
 
static xtimer_ticks64_t xtimer_ticks64 (uint64_t ticks)
 Create an xtimer time stamp, 64 bit version. More...
 
static xtimer_ticks32_t xtimer_diff (xtimer_ticks32_t a, xtimer_ticks32_t b)
 Compute difference between two xtimer time stamps. More...
 
static xtimer_ticks64_t xtimer_diff64 (xtimer_ticks64_t a, xtimer_ticks64_t b)
 Compute difference between two xtimer time stamps, 64 bit version. More...
 
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. More...
 
static bool xtimer_less (xtimer_ticks32_t a, xtimer_ticks32_t b)
 Compare two xtimer time stamps. More...
 
static bool xtimer_less64 (xtimer_ticks64_t a, xtimer_ticks64_t b)
 Compare two xtimer time stamps, 64 bit version. More...
 
int xtimer_mutex_lock_timeout (mutex_t *mutex, uint64_t us)
 lock a mutex but with timeout More...
 
int xtimer_rmutex_lock_timeout (rmutex_t *rmutex, uint64_t us)
 lock a rmutex but with timeout More...
 
void xtimer_set_timeout_flag (xtimer_t *t, uint32_t timeout)
 Set timeout thread flag after timeout. More...
 
void xtimer_set_timeout_flag64 (xtimer_t *t, uint64_t timeout)
 Set timeout thread flag after timeout. More...
 
uint64_t xtimer_left_usec (const xtimer_t *timer)
 Get remaining time of timer. More...
 
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. More...
 
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. More...
 
static int xtimer_msg_receive_timeout (msg_t *msg, uint32_t timeout)
 receive a message blocking but with timeout More...
 
static int xtimer_msg_receive_timeout64 (msg_t *msg, uint64_t timeout)
 receive a message blocking but with timeout, 64bit version More...