@@ -43,7 +43,8 @@ static rt_uint8_t timer_thread_stack[RT_TIMER_THREAD_STACK_SIZE];
4343#ifdef RT_USING_HOOK
4444extern void (* rt_object_take_hook )(struct rt_object * object );
4545extern void (* rt_object_put_hook )(struct rt_object * object );
46- static void (* rt_timer_timeout_hook )(struct rt_timer * timer );
46+ static void (* rt_timer_enter_hook )(struct rt_timer * timer );
47+ static void (* rt_timer_exit_hook )(struct rt_timer * timer );
4748
4849/**
4950 * @addtogroup Hook
@@ -52,14 +53,25 @@ static void (*rt_timer_timeout_hook)(struct rt_timer *timer);
5253/**@{*/
5354
5455/**
55- * This function will set a hook function, which will be invoked when timer
56- * is timeout.
56+ * This function will set a hook function, which will be invoked when enter
57+ * timer timeout callback function .
5758 *
5859 * @param hook the hook function
5960 */
60- void rt_timer_timeout_sethook (void (* hook )(struct rt_timer * timer ))
61+ void rt_timer_enter_sethook (void (* hook )(struct rt_timer * timer ))
6162{
62- rt_timer_timeout_hook = hook ;
63+ rt_timer_enter_hook = hook ;
64+ }
65+
66+ /**
67+ * This function will set a hook function, which will be invoked when exit
68+ * timer timeout callback function.
69+ *
70+ * @param hook the hook function
71+ */
72+ void rt_timer_exit_sethook (void (* hook )(struct rt_timer * timer ))
73+ {
74+ rt_timer_exit_hook = hook ;
6375}
6476
6577/**@}*/
@@ -503,7 +515,7 @@ void rt_timer_check(void)
503515 */
504516 if ((current_tick - t -> timeout_tick ) < RT_TICK_MAX / 2 )
505517 {
506- RT_OBJECT_HOOK_CALL (rt_timer_timeout_hook , (t ));
518+ RT_OBJECT_HOOK_CALL (rt_timer_enter_hook , (t ));
507519
508520 /* remove timer from timer list firstly */
509521 _rt_timer_remove (t );
@@ -514,6 +526,7 @@ void rt_timer_check(void)
514526 /* re-get tick */
515527 current_tick = rt_tick_get ();
516528
529+ RT_OBJECT_HOOK_CALL (rt_timer_exit_hook , (t ));
517530 RT_DEBUG_LOG (RT_DEBUG_TIMER , ("current tick: %d\n" , current_tick ));
518531
519532 if ((t -> parent .flag & RT_TIMER_FLAG_PERIODIC ) &&
@@ -578,7 +591,7 @@ void rt_soft_timer_check(void)
578591 */
579592 if ((current_tick - t -> timeout_tick ) < RT_TICK_MAX / 2 )
580593 {
581- RT_OBJECT_HOOK_CALL (rt_timer_timeout_hook , (t ));
594+ RT_OBJECT_HOOK_CALL (rt_timer_enter_hook , (t ));
582595
583596 /* move node to the next */
584597 n = n -> next ;
@@ -594,6 +607,7 @@ void rt_soft_timer_check(void)
594607 /* re-get tick */
595608 current_tick = rt_tick_get ();
596609
610+ RT_OBJECT_HOOK_CALL (rt_timer_exit_hook , (t ));
597611 RT_DEBUG_LOG (RT_DEBUG_TIMER , ("current tick: %d\n" , current_tick ));
598612
599613 /* lock scheduler */
0 commit comments