1616 * 2012-12-15 Bernard fix the next timeout issue in soft timer
1717 * 2014-07-12 Bernard does not lock scheduler when invoking soft-timer
1818 * timeout function.
19+ * 2021-08-15 supperthomas add the comment
1920 */
2021
2122#include <rtthread.h>
@@ -59,21 +60,21 @@ static void (*rt_timer_exit_hook)(struct rt_timer *timer);
5960/**@{*/
6061
6162/**
62- * This function will set a hook function, which will be invoked when enter
63- * timer timeout callback function.
63+ * @brief This function will set a hook function on timer,
64+ * which will be invoked when enter timer timeout callback function.
6465 *
65- * @param hook the hook function
66+ * @param hook the function point of timer
6667 */
6768void rt_timer_enter_sethook (void (* hook )(struct rt_timer * timer ))
6869{
6970 rt_timer_enter_hook = hook ;
7071}
7172
7273/**
73- * This function will set a hook function, which will be invoked when exit
74- * timer timeout callback function.
74+ * @brief This function will set a hook function, which will be
75+ * invoked when exit * timer timeout callback function.
7576 *
76- * @param hook the hook function
77+ * @param hook the function point of timer
7778 */
7879void rt_timer_exit_sethook (void (* hook )(struct rt_timer * timer ))
7980{
@@ -83,6 +84,20 @@ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer))
8384/**@}*/
8485#endif /* RT_USING_HOOK */
8586
87+
88+ /**
89+ * @brief [internal] the init funtion of timer
90+ *
91+ * the internal called function of rt_timer_init
92+ *
93+ * @see rt_timer_init
94+ *
95+ * @param timer the static timer object
96+ * @param timeout the timeout function
97+ * @param parameter the parameter of timeout function
98+ * @param time the tick of timer
99+ * @param flag the flag of timer
100+ */
86101static void _rt_timer_init (rt_timer_t timer ,
87102 void (* timeout )(void * parameter ),
88103 void * parameter ,
@@ -110,7 +125,13 @@ static void _rt_timer_init(rt_timer_t timer,
110125 }
111126}
112127
113- /* the fist timer always in the last row */
128+ /**
129+ * @brief find the next emtpy timer
130+ *
131+ * @param timer_list the timer of the next timeout
132+ *
133+ * @return rt_tick_t the point of timer
134+ */
114135static rt_tick_t rt_timer_list_next_timeout (rt_list_t timer_list [])
115136{
116137 struct rt_timer * timer ;
@@ -133,6 +154,11 @@ static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[])
133154 return timeout_tick ;
134155}
135156
157+ /**
158+ * @brief remove the timer
159+ *
160+ * @param timer the point of timer
161+ */
136162rt_inline void _rt_timer_remove (rt_timer_t timer )
137163{
138164 int i ;
@@ -144,6 +170,12 @@ rt_inline void _rt_timer_remove(rt_timer_t timer)
144170}
145171
146172#if RT_DEBUG_TIMER
173+ /**
174+ * @brief the number of timer
175+ *
176+ * @param timer
177+ * @return int the count
178+ */
147179static int rt_timer_count_height (struct rt_timer * timer )
148180{
149181 int i , cnt = 0 ;
@@ -155,7 +187,11 @@ static int rt_timer_count_height(struct rt_timer *timer)
155187 }
156188 return cnt ;
157189}
158-
190+ /**
191+ * @brief dump the all timer information
192+ *
193+ * @param timer_heads the head of timer
194+ */
159195void rt_timer_dump (rt_list_t timer_heads [])
160196{
161197 rt_list_t * list ;
@@ -180,9 +216,8 @@ void rt_timer_dump(rt_list_t timer_heads[])
180216/**@{*/
181217
182218/**
183- * This function will initialize a timer, normally this function is used to
184- * initialize a static timer object.
185- *
219+ * @brief This function will initialize a timer
220+ * normally this function is used to initialize a static timer object.
186221 * @param timer the static timer object
187222 * @param name the name of timer
188223 * @param timeout the timeout function
@@ -208,11 +243,10 @@ void rt_timer_init(rt_timer_t timer,
208243RTM_EXPORT (rt_timer_init );
209244
210245/**
211- * This function will detach a timer from timer management.
212- *
213- * @param timer the static timer object
246+ * @brief This function will detach a timer from timer management.
214247 *
215- * @return the operation status, RT_EOK on OK; RT_ERROR on error
248+ * @param timer the timer to be detached
249+ * @return rt_err_t RT_EOK
216250 */
217251rt_err_t rt_timer_detach (rt_timer_t timer )
218252{
@@ -241,7 +275,7 @@ RTM_EXPORT(rt_timer_detach);
241275
242276#ifdef RT_USING_HEAP
243277/**
244- * This function will create a timer
278+ * @brief This function will create a timer
245279 *
246280 * @param name the name of timer
247281 * @param timeout the timeout function
@@ -273,7 +307,7 @@ rt_timer_t rt_timer_create(const char *name,
273307RTM_EXPORT (rt_timer_create );
274308
275309/**
276- * This function will delete a timer and release timer memory
310+ * @brief This function will delete a timer and release timer memory
277311 *
278312 * @param timer the timer to be deleted
279313 *
@@ -306,7 +340,7 @@ RTM_EXPORT(rt_timer_delete);
306340#endif /* RT_USING_HEAP */
307341
308342/**
309- * This function will start the timer
343+ * @brief This function will start the timer
310344 *
311345 * @param timer the timer to be started
312346 *
@@ -429,7 +463,7 @@ rt_err_t rt_timer_start(rt_timer_t timer)
429463RTM_EXPORT (rt_timer_start );
430464
431465/**
432- * This function will stop the timer
466+ * @brief This function will stop the timer
433467 *
434468 * @param timer the timer to be stopped
435469 *
@@ -463,7 +497,7 @@ rt_err_t rt_timer_stop(rt_timer_t timer)
463497RTM_EXPORT (rt_timer_stop );
464498
465499/**
466- * This function will get or set some options of the timer
500+ * @brief This function will get or set some options of the timer
467501 *
468502 * @param timer the timer to be get or set
469503 * @param cmd the control command
@@ -521,8 +555,8 @@ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg)
521555RTM_EXPORT (rt_timer_control );
522556
523557/**
524- * This function will check timer list, if a timeout event happens, the
525- * corresponding timeout function will be invoked.
558+ * @brief This function will check timer list, if a timeout event happens,
559+ * the corresponding timeout function will be invoked.
526560 *
527561 * @note this function shall be invoked in operating system timer interrupt.
528562 */
@@ -596,7 +630,7 @@ void rt_timer_check(void)
596630}
597631
598632/**
599- * This function will return the next timeout tick in the system.
633+ * @brief This function will return the next timeout tick in the system.
600634 *
601635 * @return the next timeout tick in the system
602636 */
@@ -607,7 +641,7 @@ rt_tick_t rt_timer_next_timeout_tick(void)
607641
608642#ifdef RT_USING_TIMER_SOFT
609643/**
610- * This function will check software-timer list, if a timeout event happens, the
644+ * @brief This function will check software-timer list, if a timeout event happens, the
611645 * corresponding timeout function will be invoked.
612646 */
613647void rt_soft_timer_check (void )
@@ -684,7 +718,11 @@ void rt_soft_timer_check(void)
684718 RT_DEBUG_LOG (RT_DEBUG_TIMER , ("software timer check leave\n" ));
685719}
686720
687- /* system timer thread entry */
721+ /**
722+ * @brief system timer thread entry
723+ *
724+ * @param parameter
725+ */
688726static void rt_thread_timer_entry (void * parameter )
689727{
690728 rt_tick_t next_timeout ;
@@ -723,7 +761,7 @@ static void rt_thread_timer_entry(void *parameter)
723761/**
724762 * @ingroup SystemInit
725763 *
726- * This function will initialize system timer
764+ * @brief This function will initialize system timer
727765 */
728766void rt_system_timer_init (void )
729767{
@@ -738,7 +776,7 @@ void rt_system_timer_init(void)
738776/**
739777 * @ingroup SystemInit
740778 *
741- * This function will initialize system timer thread
779+ * @brief This function will initialize system timer thread
742780 */
743781void rt_system_timer_thread_init (void )
744782{
0 commit comments