From 33a6700f160ce8c451b08287d12c94c9691556fc Mon Sep 17 00:00:00 2001 From: supperthomas <78900636@qq.com> Date: Sun, 15 Aug 2021 23:04:22 +0800 Subject: [PATCH 1/3] add the comment of irq.c --- src/irq.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/irq.c b/src/irq.c index 6ddcb3dd4ae..ac43c45573c 100644 --- a/src/irq.c +++ b/src/irq.c @@ -9,6 +9,7 @@ * 2006-05-03 Bernard add IRQ_DEBUG * 2016-08-09 ArdaFu add interrupt enter and leave hook. * 2018-11-22 Jesven rt_interrupt_get_nest function add disable irq + * 2021-08-15 Supperthomas fix the comment */ #include @@ -21,19 +22,26 @@ static void (*rt_interrupt_leave_hook)(void); /** * @ingroup Hook - * This function set a hook function when the system enter a interrupt - * + * + * @brief This function set a hook function when the system enter a interrupt + * * @note the hook function must be simple and never be blocked or suspend. + * + * @param hook The function point to be called */ void rt_interrupt_enter_sethook(void (*hook)(void)) { rt_interrupt_enter_hook = hook; } + /** * @ingroup Hook - * This function set a hook function when the system exit a interrupt. - * + * + * @brief This function set a hook function when the system exit a interrupt. + * * @note the hook function must be simple and never be blocked or suspend. + * + * @param hook The function point to be called */ void rt_interrupt_leave_sethook(void (*hook)(void)) { @@ -53,11 +61,12 @@ void rt_interrupt_leave_sethook(void (*hook)(void)) volatile rt_uint8_t rt_interrupt_nest = 0; #endif /* RT_USING_SMP */ + /** - * This function will be invoked by BSP, when enter interrupt service routine - * + * @brief This function will be invoked by BSP, when enter interrupt service routine + * * @note please don't invoke this routine in application - * + * * @see rt_interrupt_leave */ void rt_interrupt_enter(void) @@ -74,11 +83,12 @@ void rt_interrupt_enter(void) } RTM_EXPORT(rt_interrupt_enter); + /** - * This function will be invoked by BSP, when leave interrupt service routine - * + * @brief This function will be invoked by BSP, when leave interrupt service routine + * * @note please don't invoke this routine in application - * + * * @see rt_interrupt_enter */ void rt_interrupt_leave(void) @@ -95,13 +105,14 @@ void rt_interrupt_leave(void) } RTM_EXPORT(rt_interrupt_leave); + /** - * This function will return the nest of interrupt. - * + * @brief This function will return the nest of interrupt. + * * User application can invoke this function to get whether current * context is interrupt context. - * - * @return the number of nested interrupts. + * + * @return rt_uint8_t the number of nested interrupts. */ RT_WEAK rt_uint8_t rt_interrupt_get_nest(void) { From 30fd28a89a1a73428f9cd8086add95c4066d2857 Mon Sep 17 00:00:00 2001 From: supperthomas <78900636@qq.com> Date: Sun, 15 Aug 2021 23:04:35 +0800 Subject: [PATCH 2/3] add the comment of timer.c --- src/timer.c | 98 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 68 insertions(+), 30 deletions(-) diff --git a/src/timer.c b/src/timer.c index 1c8e70fccc6..18b7ac4d587 100644 --- a/src/timer.c +++ b/src/timer.c @@ -16,6 +16,7 @@ * 2012-12-15 Bernard fix the next timeout issue in soft timer * 2014-07-12 Bernard does not lock scheduler when invoking soft-timer * timeout function. + * 2021-08-15 supperthomas add the comment */ #include @@ -59,10 +60,10 @@ static void (*rt_timer_exit_hook)(struct rt_timer *timer); /**@{*/ /** - * This function will set a hook function, which will be invoked when enter - * timer timeout callback function. - * - * @param hook the hook function + * @brief This function will set a hook function on timer, + * which will be invoked when enter timer timeout callback function. + * + * @param hook the function point of timer */ void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer)) { @@ -70,10 +71,10 @@ void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer)) } /** - * This function will set a hook function, which will be invoked when exit - * timer timeout callback function. - * - * @param hook the hook function + * @brief This function will set a hook function, which will be + * invoked when exit * timer timeout callback function. + * + * @param hook the function point of timer */ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer)) { @@ -83,6 +84,20 @@ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer)) /**@}*/ #endif /* RT_USING_HOOK */ + +/** + * @brief [internal] the init funtion of timer + * + * the internal called function of rt_timer_init + * + * @see rt_timer_init + * + * @param timer the static timer object + * @param timeout the timeout function + * @param parameter the parameter of timeout function + * @param time the tick of timer + * @param flag the flag of timer + */ static void _rt_timer_init(rt_timer_t timer, void (*timeout)(void *parameter), void *parameter, @@ -110,7 +125,13 @@ static void _rt_timer_init(rt_timer_t timer, } } -/* the fist timer always in the last row */ +/** + * @brief find the next emtpy timer + * + * @param timer_list the timer of the next timeout + * + * @return rt_tick_t the point of timer + */ static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[]) { struct rt_timer *timer; @@ -133,6 +154,11 @@ static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[]) return timeout_tick; } +/** + * @brief remove the timer + * + * @param timer the point of timer + */ rt_inline void _rt_timer_remove(rt_timer_t timer) { int i; @@ -144,6 +170,12 @@ rt_inline void _rt_timer_remove(rt_timer_t timer) } #if RT_DEBUG_TIMER +/** + * @brief the number of timer + * + * @param timer + * @return int the count + */ static int rt_timer_count_height(struct rt_timer *timer) { int i, cnt = 0; @@ -155,7 +187,11 @@ static int rt_timer_count_height(struct rt_timer *timer) } return cnt; } - +/** + * @brief dump the all timer information + * + * @param timer_heads the head of timer + */ void rt_timer_dump(rt_list_t timer_heads[]) { rt_list_t *list; @@ -180,9 +216,8 @@ void rt_timer_dump(rt_list_t timer_heads[]) /**@{*/ /** - * This function will initialize a timer, normally this function is used to - * initialize a static timer object. - * + * @brief This function will initialize a timer + * normally this function is used to initialize a static timer object. * @param timer the static timer object * @param name the name of timer * @param timeout the timeout function @@ -208,11 +243,10 @@ void rt_timer_init(rt_timer_t timer, RTM_EXPORT(rt_timer_init); /** - * This function will detach a timer from timer management. - * - * @param timer the static timer object - * - * @return the operation status, RT_EOK on OK; RT_ERROR on error + * @brief This function will detach a timer from timer management. + * + * @param timer the timer to be detached + * @return rt_err_t RT_EOK */ rt_err_t rt_timer_detach(rt_timer_t timer) { @@ -241,7 +275,7 @@ RTM_EXPORT(rt_timer_detach); #ifdef RT_USING_HEAP /** - * This function will create a timer + * @brief This function will create a timer * * @param name the name of timer * @param timeout the timeout function @@ -273,7 +307,7 @@ rt_timer_t rt_timer_create(const char *name, RTM_EXPORT(rt_timer_create); /** - * This function will delete a timer and release timer memory + * @brief This function will delete a timer and release timer memory * * @param timer the timer to be deleted * @@ -306,7 +340,7 @@ RTM_EXPORT(rt_timer_delete); #endif /* RT_USING_HEAP */ /** - * This function will start the timer + * @brief This function will start the timer * * @param timer the timer to be started * @@ -429,7 +463,7 @@ rt_err_t rt_timer_start(rt_timer_t timer) RTM_EXPORT(rt_timer_start); /** - * This function will stop the timer + * @brief This function will stop the timer * * @param timer the timer to be stopped * @@ -463,7 +497,7 @@ rt_err_t rt_timer_stop(rt_timer_t timer) RTM_EXPORT(rt_timer_stop); /** - * This function will get or set some options of the timer + * @brief This function will get or set some options of the timer * * @param timer the timer to be get or set * @param cmd the control command @@ -521,8 +555,8 @@ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg) RTM_EXPORT(rt_timer_control); /** - * This function will check timer list, if a timeout event happens, the - * corresponding timeout function will be invoked. + * @brief This function will check timer list, if a timeout event happens, + * the corresponding timeout function will be invoked. * * @note this function shall be invoked in operating system timer interrupt. */ @@ -596,7 +630,7 @@ void rt_timer_check(void) } /** - * This function will return the next timeout tick in the system. + * @brief This function will return the next timeout tick in the system. * * @return the next timeout tick in the system */ @@ -607,7 +641,7 @@ rt_tick_t rt_timer_next_timeout_tick(void) #ifdef RT_USING_TIMER_SOFT /** - * This function will check software-timer list, if a timeout event happens, the + * @brief This function will check software-timer list, if a timeout event happens, the * corresponding timeout function will be invoked. */ void rt_soft_timer_check(void) @@ -684,7 +718,11 @@ void rt_soft_timer_check(void) RT_DEBUG_LOG(RT_DEBUG_TIMER, ("software timer check leave\n")); } -/* system timer thread entry */ +/** + * @brief system timer thread entry + * + * @param parameter + */ static void rt_thread_timer_entry(void *parameter) { rt_tick_t next_timeout; @@ -723,7 +761,7 @@ static void rt_thread_timer_entry(void *parameter) /** * @ingroup SystemInit * - * This function will initialize system timer + * @brief This function will initialize system timer */ void rt_system_timer_init(void) { @@ -738,7 +776,7 @@ void rt_system_timer_init(void) /** * @ingroup SystemInit * - * This function will initialize system timer thread + * @brief This function will initialize system timer thread */ void rt_system_timer_thread_init(void) { From 19bcf9ae32682697dc2beac7cc605f7338d44c2f Mon Sep 17 00:00:00 2001 From: supperthomas <78900636@qq.com> Date: Mon, 16 Aug 2021 22:07:46 +0800 Subject: [PATCH 3/3] add the formatted file --- src/irq.c | 24 ++++++++++++------------ src/timer.c | 40 ++++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/irq.c b/src/irq.c index ac43c45573c..40c2aa5305e 100644 --- a/src/irq.c +++ b/src/irq.c @@ -22,11 +22,11 @@ static void (*rt_interrupt_leave_hook)(void); /** * @ingroup Hook - * + * * @brief This function set a hook function when the system enter a interrupt - * + * * @note the hook function must be simple and never be blocked or suspend. - * + * * @param hook The function point to be called */ void rt_interrupt_enter_sethook(void (*hook)(void)) @@ -36,11 +36,11 @@ void rt_interrupt_enter_sethook(void (*hook)(void)) /** * @ingroup Hook - * + * * @brief This function set a hook function when the system exit a interrupt. - * + * * @note the hook function must be simple and never be blocked or suspend. - * + * * @param hook The function point to be called */ void rt_interrupt_leave_sethook(void (*hook)(void)) @@ -64,9 +64,9 @@ volatile rt_uint8_t rt_interrupt_nest = 0; /** * @brief This function will be invoked by BSP, when enter interrupt service routine - * + * * @note please don't invoke this routine in application - * + * * @see rt_interrupt_leave */ void rt_interrupt_enter(void) @@ -86,9 +86,9 @@ RTM_EXPORT(rt_interrupt_enter); /** * @brief This function will be invoked by BSP, when leave interrupt service routine - * + * * @note please don't invoke this routine in application - * + * * @see rt_interrupt_enter */ void rt_interrupt_leave(void) @@ -108,10 +108,10 @@ RTM_EXPORT(rt_interrupt_leave); /** * @brief This function will return the nest of interrupt. - * + * * User application can invoke this function to get whether current * context is interrupt context. - * + * * @return rt_uint8_t the number of nested interrupts. */ RT_WEAK rt_uint8_t rt_interrupt_get_nest(void) diff --git a/src/timer.c b/src/timer.c index 18b7ac4d587..44d0d4a7cc7 100644 --- a/src/timer.c +++ b/src/timer.c @@ -16,7 +16,7 @@ * 2012-12-15 Bernard fix the next timeout issue in soft timer * 2014-07-12 Bernard does not lock scheduler when invoking soft-timer * timeout function. - * 2021-08-15 supperthomas add the comment + * 2021-08-15 supperthomas add the comment */ #include @@ -60,9 +60,9 @@ static void (*rt_timer_exit_hook)(struct rt_timer *timer); /**@{*/ /** - * @brief This function will set a hook function on timer, + * @brief This function will set a hook function on timer, * which will be invoked when enter timer timeout callback function. - * + * * @param hook the function point of timer */ void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer)) @@ -71,9 +71,9 @@ void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer)) } /** - * @brief This function will set a hook function, which will be + * @brief This function will set a hook function, which will be * invoked when exit * timer timeout callback function. - * + * * @param hook the function point of timer */ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer)) @@ -87,11 +87,11 @@ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer)) /** * @brief [internal] the init funtion of timer - * + * * the internal called function of rt_timer_init - * + * * @see rt_timer_init - * + * * @param timer the static timer object * @param timeout the timeout function * @param parameter the parameter of timeout function @@ -127,9 +127,9 @@ static void _rt_timer_init(rt_timer_t timer, /** * @brief find the next emtpy timer - * + * * @param timer_list the timer of the next timeout - * + * * @return rt_tick_t the point of timer */ static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[]) @@ -155,8 +155,8 @@ static rt_tick_t rt_timer_list_next_timeout(rt_list_t timer_list[]) } /** - * @brief remove the timer - * + * @brief remove the timer + * * @param timer the point of timer */ rt_inline void _rt_timer_remove(rt_timer_t timer) @@ -172,8 +172,8 @@ rt_inline void _rt_timer_remove(rt_timer_t timer) #if RT_DEBUG_TIMER /** * @brief the number of timer - * - * @param timer + * + * @param timer * @return int the count */ static int rt_timer_count_height(struct rt_timer *timer) @@ -189,7 +189,7 @@ static int rt_timer_count_height(struct rt_timer *timer) } /** * @brief dump the all timer information - * + * * @param timer_heads the head of timer */ void rt_timer_dump(rt_list_t timer_heads[]) @@ -244,7 +244,7 @@ RTM_EXPORT(rt_timer_init); /** * @brief This function will detach a timer from timer management. - * + * * @param timer the timer to be detached * @return rt_err_t RT_EOK */ @@ -555,7 +555,7 @@ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg) RTM_EXPORT(rt_timer_control); /** - * @brief This function will check timer list, if a timeout event happens, + * @brief This function will check timer list, if a timeout event happens, * the corresponding timeout function will be invoked. * * @note this function shall be invoked in operating system timer interrupt. @@ -719,9 +719,9 @@ void rt_soft_timer_check(void) } /** - * @brief system timer thread entry - * - * @param parameter + * @brief system timer thread entry + * + * @param parameter */ static void rt_thread_timer_entry(void *parameter) {