Skip to content

Commit 70376d2

Browse files
authored
Merge pull request #4947 from supperthomas/supperthomas_comment
[kernel] add the comment of irq.c and timer.c
2 parents 46f6d35 + 19bcf9a commit 70376d2

File tree

2 files changed

+82
-33
lines changed

2 files changed

+82
-33
lines changed

src/irq.c

+17-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* 2006-05-03 Bernard add IRQ_DEBUG
1010
* 2016-08-09 ArdaFu add interrupt enter and leave hook.
1111
* 2018-11-22 Jesven rt_interrupt_get_nest function add disable irq
12+
* 2021-08-15 Supperthomas fix the comment
1213
*/
1314

1415
#include <rthw.h>
@@ -21,19 +22,26 @@ static void (*rt_interrupt_leave_hook)(void);
2122

2223
/**
2324
* @ingroup Hook
24-
* This function set a hook function when the system enter a interrupt
25+
*
26+
* @brief This function set a hook function when the system enter a interrupt
2527
*
2628
* @note the hook function must be simple and never be blocked or suspend.
29+
*
30+
* @param hook The function point to be called
2731
*/
2832
void rt_interrupt_enter_sethook(void (*hook)(void))
2933
{
3034
rt_interrupt_enter_hook = hook;
3135
}
36+
3237
/**
3338
* @ingroup Hook
34-
* This function set a hook function when the system exit a interrupt.
39+
*
40+
* @brief This function set a hook function when the system exit a interrupt.
3541
*
3642
* @note the hook function must be simple and never be blocked or suspend.
43+
*
44+
* @param hook The function point to be called
3745
*/
3846
void rt_interrupt_leave_sethook(void (*hook)(void))
3947
{
@@ -53,8 +61,9 @@ void rt_interrupt_leave_sethook(void (*hook)(void))
5361
volatile rt_uint8_t rt_interrupt_nest = 0;
5462
#endif /* RT_USING_SMP */
5563

64+
5665
/**
57-
* This function will be invoked by BSP, when enter interrupt service routine
66+
* @brief This function will be invoked by BSP, when enter interrupt service routine
5867
*
5968
* @note please don't invoke this routine in application
6069
*
@@ -74,8 +83,9 @@ void rt_interrupt_enter(void)
7483
}
7584
RTM_EXPORT(rt_interrupt_enter);
7685

86+
7787
/**
78-
* This function will be invoked by BSP, when leave interrupt service routine
88+
* @brief This function will be invoked by BSP, when leave interrupt service routine
7989
*
8090
* @note please don't invoke this routine in application
8191
*
@@ -95,13 +105,14 @@ void rt_interrupt_leave(void)
95105
}
96106
RTM_EXPORT(rt_interrupt_leave);
97107

108+
98109
/**
99-
* This function will return the nest of interrupt.
110+
* @brief This function will return the nest of interrupt.
100111
*
101112
* User application can invoke this function to get whether current
102113
* context is interrupt context.
103114
*
104-
* @return the number of nested interrupts.
115+
* @return rt_uint8_t the number of nested interrupts.
105116
*/
106117
RT_WEAK rt_uint8_t rt_interrupt_get_nest(void)
107118
{

src/timer.c

+65-27
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
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
*/
6768
void 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
*/
7879
void 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+
*/
86101
static 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+
*/
114135
static 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+
*/
136162
rt_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+
*/
147179
static 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+
*/
159195
void 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,
208243
RTM_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
*/
217251
rt_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,
273307
RTM_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)
429463
RTM_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)
463497
RTM_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)
521555
RTM_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
*/
613647
void 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+
*/
688726
static 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
*/
728766
void 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
*/
743781
void rt_system_timer_thread_init(void)
744782
{

0 commit comments

Comments
 (0)