Contiki 3.x
Data Structures | Macros | Functions
Real-time task scheduling

The real-time module handles the scheduling and execution of real-time tasks (with predictable execution times). More...

Data Structures

struct  rtimer
 Representation of a real-time task. More...
 

Macros

#define RTIMER_NOW()
 Get the current clock time. More...
 
#define RTIMER_TIME(task)
 Get the time that a task last was executed. More...
 

Functions

void rtimer_init (void)
 Initialize the real-time scheduler. 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...
 
void rtimer_run_next (void)
 Execute the next real-time task and schedule the next task, if any. More...
 
void rtimer_arch_init (void)
 We don't need to explicitly initialise anything but this routine is required by the API. More...
 
void rtimer_arch_schedule (rtimer_clock_t t)
 Schedules an rtimer task to be triggered at time t. More...
 

Detailed Description

The real-time module handles the scheduling and execution of real-time tasks (with predictable execution times).

Macro Definition Documentation

#define RTIMER_NOW ( )

Get the current clock time.

Returns
The current 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.
Examples:
example-rudolph1.c.

Definition at line 133 of file rtimer.h.

Referenced by clock_init(), main(), and rtimer_arch_schedule().

#define RTIMER_TIME (   task)

Get the time that a task last was executed.

Parameters
taskThe task
Returns
The time that a task last was executed
        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.
Examples:
example-rudolph1.c.

Definition at line 146 of file rtimer.h.

Function Documentation

void rtimer_arch_init ( void  )

We don't need to explicitly initialise anything but this routine is required by the API.

The Sleep Timer starts ticking automatically as soon as the device turns on. We don't need to turn on interrupts before the first call to rtimer_arch_schedule()

Definition at line 78 of file rtimer-arch.c.

References NVIC_EnableIRQ(), and WUT_IRQn.

Referenced by rtimer_init().

void rtimer_arch_schedule ( rtimer_clock_t  t)

Schedules an rtimer task to be triggered at time t.

Parameters
tThe time when the task will need executed. This is an absolute time, in other words the task will be executed AT time t, not IN t ticks

Definition at line 115 of file rtimer-arch.c.

References clock_time(), INTERRUPTS_DISABLE, INTERRUPTS_ENABLE, NULL, NVIC_INT_SM_TIMER, nvic_interrupt_enable(), rtimer_arch_now, RTIMER_NOW, SMWDTHROSC_ST0, SMWDTHROSC_ST1, SMWDTHROSC_ST2, SMWDTHROSC_ST3, SMWDTHROSC_STLOAD, and SMWDTHROSC_STLOAD_STLOAD.

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.

Definition at line 61 of file rtimer.c.

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.

Definition at line 92 of file rtimer.c.

References NULL, and rtimer_arch_schedule().

Referenced by _isr_pit0(), and rtimer_isr().

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.

Parameters
taskA pointer to the task variable previously declared with RTIMER_TASK().
timeThe time when the task is to be executed.
durationUnused argument.
funcA function to be called when the task is executed.
ptrAn opaque pointer that will be supplied as an argument to the callback function.
Returns
Non-zero (true) if the task could be scheduled, zero (false) if the task could not be scheduled.

This function schedules a real-time task at a specified time in the future.

Examples:
example-rudolph1.c.

Definition at line 67 of file rtimer.c.

References NULL, and rtimer_arch_schedule().

Referenced by clock_init(), and main().