|
|
|
@ -15,7 +15,7 @@ static uint32_t _timer_ticks = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @brief Initializes the timer struct handle.
|
|
|
|
* @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_cb: timeout callback.
|
|
|
|
* @param timeout: delay to start the timer.
|
|
|
|
* @param timeout: delay to start the timer.
|
|
|
|
* @param repeat: repeat interval time.
|
|
|
|
* @param repeat: repeat interval time.
|
|
|
|
@ -25,7 +25,7 @@ static uint32_t _timer_ticks = 0;
|
|
|
|
void timer_init(struct Timer* handle, void (*timeout_cb)(void *arg), \
|
|
|
|
void timer_init(struct Timer* handle, void (*timeout_cb)(void *arg), \
|
|
|
|
uint32_t timeout, uint32_t repeat, void *arg)
|
|
|
|
uint32_t timeout, uint32_t repeat, void *arg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// memset(handle, sizeof(struct Timer), 0);
|
|
|
|
// memset(handle, 0, sizeof(struct Timer));
|
|
|
|
handle->timeout_cb = timeout_cb;
|
|
|
|
handle->timeout_cb = timeout_cb;
|
|
|
|
handle->timeout = timeout;
|
|
|
|
handle->timeout = timeout;
|
|
|
|
handle->repeat = repeat;
|
|
|
|
handle->repeat = repeat;
|
|
|
|
@ -38,7 +38,7 @@ void timer_init(struct Timer* handle, void (*timeout_cb)(void *arg), \
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @brief Start the timer work, add the handle into work list.
|
|
|
|
* @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.
|
|
|
|
* @retval 0: succeed. -1: already exist.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
int timer_start(struct Timer* handle)
|
|
|
|
int timer_start(struct Timer* handle)
|
|
|
|
@ -59,7 +59,7 @@ int timer_start(struct Timer* handle)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @brief Stop the timer work, remove the handle off work list.
|
|
|
|
* @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.
|
|
|
|
* @retval 0: succeed. -1: timer not exist.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
int timer_stop(struct Timer* handle)
|
|
|
|
int timer_stop(struct Timer* handle)
|
|
|
|
@ -77,7 +77,7 @@ int timer_stop(struct Timer* handle)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -110,7 +110,7 @@ void timer_loop(void)
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @brief background ticks, timer repeat invoking interval nms.
|
|
|
|
* @brief background ticks, timer repeat invoking interval nms.
|
|
|
|
* @param None.
|
|
|
|
* @param None.
|
|
|
|
* @retval None.
|
|
|
|
* @retval None
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void timer_ticks(void)
|
|
|
|
void timer_ticks(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|