The real-time module handles the scheduling and execution of real-time tasks (with predictable execution times).
Data Structures | |
struct | rtimer |
Representation of a real-time task. More... | |
Files | |
file | rtimer.c |
Implementation of the architecture-agnostic parts of the real-time timer module. | |
file | rtimer.h |
Header file for the real-time timer module. | |
Macros | |
#define | _DEBUG_ 0 |
#define | PRINTF(...) |
#define | RTIMER_CLOCK_LT(a, b) ((signed short)((a)-(b)) < 0) |
#define | RTIMER_NOW() |
Get the current clock time. More... | |
#define | RTIMER_SECOND RTIMER_ARCH_SECOND |
#define | RTIMER_TIME(task) |
Get the time that a task last was executed. More... | |
Typedefs | |
typedef void(* | rtimer_callback_t )(struct rtimer *t, void *ptr) |
typedef unsigned short | rtimer_clock_t |
Enumerations | |
enum | { RTIMER_OK, RTIMER_ERR_FULL, RTIMER_ERR_TIME, RTIMER_ERR_ALREADY_SCHEDULED } |
Functions | |
void | rtimer_arch_init (void) |
void | rtimer_arch_schedule (rtimer_clock_t t) |
void | rtimer_init (void) |
Initialize the real-time scheduler. More... | |
void | rtimer_run_next (void) |
Execute the next real-time task and schedule the next task, if any. More... | |
int | rtimer_set (struct rtimer *task, rtimer_clock_t time, rtimer_clock_t duration, rtimer_callback_t func, void *ptr) |
Post a real-time task. More... | |
Variables | |
static struct rtimer * | next_rtimer |
#define _DEBUG_ 0 |
#define PRINTF | ( | ... | ) |
Referenced by rtimer_set().
#define RTIMER_CLOCK_LT | ( | a, | |
b | |||
) | ((signed short)((a)-(b)) < 0) |
Referenced by phase_wait(), powercycle(), rtimer_arch_schedule(), schedule_powercycle(), schedule_powercycle_fixed(), send_one_packet(), and send_packet().
#define RTIMER_NOW | ( | ) |
Get the current clock time.
This function returns what the real-time module thinks is the current time. The current time is used to set the timeouts for real-time tasks.
Referenced by echo_reply_callback(), init(), phase_wait(), powercycle(), PROCESS_THREAD(), schedule_powercycle(), schedule_powercycle_fixed(), send_one_packet(), send_packet(), and turn_on().
#define RTIMER_SECOND RTIMER_ARCH_SECOND |
#define RTIMER_TIME | ( | task | ) |
Get the time that a task last was executed.
task | The task |
This function returns the time that the task was last executed. This typically is used to get a periodic execution of a task without clock drift.
Referenced by schedule_powercycle().
typedef unsigned short rtimer_clock_t |
void rtimer_arch_init | ( | void | ) |
References tc_config::clock_prescaler, tc_config::clock_source, configure_rtc_callbacks(), configure_rtc_count(), tc_config::counter_size, GCLK_GENERATOR_5, ret, rtimer_irq_callback(), tc_config::run_in_standby, SYSTEM_INTERRUPT_PRIORITY_LEVEL_1, system_interrupt_set_priority(), TC_CALLBACK_CC_CHANNEL0, TC_CLOCK_PRESCALER_DIV256, TC_COUNTER_SIZE_32BIT, tc_enable(), tc_enable_callback(), tc_get_config_defaults(), tc_init(), tc_instance, tc_register_callback(), and TIMER.
Referenced by rtimer_init().
void rtimer_arch_schedule | ( | rtimer_clock_t | t | ) |
References printf, rtimer_arch_now(), RTIMER_CLOCK_LT, RTIMER_COMPENSATION_TICKS, rtimer_run_next(), RTIMER_SYNC_VALUE, TC_COMPARE_CAPTURE_CHANNEL_0, tc_instance, and tc_set_compare_value().
Referenced by rtimer_run_next(), and rtimer_set().
void rtimer_init | ( | void | ) |
Initialize the real-time scheduler.
This function initializes the real-time scheduler and must be called at boot-up, before any other functions from the real-time scheduler is called.
References rtimer_arch_init().
Referenced by main().
void rtimer_run_next | ( | void | ) |
Execute the next real-time task and schedule the next task, if any.
This function is called by the architecture dependent code to execute and schedule the next real-time task.
References rtimer::func, next_rtimer, NULL, rtimer::ptr, rtimer_arch_schedule(), and rtimer::time.
Referenced by rtimer_adjust_ticks(), rtimer_arch_schedule(), and rtimer_irq_callback().
int rtimer_set | ( | struct rtimer * | task, |
rtimer_clock_t | time, | ||
rtimer_clock_t | duration, | ||
rtimer_callback_t | func, | ||
void * | ptr | ||
) |
Post a real-time task.
task | A pointer to the task variable previously declared with RTIMER_TASK(). |
time | The time when the task is to be executed. |
duration | Unused argument. |
func | A function to be called when the task is executed. |
ptr | An opaque pointer that will be supplied as an argument to the callback function. |
This function schedules a real-time task at a specified time in the future.
References rtimer::func, NULL, PRINTF, rtimer::ptr, ptr, rtimer_arch_schedule(), RTIMER_OK, and rtimer::time.
Referenced by init(), schedule_powercycle(), schedule_powercycle_fixed(), and turn_on().
|
static |
Referenced by rtimer_run_next().