|
|
|
|
@ -18,7 +18,7 @@ Your can configurate for your tick time such as 5ms/10ms and so on.
|
|
|
|
|
typedef struct Timer {
|
|
|
|
|
uint32_t cur_ticks; /* Record current timer start tick */
|
|
|
|
|
uint32_t cur_expired_time; /* Record current timer expired time */
|
|
|
|
|
uint32_t timeout; /* Delay (xx ms) time to start tiemr */
|
|
|
|
|
uint32_t timeout; /* Delay (xx ms) time to start timer */
|
|
|
|
|
uint32_t repeat; /* Timer interval expired time (xx ms) */
|
|
|
|
|
void * arg; /* Input argument for timeout_cb function */
|
|
|
|
|
void (*timeout_cb)(void *arg); /* Timer expired callback function */
|
|
|
|
|
@ -31,7 +31,7 @@ extern "C" {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Initializes the timer struct handle.
|
|
|
|
|
* @param handle: the timer handle strcut.
|
|
|
|
|
* @param handle: the timer handle struct.
|
|
|
|
|
* @param timeout_cb: timeout callback.
|
|
|
|
|
* @param timeout: delay to start the timer.
|
|
|
|
|
* @param repeat: repeat interval time.
|
|
|
|
|
@ -43,14 +43,14 @@ void timer_init(struct Timer* handle, void(*timeout_cb)(void *arg), \
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Start the timer work, add the handle into work list.
|
|
|
|
|
* @param btn: target handle strcut.
|
|
|
|
|
* @param handle: target handle struct.
|
|
|
|
|
* @retval 0: succeed. -1: already exist.
|
|
|
|
|
*/
|
|
|
|
|
int timer_start(struct Timer* handle);
|
|
|
|
|
int timer_start(struct Timer* handle);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Stop the timer work, remove the handle off work list.
|
|
|
|
|
* @param handle: target handle strcut.
|
|
|
|
|
* @param handle: target handle struct.
|
|
|
|
|
* @retval 0: succeed. -1: timer not exist.
|
|
|
|
|
*/
|
|
|
|
|
int timer_stop(struct Timer* handle);
|
|
|
|
|
@ -58,7 +58,7 @@ int timer_stop(struct Timer* handle);
|
|
|
|
|
/**
|
|
|
|
|
* @brief background ticks, timer repeat invoking interval nms.
|
|
|
|
|
* @param None.
|
|
|
|
|
* @retval None.
|
|
|
|
|
* @retval None
|
|
|
|
|
*/
|
|
|
|
|
void timer_ticks(void);
|
|
|
|
|
|
|
|
|
|
|