From 4732b96dba05e2eeaeaec795977ab0a054cce065 Mon Sep 17 00:00:00 2001 From: RichardBarry <3073890+RichardBarry@users.noreply.github.com> Date: Wed, 6 Mar 2024 23:08:15 -0800 Subject: [PATCH] Add daemon task startup hook / timer task creation consistency check (#1009) Add a compile time check that emits a helpful error message if the user attempts to create a daemon task startup hook without also creating the timer/daemon task. The timer/daemon task startup hook runs in the context of the timer/daemon task. Therefore, it won't run even if configUSE_DAEMON_TASK_STARTUP_HOOK is set to 1 if the timer task isn't created. The timer task is only created if configUSE_TIMERS is not equal to 0. --- include/FreeRTOS.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index ecf82dc5a..8dcb407f4 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -298,10 +298,6 @@ #endif #endif -#ifndef configUSE_DAEMON_TASK_STARTUP_HOOK - #define configUSE_DAEMON_TASK_STARTUP_HOOK 0 -#endif - #ifndef configUSE_APPLICATION_TASK_TAG #define configUSE_APPLICATION_TASK_TAG 0 #endif @@ -322,6 +318,16 @@ #define configUSE_TIMERS 0 #endif +#ifndef configUSE_DAEMON_TASK_STARTUP_HOOK + #define configUSE_DAEMON_TASK_STARTUP_HOOK 0 +#endif + +#if ( configUSE_DAEMON_TASK_STARTUP_HOOK != 0 ) + #if ( configUSE_TIMERS == 0 ) + #error configUSE_DAEMON_TASK_STARTUP_HOOK is set, but the daemon task is not created because configUSE_TIMERS is 0. + #endif +#endif + #ifndef configUSE_COUNTING_SEMAPHORES #define configUSE_COUNTING_SEMAPHORES 0 #endif