From 4c4089b1544b590ed3b72491a15365ec020c921f Mon Sep 17 00:00:00 2001 From: Pramith K V Date: Thu, 9 Dec 2021 05:17:07 +0530 Subject: [PATCH] Remove tickless idle mode dependency with include v task suspend (#422) * Fix Remove tickless idle feature dependency with INCLUDE_vTaskSuspend * fix unused variable warning * Fix CI fomatting check Signed-off-by: Gaurav Aggarwal Authored-by: pramithkv --- include/FreeRTOS.h | 6 ------ include/task.h | 8 +++++--- tasks.c | 29 ++++++++++++++++------------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index fc4d3631f..e79b02505 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -924,12 +924,6 @@ #endif /* Sanity check the configuration. */ -#if ( configUSE_TICKLESS_IDLE != 0 ) - #if ( INCLUDE_vTaskSuspend != 1 ) - #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0 - #endif /* INCLUDE_vTaskSuspend */ -#endif /* configUSE_TICKLESS_IDLE */ - #if ( ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) ) #error configSUPPORT_STATIC_ALLOCATION and configSUPPORT_DYNAMIC_ALLOCATION cannot both be 0, but can both be 1. #endif diff --git a/include/task.h b/include/task.h index ec684c4ca..4045f107a 100644 --- a/include/task.h +++ b/include/task.h @@ -167,9 +167,11 @@ typedef struct xTASK_STATUS /* Possible return values for eTaskConfirmSleepModeStatus(). */ typedef enum { - eAbortSleep = 0, /* A task has been made ready or a context switch pended since portSUPPRESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */ - eStandardSleep, /* Enter a sleep mode that will not last any longer than the expected idle time. */ - eNoTasksWaitingTimeout /* No tasks are waiting for a timeout so it is safe to enter a sleep mode that can only be exited by an external interrupt. */ + eAbortSleep = 0, /* A task has been made ready or a context switch pended since portSUPPRESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */ + eStandardSleep, /* Enter a sleep mode that will not last any longer than the expected idle time. */ + #if ( INCLUDE_vTaskSuspend == 1 ) + eNoTasksWaitingTimeout /* No tasks are waiting for a timeout so it is safe to enter a sleep mode that can only be exited by an external interrupt. */ + #endif /* INCLUDE_vTaskSuspend */ } eSleepModeStatus; /** diff --git a/tasks.c b/tasks.c index eff0eff0d..de70417f6 100644 --- a/tasks.c +++ b/tasks.c @@ -3529,8 +3529,11 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) eSleepModeStatus eTaskConfirmSleepModeStatus( void ) { - /* The idle task exists in addition to the application tasks. */ - const UBaseType_t uxNonApplicationTasks = 1; + #if ( INCLUDE_vTaskSuspend == 1 ) + /* The idle task exists in addition to the application tasks. */ + const UBaseType_t uxNonApplicationTasks = 1; + #endif /* INCLUDE_vTaskSuspend */ + eSleepModeStatus eReturn = eStandardSleep; /* This function must be called from a critical section. */ @@ -3551,20 +3554,20 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) * because the scheduler is suspended. */ eReturn = eAbortSleep; } - else - { - /* If all the tasks are in the suspended list (which might mean they - * have an infinite block time rather than actually being suspended) - * then it is safe to turn all clocks off and just wait for external - * interrupts. */ - if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == ( uxCurrentNumberOfTasks - uxNonApplicationTasks ) ) + + #if ( INCLUDE_vTaskSuspend == 1 ) + else if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == ( uxCurrentNumberOfTasks - uxNonApplicationTasks ) ) { + /* If all the tasks are in the suspended list (which might mean they + * have an infinite block time rather than actually being suspended) + * then it is safe to turn all clocks off and just wait for external + * interrupts. */ eReturn = eNoTasksWaitingTimeout; } - else - { - mtCOVERAGE_TEST_MARKER(); - } + #endif /* INCLUDE_vTaskSuspend */ + else + { + mtCOVERAGE_TEST_MARKER(); } return eReturn;