定时器

宏定义

#define AOS_TIMER_NONE   0x0u
 
#define AOS_TIMER_AUTORUN   0x01u
 
#define AOS_TIMER_REPEAT   0x02u
 

类型定义

typedef aos_hdl_t aos_timer_t
 

函数

aos_status_t aos_timer_create (aos_timer_t *timer, void(*fn)(void *, void *), void *arg, uint32_t ms, uint32_t options)
 
void aos_timer_free (aos_timer_t *timer)
 
aos_status_t aos_timer_start (aos_timer_t *timer)
 
aos_status_t aos_timer_stop (aos_timer_t *timer)
 
aos_status_t aos_timer_change (aos_timer_t *timer, uint32_t ms)
 
aos_status_t aos_timer_change_once (aos_timer_t *timer, uint32_t ms)
 
bool aos_timer_is_valid (aos_timer_t *timer)
 
aos_status_t aos_timer_new (aos_timer_t *timer, void(*fn)(void *, void *), void *arg, uint32_t ms, bool repeat)
 
aos_status_t aos_timer_new_ext (aos_timer_t *timer, void(*fn)(void *, void *), void *arg, uint32_t ms, bool repeat, bool autorun)
 

详细描述

提供AliOS Things系统内核定时器功能的基础API.

宏定义说明

◆ AOS_TIMER_AUTORUN

#define AOS_TIMER_AUTORUN   0x01u

表示定时器创建后即启动,当调用aos_timer_create()创建定时器时,用来指定option参数

在文件 kernel.h76 行定义.

◆ AOS_TIMER_NONE

#define AOS_TIMER_NONE   0x0u

表示不指定任意选项,当调用aos_timer_create()创建定时器时,用来指定option参数

在文件 kernel.h75 行定义.

◆ AOS_TIMER_REPEAT

#define AOS_TIMER_REPEAT   0x02u

表示定时器是周期性的,当调用aos_timer_create()创建定时器时,用来指定option参数

在文件 kernel.h77 行定义.

类型定义说明

◆ aos_timer_t

AOS定时器对象句柄类型

在文件 kernel.h148 行定义.

函数说明

◆ aos_timer_change()

aos_status_t aos_timer_change ( aos_timer_t timer,
uint32_t  ms 
)

This function will change attributes of a timer.

参数
[in]timerpointer to the timer.
[in]msms of the timer triger.
注解
change the timer attributes should follow the sequence as timer_stop->timer_change->timer_start
返回
0: success.

◆ aos_timer_change_once()

aos_status_t aos_timer_change_once ( aos_timer_t timer,
uint32_t  ms 
)

This function will change attributes of a timer once.

参数
[in]timerpointer to the timer.
[in]msms of the timer triger.
注解
change the timer attributes should follow the sequence as timer_stop->timer_change->timer_start
返回
0: success.

◆ aos_timer_create()

aos_status_t aos_timer_create ( aos_timer_t timer,
void(*)(void *, void *)  fn,
void *  arg,
uint32_t  ms,
uint32_t  options 
)

This function will create a timer.

参数
[in]timerpointer to the timer.
[in]fncallbak of the timer.
[in]argthe argument of the callback.
[in]msms of the normal timer triger.
[in]optionsoption settings, can be set to AOS_TIMER_AUTORUN|AOS_TIMER_REPEAT
注解
fn first arg: timer->hdl, not aos_timer_t *timer; second arg: user param arg.
返回
0: success.

◆ aos_timer_free()

void aos_timer_free ( aos_timer_t timer)

This function will delete a timer.

参数
[in]timerpointer to a timer.

◆ aos_timer_is_valid()

bool aos_timer_is_valid ( aos_timer_t timer)

This function will check if timer is valid. Deprecated, not Recommended.

参数
[in]timerpointer to the timer.
返回
false: invalid, true: valid.

◆ aos_timer_new()

aos_status_t aos_timer_new ( aos_timer_t timer,
void(*)(void *, void *)  fn,
void *  arg,
uint32_t  ms,
bool  repeat 
)

This function will create a timer and run auto. Deprecated, not Recommended.

参数
[in]timerpointer to the timer.
[in]fncallbak of the timer.
[in]argthe argument of the callback.
[in]msms of the normal timer triger.
[in]repeatrepeat or not when the timer is created.
注解
fn first arg: timer->hdl, not aos_timer_t *timer; second arg: user param arg.
返回
0: success.

◆ aos_timer_new_ext()

aos_status_t aos_timer_new_ext ( aos_timer_t timer,
void(*)(void *, void *)  fn,
void *  arg,
uint32_t  ms,
bool  repeat,
bool  autorun 
)

This function will create a timer. Deprecated, not Recommended.

参数
[in]timerpointer to the timer.
[in]fncallbak of the timer.
[in]argthe argument of the callback.
[in]msms of the normal timer triger.
[in]repeatrepeat or not when the timer is created.
[in]autorunauto run.
注解
fn first arg: timer->hdl, not aos_timer_t *timer; second arg: user param arg.
返回
0: success.

◆ aos_timer_start()

aos_status_t aos_timer_start ( aos_timer_t timer)

This function will start a timer.

参数
[in]timerpointer to the timer.
返回
0: success.

◆ aos_timer_stop()

aos_status_t aos_timer_stop ( aos_timer_t timer)

This function will stop a timer.

参数
[in]timerpointer to the timer.
返回
0: success.