OS Timer
API 介绍
This section introduces the TIMER module's enum, structure, functions and how to use this driver.
Typedefs
-
typedef uint32_t timer_id_t
timer id
-
typedef void (*os_timer_func_t)(timer_id_t timer_id, void *arg)
This function is used to define timer callback function pointer type.
- Param timer_id:
is timer_id of the timer related with this callback method.
- Param arg:
is arg for the callback passed in os_timer_create.
Functions
-
timer_id_t os_create_timer(module_id_t module_id, bool auto_reload, os_timer_func_t cb, void *arg)
This function is used to create a timer.
- 参数:
module_id -- is the id of module that the timer belongs to.
auto_reload -- is parameter passed to the function call.
cb -- is callback method of the timer.
arg -- is argument for the callback method.
- 返回:
0(failure), otherwise(timer id)
-
bool os_start_timer(timer_id_t id, uint32_t period)
Start a timer. This method should not be called in ISR.
- 参数:
id -- is the id of the timer to be started.
period -- is time period of the timer in milliseconds.
- 返回:
true for success, false for fail
-
bool os_start_timer_from_isr(timer_id_t id, uint32_t period)
Start a timer from ISR.
- 参数:
id -- is the id of the timer to be started.
period -- is time period of the timer in milliseconds.
- 返回:
true for success, false for fail
-
bool os_stop_timer(timer_id_t id)
This function is used to stop a timer. This method should not be called in ISR.
- 参数:
id -- is the id of the timer to be stopped.
- 返回:
true for success, false for fail
-
bool os_stop_timer_from_isr(timer_id_t id)
This function is used to stop a timer from ISR. This method can be called in ISR.
- 参数:
id -- is the id of the timer to be stopped.
- 返回:
true for success, false for fail
-
bool os_reset_timer(timer_id_t id)
This function is used to reset a timer. This method should not be called in ISR.
- 参数:
id -- is the id of the timer to be checked.
- 返回:
true for success, false for fail
-
bool os_reset_timer_from_isr(timer_id_t id)
This function is used to reset a timer from ISR.
- 参数:
id -- is the id of the timer to be checked.
- 返回:
true for success, false for fail
-
bool os_delete_timer(timer_id_t id)
This function is used to delete a timer.
- 参数:
id -- is the id of the timer to be deleted.
- 返回:
true for success, false for fail
-
bool os_is_timer_active(timer_id_t id)
This function is used to check if timer is active. Active means if started AND callback will be called later.
- 参数:
id -- is the id of the timer to be reset.
- 返回:
true(active), false(not active).