diff --git a/include/rtthread.h b/include/rtthread.h index d719e4bfb..2037645e4 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -164,7 +164,7 @@ void rt_thread_inited_sethook (void (*hook)(rt_thread_t thread)); * idle thread interface */ void rt_thread_idle_init(void); -#ifdef RT_USING_HOOK +#if defined(RT_USING_HOOK) || defined(RT_USING_IDLE_HOOK) void rt_thread_idle_sethook(void (*hook)(void)); #endif void rt_thread_idle_excute(void); diff --git a/src/idle.c b/src/idle.c index aab09cb91..b821c66fd 100644 --- a/src/idle.c +++ b/src/idle.c @@ -30,8 +30,14 @@ #include #include +#if defined (RT_USING_HOOK) +#ifndef RT_USING_IDLE_HOOK +#define RT_USING_IDLE_HOOK 1 +#endif +#endif + #ifndef IDLE_THREAD_STACK_SIZE -#if defined (RT_USING_HOOK) || defined(RT_USING_HEAP) +#if defined (RT_USING_IDLE_HOOK) || defined(RT_USING_HEAP) #define IDLE_THREAD_STACK_SIZE 256 #else #define IDLE_THREAD_STACK_SIZE 128 @@ -44,7 +50,7 @@ static rt_uint8_t rt_thread_stack[IDLE_THREAD_STACK_SIZE]; extern rt_list_t rt_thread_defunct; -#ifdef RT_USING_HOOK +#ifdef RT_USING_IDLE_HOOK static void (*rt_thread_idle_hook)(); /** @@ -179,7 +185,13 @@ static void rt_thread_idle_entry(void *parameter) { while (1) { - RT_OBJECT_HOOK_CALL(rt_thread_idle_hook,()); + #ifdef RT_USING_IDLE_HOOK + if (rt_thread_idle_hook != RT_NULL) + { + rt_thread_idle_hook(); + } + #endif + rt_thread_idle_excute(); } }