57 #include "dev/watchdog.h" 63 #ifdef RTIMER_CONF_CLOCK_SIZE 64 #define RTIMER_CLOCK_SIZE RTIMER_CONF_CLOCK_SIZE 67 #define RTIMER_CLOCK_SIZE 4 70 #if RTIMER_CLOCK_SIZE == 2 72 typedef uint16_t rtimer_clock_t;
73 #define RTIMER_CLOCK_DIFF(a,b) ((int16_t)((a)-(b))) 75 #elif RTIMER_CLOCK_SIZE == 4 77 typedef uint32_t rtimer_clock_t;
78 #define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b))) 80 #elif RTIMER_CLOCK_SIZE == 8 82 typedef uint64_t rtimer_clock_t;
83 #define RTIMER_CLOCK_DIFF(a,b) ((int64_t)((a)-(b))) 86 #error Unsupported rtimer size (check RTIMER_CLOCK_SIZE) 89 #define RTIMER_CLOCK_MAX ((rtimer_clock_t)-1) 90 #define RTIMER_CLOCK_LT(a, b) (RTIMER_CLOCK_DIFF((a),(b)) < 0) 92 #include "rtimer-arch.h" 101 #ifdef RTIMER_CONF_GUARD_TIME 102 #define RTIMER_GUARD_TIME RTIMER_CONF_GUARD_TIME 104 #define RTIMER_GUARD_TIME (RTIMER_ARCH_SECOND >> 14) 112 #define RTIMER_SECOND RTIMER_ARCH_SECOND 124 typedef void (* rtimer_callback_t)(
struct rtimer *t,
void *ptr);
135 rtimer_callback_t func;
146 RTIMER_ERR_ALREADY_SCHEDULED,
164 rtimer_clock_t duration, rtimer_callback_t func,
void *ptr);
185 #define RTIMER_NOW() rtimer_arch_now() 198 #define RTIMER_TIME(task) ((task)->time) 201 #ifndef RTIMER_BUSYWAIT_UNTIL_ABS 202 #define RTIMER_BUSYWAIT_UNTIL_ABS(cond, t0, max_time) \ 205 while(!(c = cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), (t0) + (max_time))); \ 211 #define RTIMER_BUSYWAIT_UNTIL(cond, max_time) \ 213 rtimer_clock_t t0 = RTIMER_NOW(); \ 214 RTIMER_BUSYWAIT_UNTIL_ABS(cond, t0, max_time); \ 218 #define RTIMER_BUSYWAIT(duration) RTIMER_BUSYWAIT_UNTIL(0, duration) int rtimer_set(struct rtimer *rtimer, rtimer_clock_t time, rtimer_clock_t duration, rtimer_callback_t func, void *ptr)
Post a real-time task.
Representation of a real-time task.
rtimer task is scheduled successfully
void rtimer_run_next(void)
Execute the next real-time task and schedule the next task, if any.
void rtimer_arch_init(void)
Initialized the architecture-dependent part of rtimer.
void rtimer_init(void)
Initialize the real-time scheduler.
void rtimer_arch_schedule(rtimer_clock_t t)
Schedule the call to rtimer_run_next at the time t.