16
16
* 2012-12-15 Bernard fix the next timeout issue in soft timer
17
17
* 2014-07-12 Bernard does not lock scheduler when invoking soft-timer
18
18
* timeout function.
19
+ * 2021-08-15 supperthomas add the comment
19
20
*/
20
21
21
22
#include <rtthread.h>
@@ -59,21 +60,21 @@ static void (*rt_timer_exit_hook)(struct rt_timer *timer);
59
60
/**@{*/
60
61
61
62
/**
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.
64
65
*
65
- * @param hook the hook function
66
+ * @param hook the function point of timer
66
67
*/
67
68
void rt_timer_enter_sethook (void (* hook )(struct rt_timer * timer ))
68
69
{
69
70
rt_timer_enter_hook = hook ;
70
71
}
71
72
72
73
/**
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.
75
76
*
76
- * @param hook the hook function
77
+ * @param hook the function point of timer
77
78
*/
78
79
void rt_timer_exit_sethook (void (* hook )(struct rt_timer * timer ))
79
80
{
@@ -83,6 +84,20 @@ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer))
83
84
/**@}*/
84
85
#endif /* RT_USING_HOOK */
85
86
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
+ */
86
101
static void _rt_timer_init (rt_timer_t timer ,
87
102
void (* timeout )(void * parameter ),
88
103
void * parameter ,
@@ -110,7 +125,13 @@ static void _rt_timer_init(rt_timer_t timer,
110
125
}
111
126
}
112
127
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
+ */
114
135
static rt_tick_t rt_timer_list_next_timeout (rt_list_t timer_list [])
115
136
{
116
137
struct rt_timer * timer ;
@@ -133,6 +154,11 @@ static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[])
133
154
return timeout_tick ;
134
155
}
135
156
157
+ /**
158
+ * @brief remove the timer
159
+ *
160
+ * @param timer the point of timer
161
+ */
136
162
rt_inline void _rt_timer_remove (rt_timer_t timer )
137
163
{
138
164
int i ;
@@ -144,6 +170,12 @@ rt_inline void _rt_timer_remove(rt_timer_t timer)
144
170
}
145
171
146
172
#if RT_DEBUG_TIMER
173
+ /**
174
+ * @brief the number of timer
175
+ *
176
+ * @param timer
177
+ * @return int the count
178
+ */
147
179
static int rt_timer_count_height (struct rt_timer * timer )
148
180
{
149
181
int i , cnt = 0 ;
@@ -155,7 +187,11 @@ static int rt_timer_count_height(struct rt_timer *timer)
155
187
}
156
188
return cnt ;
157
189
}
158
-
190
+ /**
191
+ * @brief dump the all timer information
192
+ *
193
+ * @param timer_heads the head of timer
194
+ */
159
195
void rt_timer_dump (rt_list_t timer_heads [])
160
196
{
161
197
rt_list_t * list ;
@@ -180,9 +216,8 @@ void rt_timer_dump(rt_list_t timer_heads[])
180
216
/**@{*/
181
217
182
218
/**
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.
186
221
* @param timer the static timer object
187
222
* @param name the name of timer
188
223
* @param timeout the timeout function
@@ -208,11 +243,10 @@ void rt_timer_init(rt_timer_t timer,
208
243
RTM_EXPORT (rt_timer_init );
209
244
210
245
/**
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.
214
247
*
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
216
250
*/
217
251
rt_err_t rt_timer_detach (rt_timer_t timer )
218
252
{
@@ -241,7 +275,7 @@ RTM_EXPORT(rt_timer_detach);
241
275
242
276
#ifdef RT_USING_HEAP
243
277
/**
244
- * This function will create a timer
278
+ * @brief This function will create a timer
245
279
*
246
280
* @param name the name of timer
247
281
* @param timeout the timeout function
@@ -273,7 +307,7 @@ rt_timer_t rt_timer_create(const char *name,
273
307
RTM_EXPORT (rt_timer_create );
274
308
275
309
/**
276
- * This function will delete a timer and release timer memory
310
+ * @brief This function will delete a timer and release timer memory
277
311
*
278
312
* @param timer the timer to be deleted
279
313
*
@@ -306,7 +340,7 @@ RTM_EXPORT(rt_timer_delete);
306
340
#endif /* RT_USING_HEAP */
307
341
308
342
/**
309
- * This function will start the timer
343
+ * @brief This function will start the timer
310
344
*
311
345
* @param timer the timer to be started
312
346
*
@@ -429,7 +463,7 @@ rt_err_t rt_timer_start(rt_timer_t timer)
429
463
RTM_EXPORT (rt_timer_start );
430
464
431
465
/**
432
- * This function will stop the timer
466
+ * @brief This function will stop the timer
433
467
*
434
468
* @param timer the timer to be stopped
435
469
*
@@ -463,7 +497,7 @@ rt_err_t rt_timer_stop(rt_timer_t timer)
463
497
RTM_EXPORT (rt_timer_stop );
464
498
465
499
/**
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
467
501
*
468
502
* @param timer the timer to be get or set
469
503
* @param cmd the control command
@@ -521,8 +555,8 @@ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg)
521
555
RTM_EXPORT (rt_timer_control );
522
556
523
557
/**
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.
526
560
*
527
561
* @note this function shall be invoked in operating system timer interrupt.
528
562
*/
@@ -596,7 +630,7 @@ void rt_timer_check(void)
596
630
}
597
631
598
632
/**
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.
600
634
*
601
635
* @return the next timeout tick in the system
602
636
*/
@@ -607,7 +641,7 @@ rt_tick_t rt_timer_next_timeout_tick(void)
607
641
608
642
#ifdef RT_USING_TIMER_SOFT
609
643
/**
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
611
645
* corresponding timeout function will be invoked.
612
646
*/
613
647
void rt_soft_timer_check (void )
@@ -684,7 +718,11 @@ void rt_soft_timer_check(void)
684
718
RT_DEBUG_LOG (RT_DEBUG_TIMER , ("software timer check leave\n" ));
685
719
}
686
720
687
- /* system timer thread entry */
721
+ /**
722
+ * @brief system timer thread entry
723
+ *
724
+ * @param parameter
725
+ */
688
726
static void rt_thread_timer_entry (void * parameter )
689
727
{
690
728
rt_tick_t next_timeout ;
@@ -723,7 +761,7 @@ static void rt_thread_timer_entry(void *parameter)
723
761
/**
724
762
* @ingroup SystemInit
725
763
*
726
- * This function will initialize system timer
764
+ * @brief This function will initialize system timer
727
765
*/
728
766
void rt_system_timer_init (void )
729
767
{
@@ -738,7 +776,7 @@ void rt_system_timer_init(void)
738
776
/**
739
777
* @ingroup SystemInit
740
778
*
741
- * This function will initialize system timer thread
779
+ * @brief This function will initialize system timer thread
742
780
*/
743
781
void rt_system_timer_thread_init (void )
744
782
{
0 commit comments