From e05186dd9501afeae3d81b10316bbef8a203b990 Mon Sep 17 00:00:00 2001 From: xieyangrun Date: Tue, 16 May 2017 10:02:19 +0800 Subject: [PATCH 1/5] separate idle hook --- src/idle.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/idle.c b/src/idle.c index aab09cb913..fab4b82439 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 +#deifne 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)(); /** From 662f619cf6723c9322f7bfb83f7d1b441edac4bf Mon Sep 17 00:00:00 2001 From: geniusgogo Date: Tue, 16 May 2017 10:42:29 +0800 Subject: [PATCH 2/5] Update idle.c --- src/idle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/idle.c b/src/idle.c index fab4b82439..630ce0cdc7 100644 --- a/src/idle.c +++ b/src/idle.c @@ -32,7 +32,7 @@ #if defined (RT_USING_HOOK) #ifndef RT_USING_IDLE_HOOK -#deifne RT_USING_IDLE_HOOK 1 +#define RT_USING_IDLE_HOOK 1 #endif #endif From 3c14a8867ddd0b4ed74cb07b0cf9975f4b32515f Mon Sep 17 00:00:00 2001 From: geniusgogo Date: Mon, 22 May 2017 23:53:55 +0800 Subject: [PATCH 3/5] Update idle.c --- src/idle.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/idle.c b/src/idle.c index 630ce0cdc7..50d55657a1 100644 --- a/src/idle.c +++ b/src/idle.c @@ -185,7 +185,13 @@ static void rt_thread_idle_entry(void *parameter) { while (1) { - RT_OBJECT_HOOK_CALL(rt_thread_idle_hook,()); + #if defined(RT_USING_IDLE_HOOK) && (RT_USING_IDLE_HOOK == 1) + if (rt_thread_idle_hook != RT_NULL) + { + rt_thread_idle_hook(); + } + #endif + rt_thread_idle_excute(); } } From 387bbcc44fbd42254da931139a4a5551f8a85200 Mon Sep 17 00:00:00 2001 From: geniusgogo Date: Tue, 23 May 2017 00:01:05 +0800 Subject: [PATCH 4/5] Update rtthread.h --- include/rtthread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rtthread.h b/include/rtthread.h index d719e4bfb4..2037645e44 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); From 05052127c3fe2fcc8989e5cafa8099e7091a9a0c Mon Sep 17 00:00:00 2001 From: geniusgogo Date: Tue, 23 May 2017 11:04:22 +0800 Subject: [PATCH 5/5] Update idle.c --- src/idle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/idle.c b/src/idle.c index 50d55657a1..b821c66fd9 100644 --- a/src/idle.c +++ b/src/idle.c @@ -185,7 +185,7 @@ static void rt_thread_idle_entry(void *parameter) { while (1) { - #if defined(RT_USING_IDLE_HOOK) && (RT_USING_IDLE_HOOK == 1) + #ifdef RT_USING_IDLE_HOOK if (rt_thread_idle_hook != RT_NULL) { rt_thread_idle_hook();