From: richardbarry Date: Thu, 31 Jan 2013 14:18:03 +0000 (+0000) Subject: Added INCLUDE_xSemaphoreGetMutexHolder() default. X-Git-Tag: V7.4.0~16 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=71bb7038b319b2559c5d471ea8fc363273f80158;p=freertos Added INCLUDE_xSemaphoreGetMutexHolder() default. Changed eTaskStateGet() to eTaskGetState() and added #define to ensure backward compatibility. Added configEXPECTED_IDLE_TIME_BEFORE_SLEEP definition - was previously hard coded to 2. Slight change to the default CM3 tickless sleep function to allow the idle time to be set to zero in the pre-sleep processing macro. Changed stack alignment for the FreeRTOS-MPU port to ensure it didn't trigger the assert() in the generic create function. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1815 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h b/FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h index 3e3795eae..deb4a3c36 100644 --- a/FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h @@ -139,4 +139,6 @@ version of the Win32 simulator projects. It will be ignored in the GCC version. */ #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 +#define configUSE_QUEUE_SETS 1 + #endif /* FREERTOS_CONFIG_H */ diff --git a/FreeRTOS/Demo/WIN32-MSVC/WIN32.suo b/FreeRTOS/Demo/WIN32-MSVC/WIN32.suo index 607824b98..1c3bbaa14 100644 Binary files a/FreeRTOS/Demo/WIN32-MSVC/WIN32.suo and b/FreeRTOS/Demo/WIN32-MSVC/WIN32.suo differ diff --git a/FreeRTOS/Source/include/FreeRTOS.h b/FreeRTOS/Source/include/FreeRTOS.h index 99df4acda..93a8e1499 100644 --- a/FreeRTOS/Source/include/FreeRTOS.h +++ b/FreeRTOS/Source/include/FreeRTOS.h @@ -161,6 +161,10 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * ); #define INCLUDE_xQueueGetMutexHolder 0 #endif +#ifndef INCLUDE_xSemaphoreGetMutexHolder + #define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder +#endif + #ifndef INCLUDE_pcTaskGetTaskName #define INCLUDE_pcTaskGetTaskName 0 #endif @@ -173,8 +177,8 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * ); #define INCLUDE_uxTaskGetStackHighWaterMark 0 #endif -#ifndef INCLUDE_eTaskStateGet - #define INCLUDE_eTaskStateGet 0 +#ifndef INCLUDE_eTaskGetState + #define INCLUDE_eTaskGetState 0 #endif #ifndef configUSE_RECURSIVE_MUTEXES @@ -534,6 +538,14 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * ); #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) #endif +#ifndef configEXPECTED_IDLE_TIME_BEFORE_SLEEP + #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2 +#endif + +#if configEXPECTED_IDLE_TIME_BEFORE_SLEEP < 2 + #error configEXPECTED_IDLE_TIME_BEFORE_SLEEP must not be less than 2 +#endif + #ifndef configUSE_TICKLESS_IDLE #define configUSE_TICKLESS_IDLE 0 #endif @@ -546,5 +558,9 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * ); #define configPOST_SLEEP_PROCESSING( x ) #endif +/* For backward compatability. */ +#define eTaskStateGet eTaskGetState +#define INCLUDE_eTaskStateGet INCLUDE_eTaskGetState + #endif /* INC_FREERTOS_H */ diff --git a/FreeRTOS/Source/include/mpu_wrappers.h b/FreeRTOS/Source/include/mpu_wrappers.h index 299e8d00e..b2ded270c 100644 --- a/FreeRTOS/Source/include/mpu_wrappers.h +++ b/FreeRTOS/Source/include/mpu_wrappers.h @@ -85,7 +85,7 @@ only for ports that are using the MPU. */ #define vTaskDelay MPU_vTaskDelay #define uxTaskPriorityGet MPU_uxTaskPriorityGet #define vTaskPrioritySet MPU_vTaskPrioritySet - #define eTaskStateGet MPU_eTaskStateGet + #define eTaskGetState MPU_eTaskGetState #define vTaskSuspend MPU_vTaskSuspend #define xTaskIsTaskSuspended MPU_xTaskIsTaskSuspended #define vTaskResume MPU_vTaskResume diff --git a/FreeRTOS/Source/include/task.h b/FreeRTOS/Source/include/task.h index b6a7818a8..b4d359cdd 100644 --- a/FreeRTOS/Source/include/task.h +++ b/FreeRTOS/Source/include/task.h @@ -131,7 +131,7 @@ typedef struct xTASK_PARAMTERS xMemoryRegion xRegions[ portNUM_CONFIGURABLE_REGIONS ]; } xTaskParameters; -/* Task states returned by eTaskStateGet. */ +/* Task states returned by eTaskGetState. */ typedef enum { eRunning = 0, /* A task is querying the state of itself, so must be running. */ @@ -613,9 +613,9 @@ unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask ) PRIVILEGED_FUNCTI /** * task. h - *
eTaskState eTaskStateGet( xTaskHandle pxTask );
+ *
eTaskState eTaskGetState( xTaskHandle pxTask );
* - * INCLUDE_eTaskStateGet must be defined as 1 for this function to be available. + * INCLUDE_eTaskGetState must be defined as 1 for this function to be available. * See the configuration section for more information. * * Obtain the state of any task. States are encoded by the eTaskState @@ -627,7 +627,7 @@ unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask ) PRIVILEGED_FUNCTI * state of the task might change between the function being called, and the * functions return value being tested by the calling task. */ -eTaskState eTaskStateGet( xTaskHandle pxTask ) PRIVILEGED_FUNCTION; +eTaskState eTaskGetState( xTaskHandle pxTask ) PRIVILEGED_FUNCTION; /** * task. h diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c index 206f484f5..286b19ac4 100644 --- a/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c @@ -1,7 +1,7 @@ /* FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd. - FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT + FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. *************************************************************************** @@ -42,7 +42,7 @@ FreeRTOS WEB site. 1 tab == 4 spaces! - + *************************************************************************** * * * Having a problem? Start by reading the FAQ "My application does * @@ -52,17 +52,17 @@ * * *************************************************************************** - - http://www.FreeRTOS.org - Documentation, training, latest versions, license - and contact details. - + + http://www.FreeRTOS.org - Documentation, training, latest versions, license + and contact details. + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, including FreeRTOS+Trace - an indispensable productivity tool. - Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell - the code with commercial support, indemnification, and middleware, under + Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell + the code with commercial support, indemnification, and middleware, under the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also - provide a safety engineered and independently SIL3 certified version under + provide a safety engineered and independently SIL3 certified version under the SafeRTOS brand: http://www.SafeRTOS.com. */ @@ -116,7 +116,7 @@ static unsigned portBASE_TYPE uxCriticalNesting = 0xaaaaaaaa; /* * Setup the timer to generate the tick interrupts. The implementation in this - * file is weak to allow application writers to change the timer used to + * file is weak to allow application writers to change the timer used to * generate the tick interrupt. */ void vPortSetupTimerInterrupt( void ); @@ -298,7 +298,7 @@ __attribute__(( naked )) void vPortClearInterruptMask( unsigned long ulNewMaskVa " bx lr \n" \ :::"r0" \ ); - + /* Just to avoid compiler warnings. */ ( void ) ulNewMaskValue; } @@ -347,7 +347,7 @@ void xPortSysTickHandler( void ) #endif /* Only reset the systick load register if configUSE_TICKLESS_IDLE is set to - 1. If it is set to 0 tickless idle is not being used. If it is set to a + 1. If it is set to 0 tickless idle is not being used. If it is set to a value other than 0 or 1 then a timer other than the SysTick is being used to generate the tick interrupt. */ #if configUSE_TICKLESS_IDLE == 1 @@ -367,6 +367,7 @@ void xPortSysTickHandler( void ) __attribute__((weak)) void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime ) { unsigned long ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickIncrements; + portTickType xModifiableIdleTime; /* Make sure the SysTick reload value does not overflow the counter. */ if( xExpectedIdleTime > xMaximumPossibleSuppressedTicks ) @@ -412,9 +413,14 @@ void xPortSysTickHandler( void ) /* Restart SysTick. */ portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT; - /* Sleep until something happens. */ - configPRE_SLEEP_PROCESSING( xExpectedIdleTime ); - if( xExpectedIdleTime > 0 ) + /* Sleep until something happens. configPRE_SLEEP_PROCESSING() can + set its parameter to 0 to indicate that its implementation contains + its own wait for interrupt or wait for event instruction, and so wfi + should not be executed again. However, the original expected idle + time variable must remain unmodified, so a copy is taken. */ + xModifiableIdleTime = xExpectedIdleTime; + configPRE_SLEEP_PROCESSING( xModifiableIdleTime ); + if( xModifiableIdleTime > 0 ) { __asm volatile( "wfi" ); } @@ -475,7 +481,7 @@ void xPortSysTickHandler( void ) */ __attribute__(( weak )) void vPortSetupTimerInterrupt( void ) { - /* Calculate the constants required to configure the tick interrupt. */ + /* Calculate the constants required to configure the tick interrupt. */ #if configUSE_TICKLESS_IDLE == 1 { ulTimerReloadValueForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM3_MPU/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM3_MPU/port.c index 514b88e80..2c79740d2 100644 --- a/FreeRTOS/Source/portable/GCC/ARM_CM3_MPU/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CM3_MPU/port.c @@ -180,7 +180,7 @@ void MPU_vTaskDelayUntil( portTickType * const pxPreviousWakeTime, portTickType void MPU_vTaskDelay( portTickType xTicksToDelay ); unsigned portBASE_TYPE MPU_uxTaskPriorityGet( xTaskHandle pxTask ); void MPU_vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority ); -eTaskState MPU_eTaskStateGet( xTaskHandle pxTask ); +eTaskState MPU_eTaskGetState( xTaskHandle pxTask ); void MPU_vTaskSuspend( xTaskHandle pxTaskToSuspend ); signed portBASE_TYPE MPU_xTaskIsTaskSuspended( xTaskHandle xTask ); void MPU_vTaskResume( xTaskHandle pxTaskToResume ); @@ -223,6 +223,7 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE /* Simulate the stack frame as it would be created by a context switch interrupt. */ pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */ + pxTopOfStack--; /* Offset added to ensure 8-byte alignment is maintained. */ *pxTopOfStack = portINITIAL_XPSR; /* xPSR */ pxTopOfStack--; *pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* PC */ @@ -736,13 +737,13 @@ portBASE_TYPE xRunningPrivileged = prvRaisePrivilege(); #endif /*-----------------------------------------------------------*/ -#if ( INCLUDE_eTaskStateGet == 1 ) - eTaskState MPU_eTaskStateGet( xTaskHandle pxTask ) +#if ( INCLUDE_eTaskGetState == 1 ) + eTaskState MPU_eTaskGetState( xTaskHandle pxTask ) { portBASE_TYPE xRunningPrivileged = prvRaisePrivilege(); eTaskState eReturn; - eReturn = eTaskStateGet( pxTask ); + eReturn = eTaskGetState( pxTask ); portRESET_PRIVILEGE( xRunningPrivileged ); return eReturn; } diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c index b9394cc55..c3d095a38 100644 --- a/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c @@ -1,7 +1,7 @@ /* FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd. - FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT + FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. *************************************************************************** @@ -42,7 +42,7 @@ FreeRTOS WEB site. 1 tab == 4 spaces! - + *************************************************************************** * * * Having a problem? Start by reading the FAQ "My application does * @@ -52,17 +52,17 @@ * * *************************************************************************** - - http://www.FreeRTOS.org - Documentation, training, latest versions, license - and contact details. - + + http://www.FreeRTOS.org - Documentation, training, latest versions, license + and contact details. + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, including FreeRTOS+Trace - an indispensable productivity tool. - Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell - the code with commercial support, indemnification, and middleware, under + Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell + the code with commercial support, indemnification, and middleware, under the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also - provide a safety engineered and independently SIL3 certified version under + provide a safety engineered and independently SIL3 certified version under the SafeRTOS brand: http://www.SafeRTOS.com. */ @@ -118,7 +118,7 @@ static unsigned portBASE_TYPE uxCriticalNesting = 0xaaaaaaaa; /* * Setup the timer to generate the tick interrupts. The implementation in this - * file is weak to allow application writers to change the timer used to + * file is weak to allow application writers to change the timer used to * generate the tick interrupt. */ void vPortSetupTimerInterrupt( void ); @@ -379,7 +379,7 @@ void xPortSysTickHandler( void ) #endif /* Only reset the systick load register if configUSE_TICKLESS_IDLE is set to - 1. If it is set to 0 tickless idle is not being used. If it is set to a + 1. If it is set to 0 tickless idle is not being used. If it is set to a value other than 0 or 1 then a timer other than the SysTick is being used to generate the tick interrupt. */ #if configUSE_TICKLESS_IDLE == 1 @@ -399,6 +399,7 @@ void xPortSysTickHandler( void ) __attribute__((weak)) void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime ) { unsigned long ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickIncrements; + portTickType xModifiableIdleTime; /* Make sure the SysTick reload value does not overflow the counter. */ if( xExpectedIdleTime > xMaximumPossibleSuppressedTicks ) @@ -444,9 +445,14 @@ void xPortSysTickHandler( void ) /* Restart SysTick. */ portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT; - /* Sleep until something happens. */ - configPRE_SLEEP_PROCESSING( xExpectedIdleTime ); - if( xExpectedIdleTime > 0 ) + /* Sleep until something happens. configPRE_SLEEP_PROCESSING() can + set its parameter to 0 to indicate that its implementation contains + its own wait for interrupt or wait for event instruction, and so wfi + should not be executed again. However, the original expected idle + time variable must remain unmodified, so a copy is taken. */ + xModifiableIdleTime = xExpectedIdleTime; + configPRE_SLEEP_PROCESSING( xModifiableIdleTime ); + if( xModifiableIdleTime > 0 ) { __asm volatile( "wfi" ); } @@ -507,7 +513,7 @@ void xPortSysTickHandler( void ) */ __attribute__(( weak )) void vPortSetupTimerInterrupt( void ) { - /* Calculate the constants required to configure the tick interrupt. */ + /* Calculate the constants required to configure the tick interrupt. */ #if configUSE_TICKLESS_IDLE == 1 { ulTimerReloadValueForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM3/port.c b/FreeRTOS/Source/portable/IAR/ARM_CM3/port.c index c501e7259..c538e6dc7 100644 --- a/FreeRTOS/Source/portable/IAR/ARM_CM3/port.c +++ b/FreeRTOS/Source/portable/IAR/ARM_CM3/port.c @@ -265,6 +265,7 @@ void xPortSysTickHandler( void ) __weak void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime ) { unsigned long ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickIncrements; + portTickType xModifiableIdleTime; /* Make sure the SysTick reload value does not overflow the counter. */ if( xExpectedIdleTime > xMaximumPossibleSuppressedTicks ) @@ -310,9 +311,14 @@ void xPortSysTickHandler( void ) /* Restart SysTick. */ portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT; - /* Sleep until something happens. */ - configPRE_SLEEP_PROCESSING( xExpectedIdleTime ); - if( xExpectedIdleTime > 0 ) + /* Sleep until something happens. configPRE_SLEEP_PROCESSING() can + set its parameter to 0 to indicate that its implementation contains + its own wait for interrupt or wait for event instruction, and so wfi + should not be executed again. However, the original expected idle + time variable must remain unmodified, so a copy is taken. */ + xModifiableIdleTime = xExpectedIdleTime; + configPRE_SLEEP_PROCESSING( xModifiableIdleTime ); + if( xModifiableIdleTime > 0 ) { __WFI(); } @@ -373,7 +379,7 @@ void xPortSysTickHandler( void ) */ __weak void vPortSetupTimerInterrupt( void ) { - /* Calculate the constants required to configure the tick interrupt. */ + /* Calculate the constants required to configure the tick interrupt. */ #if configUSE_TICKLESS_IDLE == 1 { ulTimerReloadValueForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM4F/port.c b/FreeRTOS/Source/portable/IAR/ARM_CM4F/port.c index f6434caef..5f1a8fe6c 100644 --- a/FreeRTOS/Source/portable/IAR/ARM_CM4F/port.c +++ b/FreeRTOS/Source/portable/IAR/ARM_CM4F/port.c @@ -290,6 +290,7 @@ void xPortSysTickHandler( void ) __weak void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime ) { unsigned long ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickIncrements; + portTickType xModifiableIdleTime; /* Make sure the SysTick reload value does not overflow the counter. */ if( xExpectedIdleTime > xMaximumPossibleSuppressedTicks ) @@ -335,9 +336,14 @@ void xPortSysTickHandler( void ) /* Restart SysTick. */ portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT; - /* Sleep until something happens. */ - configPRE_SLEEP_PROCESSING( xExpectedIdleTime ); - if( xExpectedIdleTime > 0 ) + /* Sleep until something happens. configPRE_SLEEP_PROCESSING() can + set its parameter to 0 to indicate that its implementation contains + its own wait for interrupt or wait for event instruction, and so wfi + should not be executed again. However, the original expected idle + time variable must remain unmodified, so a copy is taken. */ + xModifiableIdleTime = xExpectedIdleTime; + configPRE_SLEEP_PROCESSING( xModifiableIdleTime ); + if( xModifiableIdleTime > 0 ) { __WFI(); } diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c index be3d8e643..0c8f29c3b 100644 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c @@ -1,7 +1,7 @@ /* FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd. - FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT + FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. *************************************************************************** @@ -42,7 +42,7 @@ FreeRTOS WEB site. 1 tab == 4 spaces! - + *************************************************************************** * * * Having a problem? Start by reading the FAQ "My application does * @@ -52,17 +52,17 @@ * * *************************************************************************** - - http://www.FreeRTOS.org - Documentation, training, latest versions, license - and contact details. - + + http://www.FreeRTOS.org - Documentation, training, latest versions, license + and contact details. + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, including FreeRTOS+Trace - an indispensable productivity tool. - Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell - the code with commercial support, indemnification, and middleware, under + Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell + the code with commercial support, indemnification, and middleware, under the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also - provide a safety engineered and independently SIL3 certified version under + provide a safety engineered and independently SIL3 certified version under the SafeRTOS brand: http://www.SafeRTOS.com. */ @@ -88,7 +88,7 @@ /* The __weak attribute does not work as you might expect with the Keil tools so the configOVERRIDE_DEFAULT_TICK_CONFIGURATION constant must be set to 1 if -the application writer wants to provide their own implementation of +the application writer wants to provide their own implementation of vPortSetupTimerInterrupt(). Ensure configOVERRIDE_DEFAULT_TICK_CONFIGURATION is defined. */ #ifndef configOVERRIDE_DEFAULT_TICK_CONFIGURATION @@ -122,7 +122,7 @@ static unsigned portBASE_TYPE uxCriticalNesting = 0xaaaaaaaa; /* * Setup the timer to generate the tick interrupts. The implementation in this - * file is weak to allow application writers to change the timer used to + * file is weak to allow application writers to change the timer used to * generate the tick interrupt. */ void vPortSetupTimerInterrupt( void ); @@ -319,7 +319,7 @@ void xPortSysTickHandler( void ) #endif /* Only reset the systick load register if configUSE_TICKLESS_IDLE is set to - 1. If it is set to 0 tickless idle is not being used. If it is set to a + 1. If it is set to 0 tickless idle is not being used. If it is set to a value other than 0 or 1 then a timer other than the SysTick is being used to generate the tick interrupt. */ #if configUSE_TICKLESS_IDLE == 1 @@ -339,6 +339,7 @@ void xPortSysTickHandler( void ) __weak void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime ) { unsigned long ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickIncrements; + portTickType xModifiableIdleTime; /* Make sure the SysTick reload value does not overflow the counter. */ if( xExpectedIdleTime > xMaximumPossibleSuppressedTicks ) @@ -384,9 +385,14 @@ void xPortSysTickHandler( void ) /* Restart SysTick. */ portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT; - /* Sleep until something happens. */ - configPRE_SLEEP_PROCESSING( xExpectedIdleTime ); - if( xExpectedIdleTime > 0 ) + /* Sleep until something happens. configPRE_SLEEP_PROCESSING() can + set its parameter to 0 to indicate that its implementation contains + its own wait for interrupt or wait for event instruction, and so wfi + should not be executed again. However, the original expected idle + time variable must remain unmodified, so a copy is taken. */ + xModifiableIdleTime = xExpectedIdleTime; + configPRE_SLEEP_PROCESSING( xModifiableIdleTime ); + if( xModifiableIdleTime > 0 ) { __wfi(); } @@ -450,7 +456,7 @@ void xPortSysTickHandler( void ) void vPortSetupTimerInterrupt( void ) { - /* Calculate the constants required to configure the tick interrupt. */ + /* Calculate the constants required to configure the tick interrupt. */ #if configUSE_TICKLESS_IDLE == 1 { ulTimerReloadValueForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; @@ -458,12 +464,12 @@ void xPortSysTickHandler( void ) ulStoppedTimerCompensation = 45UL / ( configCPU_CLOCK_HZ / configSYSTICK_CLOCK_HZ ); } #endif /* configUSE_TICKLESS_IDLE */ - + /* Configure SysTick to interrupt at the requested rate. */ portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;; portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT; } - + #endif /* configOVERRIDE_DEFAULT_TICK_CONFIGURATION */ /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c index 2c2c4c79a..147ebcbdf 100644 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c @@ -1,7 +1,7 @@ /* FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd. - FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT + FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. *************************************************************************** @@ -42,7 +42,7 @@ FreeRTOS WEB site. 1 tab == 4 spaces! - + *************************************************************************** * * * Having a problem? Start by reading the FAQ "My application does * @@ -52,17 +52,17 @@ * * *************************************************************************** - - http://www.FreeRTOS.org - Documentation, training, latest versions, license - and contact details. - + + http://www.FreeRTOS.org - Documentation, training, latest versions, license + and contact details. + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, including FreeRTOS+Trace - an indispensable productivity tool. - Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell - the code with commercial support, indemnification, and middleware, under + Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell + the code with commercial support, indemnification, and middleware, under the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also - provide a safety engineered and independently SIL3 certified version under + provide a safety engineered and independently SIL3 certified version under the SafeRTOS brand: http://www.SafeRTOS.com. */ @@ -88,7 +88,7 @@ /* The __weak attribute does not work as you might expect with the Keil tools so the configOVERRIDE_DEFAULT_TICK_CONFIGURATION constant must be set to 1 if -the application writer wants to provide their own implementation of +the application writer wants to provide their own implementation of vPortSetupTimerInterrupt(). Ensure configOVERRIDE_DEFAULT_TICK_CONFIGURATION is defined. */ #ifndef configOVERRIDE_DEFAULT_TICK_CONFIGURATION @@ -127,7 +127,7 @@ static unsigned portBASE_TYPE uxCriticalNesting = 0xaaaaaaaa; /* * Setup the timer to generate the tick interrupts. The implementation in this - * file is weak to allow application writers to change the timer used to + * file is weak to allow application writers to change the timer used to * generate the tick interrupt. */ void vPortSetupTimerInterrupt( void ); @@ -382,7 +382,7 @@ void xPortSysTickHandler( void ) #endif /* Only reset the systick load register if configUSE_TICKLESS_IDLE is set to - 1. If it is set to 0 tickless idle is not being used. If it is set to a + 1. If it is set to 0 tickless idle is not being used. If it is set to a value other than 0 or 1 then a timer other than the SysTick is being used to generate the tick interrupt. */ #if configUSE_TICKLESS_IDLE == 1 @@ -402,6 +402,7 @@ void xPortSysTickHandler( void ) __weak void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime ) { unsigned long ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickIncrements; + portTickType xModifiableIdleTime; /* Make sure the SysTick reload value does not overflow the counter. */ if( xExpectedIdleTime > xMaximumPossibleSuppressedTicks ) @@ -447,9 +448,14 @@ void xPortSysTickHandler( void ) /* Restart SysTick. */ portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT; - /* Sleep until something happens. */ - configPRE_SLEEP_PROCESSING( xExpectedIdleTime ); - if( xExpectedIdleTime > 0 ) + /* Sleep until something happens. configPRE_SLEEP_PROCESSING() can + set its parameter to 0 to indicate that its implementation contains + its own wait for interrupt or wait for event instruction, and so wfi + should not be executed again. However, the original expected idle + time variable must remain unmodified, so a copy is taken. */ + xModifiableIdleTime = xExpectedIdleTime; + configPRE_SLEEP_PROCESSING( xModifiableIdleTime ); + if( xModifiableIdleTime > 0 ) { __wfi(); } @@ -513,7 +519,7 @@ void xPortSysTickHandler( void ) void vPortSetupTimerInterrupt( void ) { - /* Calculate the constants required to configure the tick interrupt. */ + /* Calculate the constants required to configure the tick interrupt. */ #if configUSE_TICKLESS_IDLE == 1 { ulTimerReloadValueForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; @@ -521,12 +527,12 @@ void xPortSysTickHandler( void ) ulStoppedTimerCompensation = 45UL / ( configCPU_CLOCK_HZ / configSYSTICK_CLOCK_HZ ); } #endif /* configUSE_TICKLESS_IDLE */ - + /* Configure SysTick to interrupt at the requested rate. */ portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;; portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT; } - + #endif /* configOVERRIDE_DEFAULT_TICK_CONFIGURATION */ /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/tasks.c b/FreeRTOS/Source/tasks.c index 56fc50507..ab95fbd68 100644 --- a/FreeRTOS/Source/tasks.c +++ b/FreeRTOS/Source/tasks.c @@ -620,7 +620,7 @@ tskTCB * pxNewTCB; prvAddTaskToReadyQueue( pxNewTCB ); xReturn = pdPASS; - portSETUP_TCB( pxNewTCB ); + portSETUP_TCB( pxNewTCB ); } taskEXIT_CRITICAL(); } @@ -840,9 +840,9 @@ tskTCB * pxNewTCB; #endif /*-----------------------------------------------------------*/ -#if ( INCLUDE_eTaskStateGet == 1 ) +#if ( INCLUDE_eTaskGetState == 1 ) - eTaskState eTaskStateGet( xTaskHandle pxTask ) + eTaskState eTaskGetState( xTaskHandle pxTask ) { eTaskState eReturn; xList *pxStateList; @@ -1322,10 +1322,10 @@ void vTaskSuspendAll( void ) #if ( configUSE_TICKLESS_IDLE != 0 ) - portTickType prvGetExpectedIdleTime( void ) + static portTickType prvGetExpectedIdleTime( void ) { portTickType xReturn; - + if( pxCurrentTCB->uxPriority > tskIDLE_PRIORITY ) { xReturn = 0; @@ -1341,7 +1341,7 @@ void vTaskSuspendAll( void ) { xReturn = xNextTaskUnblockTime - xTickCount; } - + return xReturn; } @@ -1638,14 +1638,14 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) /*----------------------------------------------------------*/ /* This conditional compilation should use inequality to 0, not equality to 1. -This is to ensure vTaskStepTick() is available when user defined low power mode +This is to ensure vTaskStepTick() is available when user defined low power mode implementations require configUSE_TICKLESS_IDLE to be set to a value other than 1. */ #if ( configUSE_TICKLESS_IDLE != 0 ) void vTaskStepTick( portTickType xTicksToJump ) { - configASSERT( xTicksToJump <= xNextTaskUnblockTime ); + configASSERT( ( xTickCount + xTicksToJump ) <= xNextTaskUnblockTime ); xTickCount += xTicksToJump; } @@ -1942,7 +1942,7 @@ portTickType xTimeToWake; /* Calculate the time at which the task should be woken if the event does not occur. This may overflow but this doesn't matter. */ xTimeToWake = xTickCount + xTicksToWait; - + traceTASK_DELAY_UNTIL(); prvAddCurrentTaskToDelayedList( xTimeToWake ); } @@ -2165,13 +2165,6 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) #if ( configUSE_TICKLESS_IDLE != 0 ) { portTickType xExpectedIdleTime; - /* If the expected idle time is 1 then the idle time would end at - the end of the current time slice. The idle time must be at least - 2 to ensure any pended ticks between this point and the tick being - stopped can be legitimately stepped over when the tick suppression - routines returns. */ - const portTickType xMinimumExpectedIdleTime = ( portTickType ) 2; - /* It is not desirable to suspend then resume the scheduler on each iteration of the idle task. Therefore, a preliminary test of the expected idle time is performed without the @@ -2179,7 +2172,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) valid. */ xExpectedIdleTime = prvGetExpectedIdleTime(); - if( xExpectedIdleTime >= xMinimumExpectedIdleTime ) + if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP ) { vTaskSuspendAll(); { @@ -2189,7 +2182,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) configASSERT( xNextTaskUnblockTime >= xTickCount ); xExpectedIdleTime = prvGetExpectedIdleTime(); - if( xExpectedIdleTime >= xMinimumExpectedIdleTime ) + if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP ) { portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ); }