57 #include "dev/watchdog.h" 61 #ifdef RTIMER_CONF_CLOCK_SIZE 62 #define RTIMER_CLOCK_SIZE RTIMER_CONF_CLOCK_SIZE 65 #define RTIMER_CLOCK_SIZE 4 68 #if RTIMER_CLOCK_SIZE == 2 70 typedef uint16_t rtimer_clock_t;
71 #define RTIMER_CLOCK_DIFF(a,b) ((int16_t)((a)-(b))) 73 #elif RTIMER_CLOCK_SIZE == 4 75 typedef uint32_t rtimer_clock_t;
76 #define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b))) 78 #elif RTIMER_CLOCK_SIZE == 8 80 typedef uint64_t rtimer_clock_t;
81 #define RTIMER_CLOCK_DIFF(a,b) ((int64_t)((a)-(b))) 84 #error Unsupported rtimer size (check RTIMER_CLOCK_SIZE) 87 #define RTIMER_CLOCK_MAX ((rtimer_clock_t)-1) 88 #define RTIMER_CLOCK_LT(a, b) (RTIMER_CLOCK_DIFF((a),(b)) < 0) 90 #include "rtimer-arch.h" 102 typedef void (* rtimer_callback_t)(
struct rtimer *t,
void *ptr);
113 rtimer_callback_t func;
121 RTIMER_ERR_ALREADY_SCHEDULED,
139 rtimer_clock_t duration, rtimer_callback_t func,
void *ptr);
160 #define RTIMER_NOW() rtimer_arch_now() 173 #define RTIMER_TIME(task) ((task)->time) 179 #define RTIMER_SECOND RTIMER_ARCH_SECOND 185 #ifdef RTIMER_CONF_GUARD_TIME 186 #define RTIMER_GUARD_TIME RTIMER_CONF_GUARD_TIME 188 #define RTIMER_GUARD_TIME (RTIMER_ARCH_SECOND >> 14) 192 #ifndef RTIMER_BUSYWAIT_UNTIL_ABS 193 #define RTIMER_BUSYWAIT_UNTIL_ABS(cond, t0, max_time) \ 196 while(!(c = cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), (t0) + (max_time))); \ 202 #define RTIMER_BUSYWAIT_UNTIL(cond, max_time) \ 204 rtimer_clock_t t0 = RTIMER_NOW(); \ 205 RTIMER_BUSYWAIT_UNTIL_ABS(cond, t0, max_time); \ 209 #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.
void rtimer_run_next(void)
Execute the next real-time task and schedule the next task, if any.
void rtimer_arch_init(void)
We don't need to explicitly initialise anything but this routine is required by the API...
void rtimer_init(void)
Initialize the real-time scheduler.
void rtimer_arch_schedule(rtimer_clock_t t)
Schedules an rtimer task to be triggered at time t.