/*\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
#error Missing definition: INCLUDE_uxTaskPriorityGet should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.\r
#endif\r
\r
-#ifndef INCLUDE_vTaskDelete \r
+#ifndef INCLUDE_vTaskDelete\r
#error Missing definition: INCLUDE_vTaskDelete should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.\r
#endif\r
\r
-#ifndef INCLUDE_vTaskSuspend \r
+#ifndef INCLUDE_vTaskSuspend\r
#error Missing definition: INCLUDE_vTaskSuspend should be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.\r
#endif\r
\r
\r
#ifndef traceTASK_PRIORITY_DISINHERIT\r
/* Called when a task releases a mutex, the holding of which had resulted in\r
- the task inheriting the priority of a higher priority task. \r
+ the task inheriting the priority of a higher priority task.\r
pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the\r
mutex. uxOriginalPriority is the task's configured (base) priority. */\r
#define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority )\r
#define traceMOVED_TASK_TO_READY_STATE( pxTCB )\r
#endif\r
\r
-#ifndef traceQUEUE_CREATE \r
+#ifndef traceQUEUE_CREATE\r
#define traceQUEUE_CREATE( pxNewQueue )\r
#endif\r
\r
#define configPOST_SLEEP_PROCESSING( x )\r
#endif\r
\r
+#ifndef configUSE_QUEUE_SETS\r
+ #define configUSE_QUEUE_SETS 0\r
+#endif\r
+\r
/* For backward compatability. */\r
#define eTaskStateGet eTaskGetState\r
\r
\r
1 tab == 4 spaces!\r
\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 information, \r
+\r
+ http://www.FreeRTOS.org - Documentation, training, latest information,\r
license and contact details.\r
- \r
+\r
http://www.FreeRTOS.org/plus - 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
eDeleted /* The task being queried has been deleted, but its TCB has not yet been freed. */\r
} eTaskState;\r
\r
+/* Possible return values for eTaskConfirmSleepModeStatus(). */\r
+typedef enum\r
+{\r
+ eAbortSleep = 0, /* A task has been made ready or a context switch pended since portSUPPORESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */\r
+ eStandardSleep, /* Enter a sleep mode that will not last any longer than the expected idle time. */\r
+ 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. */\r
+} eSleepModeStatus;\r
+\r
+\r
/*\r
* Defines the priority used by the idle task. This must not be modified.\r
*\r
// the task, with appropriate access permissions. Different processors have\r
// different memory alignment requirements - refer to the FreeRTOS documentation\r
// for full information.\r
- { \r
+ {\r
// Base address Length Parameters\r
{ cReadWriteArray, 32, portMPU_REGION_READ_WRITE },\r
{ cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },\r
// ucOneKByte array. The other two of the maximum 3 definable regions are\r
// unused so set to zero.\r
static const xMemoryRegion xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =\r
-{ \r
+{\r
// Base address Length Parameters\r
{ ucOneKByte, 1024, portMPU_REGION_READ_WRITE },\r
{ 0, 0, 0 },\r
// for this purpose. NULL is used as the task handle to indicate that this\r
// function should modify the MPU regions of the calling task.\r
vTaskAllocateMPURegions( NULL, xAltRegions );\r
- \r
+\r
// Now the task can continue its function, but from this point on can only\r
// access its stack and the ucOneKByte array (unless any other statically\r
// defined or shared regions have been declared elsewhere).\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
+ * Obtain the state of any task. States are encoded by the eTaskState\r
* enumerated type.\r
*\r
* @param xTask Handle of the task to be queried.\r
portBASE_TYPE xTaskCallApplicationTaskHook( xTaskHandle xTask, void *pvParameter ) PRIVILEGED_FUNCTION;\r
\r
/**\r
- * xTaskGetIdleTaskHandle() is only available if \r
+ * xTaskGetIdleTaskHandle() is only available if\r
* INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.\r
*\r
* Simply returns the handle of the idle task. It is not valid to call\r
*/\r
unsigned portBASE_TYPE uxTaskGetTaskNumber( xTaskHandle xTask );\r
\r
-/* \r
+/*\r
* Set the uxTCBNumber of the task referenced by the xTask parameter to\r
* ucHandle.\r
*/\r
*/\r
void vTaskStepTick( portTickType xTicksToJump );\r
\r
+/*\r
+ * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port\r
+ * specific sleep function to determine if it is ok to proceed with the sleep,\r
+ * and if it is ok to proceed, if it is ok to sleep indefinitely.\r
+ *\r
+ * This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only\r
+ * called with the scheduler suspended, not from within a critical section. It\r
+ * is therefore possible for an interrupt to request a context switch between\r
+ * portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being\r
+ * entered. eTaskConfirmSleepModeStatus() should be called from a short\r
+ * critical section between the timer being stopped and the sleep mode being\r
+ * entered to ensure it is ok to proceed into the sleep mode.\r
+ */\r
+eSleepModeStatus eTaskConfirmSleepModeStatus( void );\r
+\r
#ifdef __cplusplus\r
}\r
#endif\r
configASSERT( pxQueue );\r
\r
traceQUEUE_DELETE( pxQueue );\r
- prvQueueUnregisterQueue( pxQueue );\r
+ #if ( configQUEUE_REGISTRY_SIZE > 0 )\r
+ {\r
+ prvQueueUnregisterQueue( pxQueue );\r
+ }\r
+ #endif\r
vPortFree( pxQueue->pcHead );\r
vPortFree( pxQueue );\r
}\r
\r
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
\r
+/* Sanity check the configuration. */\r
+#if configUSE_TICKLESS_IDLE != 0\r
+ #if INCLUDE_vTaskSuspend != 1\r
+ #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0\r
+ #endif /* INCLUDE_vTaskSuspend */\r
+#endif /* configUSE_TICKLESS_IDLE */\r
+\r
/*\r
* Defines the size, in words, of the stack allocated to the idle task.\r
*/\r
uxTopUsedPriority = pxNewTCB->uxPriority;\r
}\r
\r
+ uxTaskNumber++;\r
+\r
#if ( configUSE_TRACE_FACILITY == 1 )\r
{\r
/* Add a counter into the TCB for tracing only. */\r
pxNewTCB->uxTCBNumber = uxTaskNumber;\r
}\r
#endif /* configUSE_TRACE_FACILITY */\r
- uxTaskNumber++;\r
traceTASK_CREATE( pxNewTCB );\r
\r
prvAddTaskToReadyQueue( pxNewTCB );\r
/* Remember the ready list the task might be referenced from\r
before its uxPriority member is changed so the\r
taskRESET_READY_PRIORITY() macro can function correctly. */\r
- #if ( configUSE_PORT_OPTIMISED_TASK_SELECTION != 0 )\r
- {\r
- uxPriorityUsedOnEntry = pxTCB->uxPriority;\r
- }\r
- #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
+ uxPriorityUsedOnEntry = pxTCB->uxPriority;\r
\r
#if ( configUSE_MUTEXES == 1 )\r
{\r
}\r
else\r
{\r
- /* This line will only be reached if the kernel could not be started, \r
+ /* This line will only be reached if the kernel could not be started,\r
because there was not enough FreeRTOS heap to create the idle task\r
or the timer task. */\r
configASSERT( xReturn );\r
} /*lint !e715 pvParameters is not accessed but all task functions require the same prototype. */\r
/*-----------------------------------------------------------*/\r
\r
+#if configUSE_TICKLESS_IDLE != 0\r
+\r
+ eSleepModeStatus eTaskConfirmSleepModeStatus( void )\r
+ {\r
+ eSleepModeStatus eReturn = eStandardSleep;\r
+\r
+ if( listCURRENT_LIST_LENGTH( &xPendingReadyList ) != 0 )\r
+ {\r
+ /* A task was made ready while the scheduler was suspended. */\r
+ eReturn = eAbortSleep;\r
+ }\r
+ else if( xMissedYield != pdFALSE )\r
+ {\r
+ /* A yield was pended while the scheduler was suspended. */\r
+ eReturn = eAbortSleep;\r
+ }\r
+ else\r
+ {\r
+ #if configUSE_TIMERS == 0\r
+ {\r
+ /* The idle task exists in addition to the application tasks. */\r
+ const unsigned portBASE_TYPE uxNonApplicationTasks = 1;\r
+\r
+ /* If timers are not being used and all the tasks are in the\r
+ suspended list (which might mean they have an infinite block\r
+ time rather than actually being suspended) then it is safe to\r
+ turn all clocks off and just wait for external initerrupts. */\r
+ if( listCURRENT_LIST_LENGTH( &xSuspendedTasksList ) == ( uxCurrentNumberOfTasks - uxNonApplicationTasks ) )\r
+ {\r
+ eReturn = eNoTasksWaitingTimeout;\r
+ }\r
+ }\r
+ #endif /* configUSE_TIMERS */\r
+ }\r
+\r
+ return eReturn;\r
+ }\r
+#endif /* configUSE_TICKLESS_IDLE */\r
+/*-----------------------------------------------------------*/\r
+\r
static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed char * const pcName, unsigned portBASE_TYPE uxPriority, const xMemoryRegion * const xRegions, unsigned short usStackDepth )\r
{\r
/* Store the function name in the TCB. */\r
\r
vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), xRegions, NULL, 0 );\r
}\r
- \r
+\r
#endif /* portUSING_MPU_WRAPPERS */\r
/*-----------------------------------------------------------*/\r
\r
}\r
}\r
}\r
- } \r
+ }\r
\r
#endif /* portCRITICAL_NESTING_IN_TCB */\r
/*-----------------------------------------------------------*/\r