|
@@ -26,6 +26,32 @@
|
|
|
static volatile rt_tick_t rt_tick = 0;
|
|
|
#endif /* RT_USING_SMP */
|
|
|
|
|
|
+#ifndef __on_rt_tick_hook
|
|
|
+ #define __on_rt_tick_hook() __ON_HOOK_ARGS(rt_tick_hook, ())
|
|
|
+#endif
|
|
|
+
|
|
|
+#if defined(RT_USING_HOOK) && defined(RT_HOOK_USING_FUNC_PTR)
|
|
|
+static void (*rt_tick_hook)(void);
|
|
|
+
|
|
|
+/**
|
|
|
+ * @addtogroup Hook
|
|
|
+ */
|
|
|
+
|
|
|
+/**@{*/
|
|
|
+
|
|
|
+/**
|
|
|
+ * This function will set a hook function, which will be invoked when tick increase
|
|
|
+ *
|
|
|
+ *
|
|
|
+ * @param hook the hook function
|
|
|
+ */
|
|
|
+void rt_tick_sethook(void (*hook)(void))
|
|
|
+{
|
|
|
+ rt_tick_hook = hook;
|
|
|
+}
|
|
|
+/**@}*/
|
|
|
+#endif /* RT_USING_HOOK */
|
|
|
+
|
|
|
/**
|
|
|
* @addtogroup Clock
|
|
|
*/
|
|
@@ -67,6 +93,8 @@ void rt_tick_increase(void)
|
|
|
struct rt_thread *thread;
|
|
|
rt_base_t level;
|
|
|
|
|
|
+ RT_OBJECT_HOOK_CALL(rt_tick_hook, ());
|
|
|
+
|
|
|
level = rt_hw_interrupt_disable();
|
|
|
|
|
|
/* increase the global tick */
|