version. */\r
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1\r
\r
+#define configUSE_QUEUE_SETS 1\r
+\r
#endif /* FREERTOS_CONFIG_H */\r
#define INCLUDE_xQueueGetMutexHolder 0\r
#endif\r
\r
+#ifndef INCLUDE_xSemaphoreGetMutexHolder\r
+ #define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder\r
+#endif\r
+\r
#ifndef INCLUDE_pcTaskGetTaskName\r
#define INCLUDE_pcTaskGetTaskName 0\r
#endif\r
#define INCLUDE_uxTaskGetStackHighWaterMark 0\r
#endif\r
\r
-#ifndef INCLUDE_eTaskStateGet\r
- #define INCLUDE_eTaskStateGet 0\r
+#ifndef INCLUDE_eTaskGetState\r
+ #define INCLUDE_eTaskGetState 0\r
#endif\r
\r
#ifndef configUSE_RECURSIVE_MUTEXES\r
#define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime )\r
#endif\r
\r
+#ifndef configEXPECTED_IDLE_TIME_BEFORE_SLEEP\r
+ #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2\r
+#endif\r
+\r
+#if configEXPECTED_IDLE_TIME_BEFORE_SLEEP < 2\r
+ #error configEXPECTED_IDLE_TIME_BEFORE_SLEEP must not be less than 2\r
+#endif\r
+\r
#ifndef configUSE_TICKLESS_IDLE\r
#define configUSE_TICKLESS_IDLE 0\r
#endif\r
#define configPOST_SLEEP_PROCESSING( x )\r
#endif\r
\r
+/* For backward compatability. */\r
+#define eTaskStateGet eTaskGetState\r
+#define INCLUDE_eTaskStateGet INCLUDE_eTaskGetState\r
+\r
#endif /* INC_FREERTOS_H */\r
\r
#define vTaskDelay MPU_vTaskDelay\r
#define uxTaskPriorityGet MPU_uxTaskPriorityGet\r
#define vTaskPrioritySet MPU_vTaskPrioritySet\r
- #define eTaskStateGet MPU_eTaskStateGet\r
+ #define eTaskGetState MPU_eTaskGetState\r
#define vTaskSuspend MPU_vTaskSuspend\r
#define xTaskIsTaskSuspended MPU_xTaskIsTaskSuspended\r
#define vTaskResume MPU_vTaskResume\r
xMemoryRegion xRegions[ portNUM_CONFIGURABLE_REGIONS ];\r
} xTaskParameters;\r
\r
-/* Task states returned by eTaskStateGet. */\r
+/* Task states returned by eTaskGetState. */\r
typedef enum\r
{\r
eRunning = 0, /* A task is querying the state of itself, so must be running. */\r
\r
/**\r
* task. h\r
- * <pre>eTaskState eTaskStateGet( xTaskHandle pxTask );</pre>\r
+ * <pre>eTaskState eTaskGetState( xTaskHandle pxTask );</pre>\r
*\r
- * INCLUDE_eTaskStateGet must be defined as 1 for this function to be available.\r
+ * INCLUDE_eTaskGetState must be defined as 1 for this function to be available.\r
* See the configuration section for more information.\r
*\r
* Obtain the state of any task. States are encoded by the eTaskState \r
* state of the task might change between the function being called, and the\r
* functions return value being tested by the calling task.\r
*/\r
-eTaskState eTaskStateGet( xTaskHandle pxTask ) PRIVILEGED_FUNCTION;\r
+eTaskState eTaskGetState( xTaskHandle pxTask ) PRIVILEGED_FUNCTION;\r
\r
/**\r
* task. h\r
/*\r
FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
\r
- FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT \r
+ FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT\r
http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
\r
***************************************************************************\r
FreeRTOS WEB site.\r
\r
1 tab == 4 spaces!\r
- \r
+\r
***************************************************************************\r
* *\r
* Having a problem? Start by reading the FAQ "My application does *\r
* *\r
***************************************************************************\r
\r
- \r
- http://www.FreeRTOS.org - Documentation, training, latest versions, license \r
- and contact details. \r
- \r
+\r
+ http://www.FreeRTOS.org - Documentation, training, latest versions, license\r
+ and contact details.\r
+\r
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
including FreeRTOS+Trace - an indispensable productivity tool.\r
\r
- Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
- the code with commercial support, indemnification, and middleware, under \r
+ Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell\r
+ the code with commercial support, indemnification, and middleware, under\r
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also\r
- provide a safety engineered and independently SIL3 certified version under \r
+ provide a safety engineered and independently SIL3 certified version under\r
the SafeRTOS brand: http://www.SafeRTOS.com.\r
*/\r
\r
\r
/*\r
* Setup the timer to generate the tick interrupts. The implementation in this\r
- * file is weak to allow application writers to change the timer used to \r
+ * file is weak to allow application writers to change the timer used to\r
* generate the tick interrupt.\r
*/\r
void vPortSetupTimerInterrupt( void );\r
" bx lr \n" \\r
:::"r0" \\r
);\r
- \r
+\r
/* Just to avoid compiler warnings. */\r
( void ) ulNewMaskValue;\r
}\r
#endif\r
\r
/* Only reset the systick load register if configUSE_TICKLESS_IDLE is set to\r
- 1. If it is set to 0 tickless idle is not being used. If it is set to a \r
+ 1. If it is set to 0 tickless idle is not being used. If it is set to a\r
value other than 0 or 1 then a timer other than the SysTick is being used\r
to generate the tick interrupt. */\r
#if configUSE_TICKLESS_IDLE == 1\r
__attribute__((weak)) void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime )\r
{\r
unsigned long ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickIncrements;\r
+ portTickType xModifiableIdleTime;\r
\r
/* Make sure the SysTick reload value does not overflow the counter. */\r
if( xExpectedIdleTime > xMaximumPossibleSuppressedTicks )\r
/* Restart SysTick. */\r
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT;\r
\r
- /* Sleep until something happens. */\r
- configPRE_SLEEP_PROCESSING( xExpectedIdleTime );\r
- if( xExpectedIdleTime > 0 )\r
+ /* Sleep until something happens. configPRE_SLEEP_PROCESSING() can\r
+ set its parameter to 0 to indicate that its implementation contains\r
+ its own wait for interrupt or wait for event instruction, and so wfi\r
+ should not be executed again. However, the original expected idle\r
+ time variable must remain unmodified, so a copy is taken. */\r
+ xModifiableIdleTime = xExpectedIdleTime;\r
+ configPRE_SLEEP_PROCESSING( xModifiableIdleTime );\r
+ if( xModifiableIdleTime > 0 )\r
{\r
__asm volatile( "wfi" );\r
}\r
*/\r
__attribute__(( weak )) void vPortSetupTimerInterrupt( void )\r
{\r
- /* Calculate the constants required to configure the tick interrupt. */ \r
+ /* Calculate the constants required to configure the tick interrupt. */\r
#if configUSE_TICKLESS_IDLE == 1\r
{\r
ulTimerReloadValueForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
void MPU_vTaskDelay( portTickType xTicksToDelay );\r
unsigned portBASE_TYPE MPU_uxTaskPriorityGet( xTaskHandle pxTask );\r
void MPU_vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority );\r
-eTaskState MPU_eTaskStateGet( xTaskHandle pxTask );\r
+eTaskState MPU_eTaskGetState( xTaskHandle pxTask );\r
void MPU_vTaskSuspend( xTaskHandle pxTaskToSuspend );\r
signed portBASE_TYPE MPU_xTaskIsTaskSuspended( xTaskHandle xTask );\r
void MPU_vTaskResume( xTaskHandle pxTaskToResume );\r
/* Simulate the stack frame as it would be created by a context switch\r
interrupt. */\r
pxTopOfStack--; /* Offset added to account for the way the MCU uses the stack on entry/exit of interrupts. */\r
+ pxTopOfStack--; /* Offset added to ensure 8-byte alignment is maintained. */\r
*pxTopOfStack = portINITIAL_XPSR; /* xPSR */\r
pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* PC */\r
#endif\r
/*-----------------------------------------------------------*/\r
\r
-#if ( INCLUDE_eTaskStateGet == 1 )\r
- eTaskState MPU_eTaskStateGet( xTaskHandle pxTask )\r
+#if ( INCLUDE_eTaskGetState == 1 )\r
+ eTaskState MPU_eTaskGetState( xTaskHandle pxTask )\r
{\r
portBASE_TYPE xRunningPrivileged = prvRaisePrivilege();\r
eTaskState eReturn;\r
\r
- eReturn = eTaskStateGet( pxTask );\r
+ eReturn = eTaskGetState( pxTask );\r
portRESET_PRIVILEGE( xRunningPrivileged );\r
return eReturn;\r
}\r
/*\r
FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
\r
- FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT \r
+ FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT\r
http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
\r
***************************************************************************\r
FreeRTOS WEB site.\r
\r
1 tab == 4 spaces!\r
- \r
+\r
***************************************************************************\r
* *\r
* Having a problem? Start by reading the FAQ "My application does *\r
* *\r
***************************************************************************\r
\r
- \r
- http://www.FreeRTOS.org - Documentation, training, latest versions, license \r
- and contact details. \r
- \r
+\r
+ http://www.FreeRTOS.org - Documentation, training, latest versions, license\r
+ and contact details.\r
+\r
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
including FreeRTOS+Trace - an indispensable productivity tool.\r
\r
- Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
- the code with commercial support, indemnification, and middleware, under \r
+ Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell\r
+ the code with commercial support, indemnification, and middleware, under\r
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also\r
- provide a safety engineered and independently SIL3 certified version under \r
+ provide a safety engineered and independently SIL3 certified version under\r
the SafeRTOS brand: http://www.SafeRTOS.com.\r
*/\r
\r
\r
/*\r
* Setup the timer to generate the tick interrupts. The implementation in this\r
- * file is weak to allow application writers to change the timer used to \r
+ * file is weak to allow application writers to change the timer used to\r
* generate the tick interrupt.\r
*/\r
void vPortSetupTimerInterrupt( void );\r
#endif\r
\r
/* Only reset the systick load register if configUSE_TICKLESS_IDLE is set to\r
- 1. If it is set to 0 tickless idle is not being used. If it is set to a \r
+ 1. If it is set to 0 tickless idle is not being used. If it is set to a\r
value other than 0 or 1 then a timer other than the SysTick is being used\r
to generate the tick interrupt. */\r
#if configUSE_TICKLESS_IDLE == 1\r
__attribute__((weak)) void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime )\r
{\r
unsigned long ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickIncrements;\r
+ portTickType xModifiableIdleTime;\r
\r
/* Make sure the SysTick reload value does not overflow the counter. */\r
if( xExpectedIdleTime > xMaximumPossibleSuppressedTicks )\r
/* Restart SysTick. */\r
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT;\r
\r
- /* Sleep until something happens. */\r
- configPRE_SLEEP_PROCESSING( xExpectedIdleTime );\r
- if( xExpectedIdleTime > 0 )\r
+ /* Sleep until something happens. configPRE_SLEEP_PROCESSING() can\r
+ set its parameter to 0 to indicate that its implementation contains\r
+ its own wait for interrupt or wait for event instruction, and so wfi\r
+ should not be executed again. However, the original expected idle\r
+ time variable must remain unmodified, so a copy is taken. */\r
+ xModifiableIdleTime = xExpectedIdleTime;\r
+ configPRE_SLEEP_PROCESSING( xModifiableIdleTime );\r
+ if( xModifiableIdleTime > 0 )\r
{\r
__asm volatile( "wfi" );\r
}\r
*/\r
__attribute__(( weak )) void vPortSetupTimerInterrupt( void )\r
{\r
- /* Calculate the constants required to configure the tick interrupt. */ \r
+ /* Calculate the constants required to configure the tick interrupt. */\r
#if configUSE_TICKLESS_IDLE == 1\r
{\r
ulTimerReloadValueForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
__weak void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime )\r
{\r
unsigned long ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickIncrements;\r
+ portTickType xModifiableIdleTime;\r
\r
/* Make sure the SysTick reload value does not overflow the counter. */\r
if( xExpectedIdleTime > xMaximumPossibleSuppressedTicks )\r
/* Restart SysTick. */\r
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT;\r
\r
- /* Sleep until something happens. */\r
- configPRE_SLEEP_PROCESSING( xExpectedIdleTime );\r
- if( xExpectedIdleTime > 0 )\r
+ /* Sleep until something happens. configPRE_SLEEP_PROCESSING() can\r
+ set its parameter to 0 to indicate that its implementation contains\r
+ its own wait for interrupt or wait for event instruction, and so wfi\r
+ should not be executed again. However, the original expected idle\r
+ time variable must remain unmodified, so a copy is taken. */\r
+ xModifiableIdleTime = xExpectedIdleTime;\r
+ configPRE_SLEEP_PROCESSING( xModifiableIdleTime );\r
+ if( xModifiableIdleTime > 0 )\r
{\r
__WFI();\r
}\r
*/\r
__weak void vPortSetupTimerInterrupt( void )\r
{\r
- /* Calculate the constants required to configure the tick interrupt. */ \r
+ /* Calculate the constants required to configure the tick interrupt. */\r
#if configUSE_TICKLESS_IDLE == 1\r
{\r
ulTimerReloadValueForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
__weak void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime )\r
{\r
unsigned long ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickIncrements;\r
+ portTickType xModifiableIdleTime;\r
\r
/* Make sure the SysTick reload value does not overflow the counter. */\r
if( xExpectedIdleTime > xMaximumPossibleSuppressedTicks )\r
/* Restart SysTick. */\r
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT;\r
\r
- /* Sleep until something happens. */\r
- configPRE_SLEEP_PROCESSING( xExpectedIdleTime );\r
- if( xExpectedIdleTime > 0 )\r
+ /* Sleep until something happens. configPRE_SLEEP_PROCESSING() can\r
+ set its parameter to 0 to indicate that its implementation contains\r
+ its own wait for interrupt or wait for event instruction, and so wfi\r
+ should not be executed again. However, the original expected idle\r
+ time variable must remain unmodified, so a copy is taken. */\r
+ xModifiableIdleTime = xExpectedIdleTime;\r
+ configPRE_SLEEP_PROCESSING( xModifiableIdleTime );\r
+ if( xModifiableIdleTime > 0 )\r
{\r
__WFI();\r
}\r
/*\r
FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
\r
- FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT \r
+ FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT\r
http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
\r
***************************************************************************\r
FreeRTOS WEB site.\r
\r
1 tab == 4 spaces!\r
- \r
+\r
***************************************************************************\r
* *\r
* Having a problem? Start by reading the FAQ "My application does *\r
* *\r
***************************************************************************\r
\r
- \r
- http://www.FreeRTOS.org - Documentation, training, latest versions, license \r
- and contact details. \r
- \r
+\r
+ http://www.FreeRTOS.org - Documentation, training, latest versions, license\r
+ and contact details.\r
+\r
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
including FreeRTOS+Trace - an indispensable productivity tool.\r
\r
- Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
- the code with commercial support, indemnification, and middleware, under \r
+ Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell\r
+ the code with commercial support, indemnification, and middleware, under\r
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also\r
- provide a safety engineered and independently SIL3 certified version under \r
+ provide a safety engineered and independently SIL3 certified version under\r
the SafeRTOS brand: http://www.SafeRTOS.com.\r
*/\r
\r
\r
/* The __weak attribute does not work as you might expect with the Keil tools\r
so the configOVERRIDE_DEFAULT_TICK_CONFIGURATION constant must be set to 1 if\r
-the application writer wants to provide their own implementation of \r
+the application writer wants to provide their own implementation of\r
vPortSetupTimerInterrupt(). Ensure configOVERRIDE_DEFAULT_TICK_CONFIGURATION\r
is defined. */\r
#ifndef configOVERRIDE_DEFAULT_TICK_CONFIGURATION\r
\r
/*\r
* Setup the timer to generate the tick interrupts. The implementation in this\r
- * file is weak to allow application writers to change the timer used to \r
+ * file is weak to allow application writers to change the timer used to\r
* generate the tick interrupt.\r
*/\r
void vPortSetupTimerInterrupt( void );\r
#endif\r
\r
/* Only reset the systick load register if configUSE_TICKLESS_IDLE is set to\r
- 1. If it is set to 0 tickless idle is not being used. If it is set to a \r
+ 1. If it is set to 0 tickless idle is not being used. If it is set to a\r
value other than 0 or 1 then a timer other than the SysTick is being used\r
to generate the tick interrupt. */\r
#if configUSE_TICKLESS_IDLE == 1\r
__weak void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime )\r
{\r
unsigned long ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickIncrements;\r
+ portTickType xModifiableIdleTime;\r
\r
/* Make sure the SysTick reload value does not overflow the counter. */\r
if( xExpectedIdleTime > xMaximumPossibleSuppressedTicks )\r
/* Restart SysTick. */\r
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT;\r
\r
- /* Sleep until something happens. */\r
- configPRE_SLEEP_PROCESSING( xExpectedIdleTime );\r
- if( xExpectedIdleTime > 0 )\r
+ /* Sleep until something happens. configPRE_SLEEP_PROCESSING() can\r
+ set its parameter to 0 to indicate that its implementation contains\r
+ its own wait for interrupt or wait for event instruction, and so wfi\r
+ should not be executed again. However, the original expected idle\r
+ time variable must remain unmodified, so a copy is taken. */\r
+ xModifiableIdleTime = xExpectedIdleTime;\r
+ configPRE_SLEEP_PROCESSING( xModifiableIdleTime );\r
+ if( xModifiableIdleTime > 0 )\r
{\r
__wfi();\r
}\r
\r
void vPortSetupTimerInterrupt( void )\r
{\r
- /* Calculate the constants required to configure the tick interrupt. */ \r
+ /* Calculate the constants required to configure the tick interrupt. */\r
#if configUSE_TICKLESS_IDLE == 1\r
{\r
ulTimerReloadValueForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
ulStoppedTimerCompensation = 45UL / ( configCPU_CLOCK_HZ / configSYSTICK_CLOCK_HZ );\r
}\r
#endif /* configUSE_TICKLESS_IDLE */\r
- \r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;;\r
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT;\r
}\r
- \r
+\r
#endif /* configOVERRIDE_DEFAULT_TICK_CONFIGURATION */\r
/*-----------------------------------------------------------*/\r
\r
/*\r
FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
\r
- FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT \r
+ FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT\r
http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
\r
***************************************************************************\r
FreeRTOS WEB site.\r
\r
1 tab == 4 spaces!\r
- \r
+\r
***************************************************************************\r
* *\r
* Having a problem? Start by reading the FAQ "My application does *\r
* *\r
***************************************************************************\r
\r
- \r
- http://www.FreeRTOS.org - Documentation, training, latest versions, license \r
- and contact details. \r
- \r
+\r
+ http://www.FreeRTOS.org - Documentation, training, latest versions, license\r
+ and contact details.\r
+\r
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
including FreeRTOS+Trace - an indispensable productivity tool.\r
\r
- Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
- the code with commercial support, indemnification, and middleware, under \r
+ Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell\r
+ the code with commercial support, indemnification, and middleware, under\r
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also\r
- provide a safety engineered and independently SIL3 certified version under \r
+ provide a safety engineered and independently SIL3 certified version under\r
the SafeRTOS brand: http://www.SafeRTOS.com.\r
*/\r
\r
\r
/* The __weak attribute does not work as you might expect with the Keil tools\r
so the configOVERRIDE_DEFAULT_TICK_CONFIGURATION constant must be set to 1 if\r
-the application writer wants to provide their own implementation of \r
+the application writer wants to provide their own implementation of\r
vPortSetupTimerInterrupt(). Ensure configOVERRIDE_DEFAULT_TICK_CONFIGURATION\r
is defined. */\r
#ifndef configOVERRIDE_DEFAULT_TICK_CONFIGURATION\r
\r
/*\r
* Setup the timer to generate the tick interrupts. The implementation in this\r
- * file is weak to allow application writers to change the timer used to \r
+ * file is weak to allow application writers to change the timer used to\r
* generate the tick interrupt.\r
*/\r
void vPortSetupTimerInterrupt( void );\r
#endif\r
\r
/* Only reset the systick load register if configUSE_TICKLESS_IDLE is set to\r
- 1. If it is set to 0 tickless idle is not being used. If it is set to a \r
+ 1. If it is set to 0 tickless idle is not being used. If it is set to a\r
value other than 0 or 1 then a timer other than the SysTick is being used\r
to generate the tick interrupt. */\r
#if configUSE_TICKLESS_IDLE == 1\r
__weak void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime )\r
{\r
unsigned long ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickIncrements;\r
+ portTickType xModifiableIdleTime;\r
\r
/* Make sure the SysTick reload value does not overflow the counter. */\r
if( xExpectedIdleTime > xMaximumPossibleSuppressedTicks )\r
/* Restart SysTick. */\r
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT;\r
\r
- /* Sleep until something happens. */\r
- configPRE_SLEEP_PROCESSING( xExpectedIdleTime );\r
- if( xExpectedIdleTime > 0 )\r
+ /* Sleep until something happens. configPRE_SLEEP_PROCESSING() can\r
+ set its parameter to 0 to indicate that its implementation contains\r
+ its own wait for interrupt or wait for event instruction, and so wfi\r
+ should not be executed again. However, the original expected idle\r
+ time variable must remain unmodified, so a copy is taken. */\r
+ xModifiableIdleTime = xExpectedIdleTime;\r
+ configPRE_SLEEP_PROCESSING( xModifiableIdleTime );\r
+ if( xModifiableIdleTime > 0 )\r
{\r
__wfi();\r
}\r
\r
void vPortSetupTimerInterrupt( void )\r
{\r
- /* Calculate the constants required to configure the tick interrupt. */ \r
+ /* Calculate the constants required to configure the tick interrupt. */\r
#if configUSE_TICKLESS_IDLE == 1\r
{\r
ulTimerReloadValueForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
ulStoppedTimerCompensation = 45UL / ( configCPU_CLOCK_HZ / configSYSTICK_CLOCK_HZ );\r
}\r
#endif /* configUSE_TICKLESS_IDLE */\r
- \r
+\r
/* Configure SysTick to interrupt at the requested rate. */\r
portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;;\r
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT;\r
}\r
- \r
+\r
#endif /* configOVERRIDE_DEFAULT_TICK_CONFIGURATION */\r
/*-----------------------------------------------------------*/\r
\r
prvAddTaskToReadyQueue( pxNewTCB );\r
\r
xReturn = pdPASS;\r
- portSETUP_TCB( pxNewTCB ); \r
+ portSETUP_TCB( pxNewTCB );\r
}\r
taskEXIT_CRITICAL();\r
}\r
#endif\r
/*-----------------------------------------------------------*/\r
\r
-#if ( INCLUDE_eTaskStateGet == 1 )\r
+#if ( INCLUDE_eTaskGetState == 1 )\r
\r
- eTaskState eTaskStateGet( xTaskHandle pxTask )\r
+ eTaskState eTaskGetState( xTaskHandle pxTask )\r
{\r
eTaskState eReturn;\r
xList *pxStateList;\r
\r
#if ( configUSE_TICKLESS_IDLE != 0 )\r
\r
- portTickType prvGetExpectedIdleTime( void )\r
+ static portTickType prvGetExpectedIdleTime( void )\r
{\r
portTickType xReturn;\r
- \r
+\r
if( pxCurrentTCB->uxPriority > tskIDLE_PRIORITY )\r
{\r
xReturn = 0;\r
{\r
xReturn = xNextTaskUnblockTime - xTickCount;\r
}\r
- \r
+\r
return xReturn;\r
}\r
\r
/*----------------------------------------------------------*/\r
\r
/* This conditional compilation should use inequality to 0, not equality to 1.\r
-This is to ensure vTaskStepTick() is available when user defined low power mode \r
+This is to ensure vTaskStepTick() is available when user defined low power mode\r
implementations require configUSE_TICKLESS_IDLE to be set to a value other than\r
1. */\r
#if ( configUSE_TICKLESS_IDLE != 0 )\r
\r
void vTaskStepTick( portTickType xTicksToJump )\r
{\r
- configASSERT( xTicksToJump <= xNextTaskUnblockTime );\r
+ configASSERT( ( xTickCount + xTicksToJump ) <= xNextTaskUnblockTime );\r
xTickCount += xTicksToJump;\r
}\r
\r
/* Calculate the time at which the task should be woken if the event does\r
not occur. This may overflow but this doesn't matter. */\r
xTimeToWake = xTickCount + xTicksToWait;\r
- \r
+\r
traceTASK_DELAY_UNTIL();\r
prvAddCurrentTaskToDelayedList( xTimeToWake );\r
}\r
#if ( configUSE_TICKLESS_IDLE != 0 )\r
{\r
portTickType xExpectedIdleTime;\r
- /* If the expected idle time is 1 then the idle time would end at\r
- the end of the current time slice. The idle time must be at least\r
- 2 to ensure any pended ticks between this point and the tick being\r
- stopped can be legitimately stepped over when the tick suppression\r
- routines returns. */\r
- const portTickType xMinimumExpectedIdleTime = ( portTickType ) 2;\r
-\r
/* It is not desirable to suspend then resume the scheduler on\r
each iteration of the idle task. Therefore, a preliminary\r
test of the expected idle time is performed without the\r
valid. */\r
xExpectedIdleTime = prvGetExpectedIdleTime();\r
\r
- if( xExpectedIdleTime >= xMinimumExpectedIdleTime )\r
+ if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP )\r
{\r
vTaskSuspendAll();\r
{\r
configASSERT( xNextTaskUnblockTime >= xTickCount );\r
xExpectedIdleTime = prvGetExpectedIdleTime();\r
\r
- if( xExpectedIdleTime >= xMinimumExpectedIdleTime )\r
+ if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP )\r
{\r
portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime );\r
}\r