Data Structures |
struct | rt_timer |
Defines |
#define | RT_TIMER_FLAG_DEACTIVATED 0x0 |
#define | RT_TIMER_FLAG_ACTIVATED 0x1 |
#define | RT_TIMER_FLAG_ONE_SHOT 0x0 |
#define | RT_TIMER_FLAG_PERIODIC 0x2 |
#define | RT_TIMER_FLAG_HARD_TIMER 0x0 |
#define | RT_TIMER_FLAG_SOFT_TIMER 0x4 |
#define | RT_TIMER_CTRL_SET_TIME 0x0 |
#define | RT_TIMER_CTRL_GET_TIME 0x1 |
#define | RT_TIMER_CTRL_SET_ONESHOT 0x2 |
#define | RT_TIMER_CTRL_SET_PERIODIC 0x3 |
Functions |
rt_tick_t | rt_tick_get (void) |
void | rt_tick_set (rt_tick_t tick) |
void | rt_tick_increase (void) |
rt_tick_t | rt_tick_from_millisecond (rt_uint32_t ms) |
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 (void) |
void | rt_system_tick_init (void) |
void | rt_system_timer_init (void) |
void | rt_system_timer_thread_init (void) |
void | rt_timer_timeout_sethook (void(*hook)(struct rt_timer *timer)) |
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.
Define Documentation
clock & timer macros timer is deactive
hard timer,the timer's callback function will be called in tick isr.
soft timer,the timer's callback function will be called in timer thread.
set timer control command
get timer control command
Function Documentation
This function will return current tick from operating system startup
- Returns:
- current tick
This function will set current tick
This function will notify kernel there is one tick passed. Normally, this function is invoked by clock ISR.
This function will calculate the tick from millisecond.
- Parameters:
-
ms | the specified millisecond |
- Returns:
- the calculated tick
This function will initialize 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 |
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
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
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
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
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
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:
- RT_EOK
This function will check timer list, if a timeout event happens, the corresponding timeout function will be invoked.
- Note:
- this function shall be invoked in operating system timer interrupt.
This function will init system tick and set it to zero.
This function will initialize system timer
This function will initialize system timer thread
This function will set a hook function, which will be invoked when timer is timeout.
- Parameters:
-