RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
|
结构体 | |
struct | rt_timer |
宏定义 | |
#define | _update_process_times(tick) |
#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_FLAG_THREAD_TIMER (0x8 | RT_TIMER_FLAG_HARD_TIMER) |
#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 |
#define | RT_TIMER_CTRL_GET_STATE 0x4 |
#define | RT_TIMER_CTRL_GET_REMAIN_TIME 0x5 |
#define | RT_TIMER_CTRL_GET_FUNC 0x6 |
#define | RT_TIMER_CTRL_SET_FUNC 0x7 |
#define | RT_TIMER_CTRL_GET_PARM 0x8 |
#define | RT_TIMER_CTRL_SET_PARM 0x9 |
#define | RT_TIMER_SKIP_LIST_LEVEL 1 |
#define | RT_TIMER_SKIP_LIST_MASK 0x3 |
类型定义 | |
typedef void(* | rt_timer_func_t) (void *parameter) |
typedef struct rt_timer * | rt_timer_t |
clock and system timer management
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 RT_TIMER_FLAG_HARD_TIMER 0x0 |
#define RT_TIMER_FLAG_SOFT_TIMER 0x4 |
#define RT_TIMER_FLAG_THREAD_TIMER (0x8 | RT_TIMER_FLAG_HARD_TIMER) |
typedef void(* rt_timer_func_t) (void *parameter) |
typedef struct rt_timer* rt_timer_t |
rt_tick_t rt_tick_get | ( | void | ) |
This function will return current tick from operating system startup.
引用了 rt_atomic_load.
RTM_EXPORT | ( | rt_tick_get | ) |
void rt_tick_set | ( | rt_tick_t | tick | ) |
This function will set current tick.
tick | is the value that you will set. |
引用了 rt_atomic_store.
void rt_tick_increase | ( | void | ) |
This function will notify kernel there is one tick passed. Normally, this function is invoked by clock ISR.
引用了 _update_process_times, RT_ASSERT, rt_atomic_add, rt_cpu_get_id, rt_cpu_self(), rt_interrupt_get_nest(), RT_OBJECT_HOOK_CALL, rt_sched_tick_increase() , 以及 rt_timer_check().
void rt_tick_increase_tick | ( | rt_tick_t | tick | ) |
This function will notify kernel there is n tick passed. Normally, this function is invoked by clock ISR.
引用了 _update_process_times, RT_ASSERT, rt_atomic_add, rt_cpu_get_id, rt_cpu_self(), rt_interrupt_get_nest(), RT_OBJECT_HOOK_CALL, rt_sched_tick_increase() , 以及 rt_timer_check().
rt_tick_t rt_tick_from_millisecond | ( | rt_int32_t | ms | ) |
This function will calculate the tick from millisecond.
ms | is the specified millisecond.
|
引用了 RT_WAITING_FOREVER.
RTM_EXPORT | ( | rt_tick_from_millisecond | ) |
rt_tick_t rt_tick_get_millisecond | ( | void | ) |
This function will return the passed millisecond from boot.
引用了 rt_tick_get().
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 ) |
This function will initialize a timer normally this function is used to initialize a static timer object.
timer | is the point of timer |
name | is a pointer to the name of the timer |
timeout | is the callback of timer |
parameter | is the param of the callback |
time | is timeout ticks of timer NOTE: The max timeout tick should be no more than (RT_TICK_MAX/2 - 1). |
flag | is the flag of timer |
引用了 rt_timer::parameter, rt_timer::parent, RT_ASSERT, RT_NULL, RT_Object_Class_Timer, rt_object_init() , 以及 RT_TICK_MAX.
RTM_EXPORT | ( | rt_timer_init | ) |
rt_err_t rt_timer_detach | ( | rt_timer_t | timer | ) |
This function will detach a timer from timer management.
timer | is the timer to be detached |
引用了 _timer_remove(), _timerlock_idx(), rt_object::flag, rt_timer::parent, RT_ASSERT, RT_NULL, RT_Object_Class_Timer, rt_object_detach(), rt_object_get_type(), rt_object_is_systemobject(), rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore() , 以及 RT_TIMER_FLAG_ACTIVATED.
RTM_EXPORT | ( | rt_timer_detach | ) |
rt_timer_t rt_timer_create | ( | const char * | name, |
void(* | timeout )(void *parameter), | ||
void * | parameter, | ||
rt_tick_t | time, | ||
rt_uint8_t | flag ) |
This function will create a timer
name | is the name of timer |
timeout | is the timeout function |
parameter | is the parameter of timeout function |
time | is timeout ticks of the timer NOTE: The max timeout tick should be no more than (RT_TICK_MAX/2 - 1). |
flag | is the flag of timer. Timer will invoke the timeout function according to the selected values of flag, if one or more of the following flags is set. RT_TIMER_FLAG_ONE_SHOT One shot timing RT_TIMER_FLAG_PERIODIC Periodic timing RT_TIMER_FLAG_HARD_TIMER Hardware timer RT_TIMER_FLAG_SOFT_TIMER Software timer RT_TIMER_FLAG_THREAD_TIMER Thread timer NOTE: You can use multiple values with "|" logical operator. By default, system will use the RT_TIME_FLAG_HARD_TIMER. |
引用了 rt_timer::parameter, RT_ASSERT, RT_NULL, rt_object_allocate(), RT_Object_Class_Timer , 以及 RT_TICK_MAX.
RTM_EXPORT | ( | rt_timer_create | ) |
rt_err_t rt_timer_delete | ( | rt_timer_t | timer | ) |
This function will delete a timer and release timer memory
timer | the timer to be deleted |
引用了 _timer_remove(), _timerlock_idx(), rt_object::flag, rt_timer::parent, RT_ASSERT, RT_FALSE, RT_NULL, RT_Object_Class_Timer, rt_object_delete(), rt_object_get_type(), rt_object_is_systemobject(), rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore() , 以及 RT_TIMER_FLAG_ACTIVATED.
RTM_EXPORT | ( | rt_timer_delete | ) |
rt_err_t rt_timer_start | ( | rt_timer_t | timer | ) |
This function will start the timer
timer | the timer to be started |
引用了 rt_object::flag, rt_thread::parent, rt_timer::parent, RT_ASSERT, rt_container_of, RT_NULL, RT_Object_Class_Thread, RT_Object_Class_Timer, rt_object_get_type(), rt_sched_lock(), rt_sched_thread_timer_start(), rt_sched_unlock(), rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore(), RT_TIMER_FLAG_SOFT_TIMER , 以及 RT_TIMER_FLAG_THREAD_TIMER.
RTM_EXPORT | ( | rt_timer_start | ) |
rt_err_t rt_timer_stop | ( | rt_timer_t | timer | ) |
This function will stop the timer
timer | the timer to be stopped |
引用了 _timer_remove(), _timerlock_idx(), rt_object::flag, rt_timer::parent, RT_ASSERT, RT_NULL, RT_Object_Class_Timer, rt_object_get_type(), RT_OBJECT_HOOK_CALL, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore() , 以及 RT_TIMER_FLAG_ACTIVATED.
RTM_EXPORT | ( | rt_timer_stop | ) |
rt_err_t rt_timer_control | ( | rt_timer_t | timer, |
int | cmd, | ||
void * | arg ) |
This function will get or set some options of the timer
timer | the timer to be get or set |
cmd | the control command |
arg | the argument |
引用了 _timer_remove(), _timerlock_idx(), rt_object::flag, rt_timer::init_tick, rt_timer::parameter, rt_timer::parent, RT_ASSERT, RT_NULL, RT_Object_Class_Timer, rt_object_get_type(), rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore(), RT_TICK_MAX, RT_TIMER_CTRL_GET_FUNC, RT_TIMER_CTRL_GET_PARM, RT_TIMER_CTRL_GET_REMAIN_TIME, RT_TIMER_CTRL_GET_STATE, RT_TIMER_CTRL_GET_TIME, RT_TIMER_CTRL_SET_FUNC, RT_TIMER_CTRL_SET_ONESHOT, RT_TIMER_CTRL_SET_PARM, RT_TIMER_CTRL_SET_PERIODIC, RT_TIMER_CTRL_SET_TIME, RT_TIMER_FLAG_ACTIVATED, RT_TIMER_FLAG_DEACTIVATED, RT_TIMER_FLAG_PERIODIC, rt_timer::timeout_func , 以及 rt_timer::timeout_tick.
RTM_EXPORT | ( | rt_timer_control | ) |
void rt_timer_check | ( | void | ) |
This function will check timer list, if a timeout event happens, the corresponding timeout function will be invoked.
引用了 RT_ASSERT, rt_cpu_get_id, rt_interrupt_get_nest(), rt_sem_release() , 以及 rt_tick_get().
rt_tick_t rt_timer_next_timeout_tick | ( | void | ) |
This function will return the next timeout tick in the system.
引用了 rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore() , 以及 RT_TICK_MAX.
void rt_tick_sethook | ( | void(* | hook )(void) | ) |
void rt_system_timer_init | ( | void | ) |
This function will initialize system timer
引用了 rt_list_init() , 以及 rt_spin_lock_init().
void rt_system_timer_thread_init | ( | void | ) |
This function will initialize system timer thread
引用了 RT_IPC_CMD_SET_VLIMIT, RT_IPC_FLAG_PRIO, rt_list_init(), RT_NULL, rt_sem_control(), rt_sem_init(), rt_spin_lock_init(), rt_thread_init() , 以及 rt_thread_startup().
void rt_timer_enter_sethook | ( | void(* | hook )(struct rt_timer *timer) | ) |
void rt_timer_exit_sethook | ( | void(* | hook )(struct rt_timer *timer) | ) |