Clock and Timer Management
[RT-Thread Kernel API]


Functions

void rt_system_tick_init (void)
rt_tick_t rt_tick_get (void)
void rt_tick_increase (void)
rt_tick_t rt_tick_from_millisecond (rt_uint32_t ms)
void rt_system_timer_init (void)
void rt_timer_init (rt_timer_t timer, const char *name, void(*timeout)(void *parameter), void *parameter, rt_tick_t time, rt_uint8_t flag)
rt_err_t rt_timer_detach (rt_timer_t timer)
rt_timer_t rt_timer_create (const char *name, void(*timeout)(void *parameter), void *parameter, rt_tick_t time, rt_uint8_t flag)
rt_err_t rt_timer_delete (rt_timer_t timer)
rt_err_t rt_timer_start (rt_timer_t timer)
rt_err_t rt_timer_stop (rt_timer_t timer)
rt_err_t rt_timer_control (rt_timer_t timer, rt_uint8_t cmd, void *arg)
void rt_timer_check ()

Detailed Description

RT-Thread uses clock tick to implement shared time-slice scheduling.

The timing sensitivity of thread is implemented by timers. The timer can be set as one-shot or periodic timeout.


Function Documentation

void rt_system_tick_init ( void   ) 

This function will init system tick and set it to zero.

void rt_system_timer_init (  ) 

This function will init system timer

rt_tick_t rt_tick_from_millisecond ( rt_uint32_t  ms  ) 

This function will calculate the tick from millisecond.

Parameters:
ms the specified millisecond
Returns:
the calculated tick

rt_tick_t rt_tick_get (  ) 

This function will return current tick from operating system startup

Returns:
current tick

void rt_tick_increase (  ) 

This function will notify kernel there is one tick passed. Normally, this function is invoked by clock ISR.

void rt_timer_check ( void   ) 

This function will check timer list, if a timeout event happens, the corresponding timeout function will be invoked.

rt_err_t rt_timer_control ( rt_timer_t  timer,
rt_uint8_t  cmd,
void *  arg 
)

This function will get or set some options of the timer

Parameters:
timer the timer to be get or set
cmd the control command
arg the argument
Returns:
the operation status, RT_EOK on OK; RT_ERROR on error

rt_timer_t rt_timer_create ( const char *  name,
void(*)(void *parameter)  timeout,
void *  parameter,
rt_tick_t  time,
rt_uint8_t  flag 
)

This function will create a timer

Parameters:
name the name of timer
timeout the timeout function
parameter the parameter of timeout function
time the tick of timer
flag the flag of timer
Returns:
the created timer object

rt_err_t rt_timer_delete ( rt_timer_t  timer  ) 

This function will delete a timer and release timer memory

Parameters:
timer the timer to be deleted
Returns:
the operation status, RT_EOK on OK; RT_ERROR on error

rt_err_t rt_timer_detach ( rt_timer_t  timer  ) 

This function will detach a timer from timer management.

Parameters:
timer the static timer object
Returns:
the operation status, RT_EOK on OK; RT_ERROR on error

void rt_timer_init ( rt_timer_t  timer,
const char *  name,
void(*)(void *parameter)  timeout,
void *  parameter,
rt_tick_t  time,
rt_uint8_t  flag 
)

This function will init a timer, normally this function is used to initialize a static timer object.

Parameters:
timer the static timer object
name the name of timer
timeout the timeout function
parameter the parameter of timeout function
time the tick of timer
flag the flag of timer

rt_err_t rt_timer_start ( rt_timer_t  timer  ) 

This function will start the timer

Parameters:
timer the timer to be started
Returns:
the operation status, RT_EOK on OK; RT_ERROR on error

rt_err_t rt_timer_stop ( rt_timer_t  timer  ) 

This function will stop the timer

Parameters:
timer the timer to be stopped
Returns:
the operation status, RT_EOK on OK; RT_ERROR on error


Generated on Thu Oct 9 07:19:09 2008 for RT-Thread Kernel by  doxygen 1.5.7