|
@@ -246,9 +246,12 @@ void rt_timer_dump(rt_list_t timer_heads[])
|
|
|
*
|
|
|
* @param parameter is the param of the callback
|
|
|
*
|
|
|
- * @param time is the ticks of timer
|
|
|
+ * @param time is timeout ticks of timer
|
|
|
+ *
|
|
|
+ * NOTE: The max timeout tick should be no more than (RT_TICK_MAX/2 - 1).
|
|
|
*
|
|
|
* @param flag is the flag of timer
|
|
|
+ *
|
|
|
*/
|
|
|
void rt_timer_init(rt_timer_t timer,
|
|
|
const char *name,
|
|
@@ -259,6 +262,8 @@ void rt_timer_init(rt_timer_t timer,
|
|
|
{
|
|
|
/* parameter check */
|
|
|
RT_ASSERT(timer != RT_NULL);
|
|
|
+ RT_ASSERT(timeout != RT_NULL);
|
|
|
+ RT_ASSERT(timer->init_tick < RT_TICK_MAX / 2);
|
|
|
|
|
|
/* timer object initialization */
|
|
|
rt_object_init(&(timer->parent), RT_Object_Class_Timer, name);
|
|
@@ -303,15 +308,17 @@ RTM_EXPORT(rt_timer_detach);
|
|
|
/**
|
|
|
* @brief This function will create a timer
|
|
|
*
|
|
|
- * @param name the name of timer
|
|
|
+ * @param name is the name of timer
|
|
|
*
|
|
|
- * @param timeout the timeout function
|
|
|
+ * @param timeout is the timeout function
|
|
|
*
|
|
|
- * @param parameter the parameter of timeout function
|
|
|
+ * @param parameter is the parameter of timeout function
|
|
|
*
|
|
|
- * @param time the tick of timer
|
|
|
+ * @param time is timeout ticks of the timer
|
|
|
*
|
|
|
- * @param flag the flag of timer
|
|
|
+ * NOTE: The max timeout tick should be no more than (RT_TICK_MAX/2 - 1).
|
|
|
+ *
|
|
|
+ * @param flag is the flag of timer
|
|
|
*
|
|
|
* @return the created timer object
|
|
|
*/
|
|
@@ -323,6 +330,10 @@ rt_timer_t rt_timer_create(const char *name,
|
|
|
{
|
|
|
struct rt_timer *timer;
|
|
|
|
|
|
+ /* parameter check */
|
|
|
+ RT_ASSERT(timeout != RT_NULL);
|
|
|
+ RT_ASSERT(timer->init_tick < RT_TICK_MAX / 2);
|
|
|
+
|
|
|
/* allocate a object */
|
|
|
timer = (struct rt_timer *)rt_object_allocate(RT_Object_Class_Timer, name);
|
|
|
if (timer == RT_NULL)
|
|
@@ -401,11 +412,6 @@ rt_err_t rt_timer_start(rt_timer_t timer)
|
|
|
|
|
|
RT_OBJECT_HOOK_CALL(rt_object_take_hook, (&(timer->parent)));
|
|
|
|
|
|
- /*
|
|
|
- * get timeout tick,
|
|
|
- * the max timeout tick shall not great than RT_TICK_MAX/2
|
|
|
- */
|
|
|
- RT_ASSERT(timer->init_tick < RT_TICK_MAX / 2);
|
|
|
timer->timeout_tick = rt_tick_get() + timer->init_tick;
|
|
|
|
|
|
#ifdef RT_USING_TIMER_SOFT
|