]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/include/task.h
Rename DummyTCB_t to StaticTCB_t.
[freertos] / FreeRTOS / Source / include / task.h
index 7dd9f87acb03e0701f52a0520c2f44d171e554d9..1108d34212811f20ef8c7bb9415ece7572a2fc33 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.\r
     All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
@@ -8,7 +8,7 @@
 \r
     FreeRTOS is free software; you can redistribute it and/or modify it under\r
     the terms of the GNU General Public License (version 2) as published by the\r
-    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+    Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.\r
 \r
     ***************************************************************************\r
     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
@@ -85,10 +85,10 @@ extern "C" {
  * MACROS AND DEFINITIONS\r
  *----------------------------------------------------------*/\r
 \r
-#define tskKERNEL_VERSION_NUMBER "V8.2.1"\r
+#define tskKERNEL_VERSION_NUMBER "V8.2.3"\r
 #define tskKERNEL_VERSION_MAJOR 8\r
 #define tskKERNEL_VERSION_MINOR 2\r
-#define tskKERNEL_VERSION_BUILD 1\r
+#define tskKERNEL_VERSION_BUILD 3\r
 \r
 /**\r
  * task. h\r
@@ -128,6 +128,12 @@ typedef enum
        eSetValueWithoutOverwrite       /* Set the task's notification value if the previous value has been read by the task. */\r
 } eNotifyAction;\r
 \r
+/* For data hiding purposes. */\r
+typedef enum\r
+{\r
+       eNothing = 0\r
+} eDummy;\r
+\r
 /*\r
  * Used internally only.\r
  */\r
@@ -183,6 +189,65 @@ typedef enum
        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
+/* Value that can be assigned to the eNotifyState member of the TCB. */\r
+typedef enum\r
+{\r
+       eNotWaitingNotification = 0,\r
+       eWaitingNotification,\r
+       eNotified\r
+} eNotifyValue;\r
+\r
+/*\r
+ * FreeRTOS implements a strict data hiding policy, so the real task control\r
+ * block (TCB) structure is not accessible to the application code.  However, if\r
+ * the application writer wants to statically allocate a TCB then the size of\r
+ * the TCB needs to be know.  The dummy TCB structure below is used for this\r
+ * purpose.  Its size will allows match the size of the real TCB, no matter what\r
+ * the FreeRTOSConfig.h settings.\r
+ */\r
+typedef struct xDUMMY_TCB\r
+{\r
+       void                            *pxDummy1;\r
+       #if ( portUSING_MPU_WRAPPERS == 1 )\r
+               xMPU_SETTINGS   xDummy2;\r
+       #endif\r
+       ListItem_t                      xDummy3[ 2 ];\r
+       UBaseType_t                     uxDummy5;\r
+       void                            *pxDummy6;\r
+       uint8_t                         ucDummy7[ configMAX_TASK_NAME_LEN ];\r
+       #if ( portSTACK_GROWTH > 0 )\r
+               void                    *pxDummy8;\r
+       #endif\r
+       #if ( portCRITICAL_NESTING_IN_TCB == 1 )\r
+               UBaseType_t             uxDummy9;\r
+       #endif\r
+       #if ( configUSE_TRACE_FACILITY == 1 )\r
+               UBaseType_t             uxDummy10[ 2 ];\r
+       #endif\r
+       #if ( configUSE_MUTEXES == 1 )\r
+               UBaseType_t             uxDummy12[ 2 ];\r
+       #endif\r
+       #if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
+               void                    *pxDummy14;\r
+       #endif\r
+       #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )\r
+               void                    pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];\r
+       #endif\r
+       #if ( configGENERATE_RUN_TIME_STATS == 1 )\r
+               uint32_t                ulDummy16;\r
+       #endif\r
+       #if ( configUSE_NEWLIB_REENTRANT == 1 )\r
+               struct  _reent  xDummy17;\r
+       #endif\r
+       #if ( configUSE_TASK_NOTIFICATIONS == 1 )\r
+               uint32_t                ulDummy18;\r
+               eDummy                  eDummy19;\r
+       #endif\r
+       #if ( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+               UBaseType_t             uxDummy20;\r
+       #endif\r
+\r
+} DummyTCB_t;\r
 \r
 /**\r
  * Defines the priority used by the idle task.  This must not be modified.\r
@@ -342,7 +407,112 @@ is used in assert() statements. */
  * \defgroup xTaskCreate xTaskCreate\r
  * \ingroup Tasks\r
  */\r
-#define xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask ) xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), ( NULL ), ( NULL ) )\r
+#define xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask ) xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), ( NULL ), ( NULL ), ( NULL ) )\r
+\r
+/**\r
+ * task. h\r
+ *<pre>\r
+ BaseType_t xTaskCreateStatic(\r
+                                                         TaskFunction_t pvTaskCode,\r
+                                                         const char * const pcName,\r
+                                                         uint16_t usStackDepth,\r
+                                                         void *pvParameters,\r
+                                                         UBaseType_t uxPriority,\r
+                                                         TaskHandle_t *pvCreatedTask,\r
+                                                         StackType_t *pxStackBuffer,\r
+                                                         DummyTCB_t *pxTCBBuffer\r
+                                                 );</pre>\r
+ *\r
+ * Create a new task and add it to the list of tasks that are ready to run.\r
+ * If a task is created using xTaskCreate() then the stack and task control \r
+ * block (TCB) used by the task are allocated dynamically.  If a task is created\r
+ * using xTaskCreateStatic() then the application writer can optionally provide\r
+ * the buffers that will hold the task stack and TCB respectively.  \r
+ * xTaskCreateStatic() therefore allows tasks to be created without any dynamic\r
+ * memory allocation.\r
+ *\r
+ * @param pvTaskCode Pointer to the task entry function.  Tasks\r
+ * must be implemented to never return (i.e. continuous loop).\r
+ *\r
+ * @param pcName A descriptive name for the task.  This is mainly used to\r
+ * facilitate debugging.  The maximum length of the string is defined by \r
+ * configMAX_TASK_NAME_LEN in FreeRTOSConfig.h.\r
+ *\r
+ * @param usStackDepth The size of the task stack specified as the number of\r
+ * variables the stack can hold - not the number of bytes.  For example, if\r
+ * the stack is 32-bits wide and usStackDepth is defined as 100 then 400 bytes\r
+ * will be allocated for stack storage.\r
+ *\r
+ * @param pvParameters Pointer that will be used as the parameter for the task\r
+ * being created.\r
+ *\r
+ * @param uxPriority The priority at which the task will run.\r
+ *\r
+ * @param pvCreatedTask Used to pass back a handle by which the created task\r
+ * can be referenced.  Pass as NULL if the handle is not required.\r
+ *\r
+ * @param pxStackBuffer If pxStackBuffer is NULL then the stack used by the\r
+ * task will be allocated dynamically, just as if the task was created using\r
+ * xTaskCreate().  if pxStackBuffer is not NULL then it must point to a \r
+ * StackType_t array that has at least usStackDepth indexes - the array will\r
+ * then be used as the task's stack.\r
+ *\r
+ * @param pxTCBBuffer If pxTCBBuffer is NULL then the TCB (which is the\r
+ * structures used internally within FreeRTOS to hold information on the task)\r
+ * will be allocated dynamically, just as when xTaskCreate() is used.  If\r
+ * pxTCBBuffer is not NULL then it must point to a variable of type DummyTCB_T,\r
+ * which will then be used as the TCB of the task being created.\r
+ *\r
+ * @return pdPASS if the task was successfully created and added to a ready\r
+ * list, otherwise an error code defined in the file projdefs.h\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+\r
+ // Dimensions the buffer that the task being created will use as its stack.\r
+ // NOTE:  This is the number of words the stack will hold, not the number of\r
+ // bytes.  For example, if each stack item is 32-bits, and this is set to 100,\r
+ // then 400 bytes (100 * 32-bits) will be allocated.\r
+ #define STACK_SIZE 200\r
+\r
+ // Structure that will hold the TCB of the task being created.\r
+ DummyTCB_t xTCB;\r
+\r
+ // Buffer that the task being created will use as its stack.\r
+ StackType_t xStack[ STACK_SIZE ];\r
+   \r
+ // Task to be created.\r
+ void vTaskCode( void * pvParameters )\r
+ {\r
+        for( ;; )\r
+        {\r
+                // Task code goes here.\r
+        }\r
+ }\r
+\r
+ // Function that creates a task.\r
+ void vOtherFunction( void )\r
+ {\r
+ static uint8_t ucParameterToPass;\r
+ TaskHandle_t xHandle = NULL;\r
+\r
+        // Create the task without using any dynamic memory allocation.\r
+        xTaskCreate( vTaskCode,          // As per xTaskCreate() parameter.\r
+                                 "NAME",             // As per xTaskCreate() parameter.\r
+                                 STACK_SIZE,         // As per xTaskCreate() parameter.\r
+                                 &ucParameterToPass, // As per xTaskCreate() parameter. \r
+                                 tskIDLE_PRIORITY,   // As per xTaskCreate() parameter.\r
+                                 &xHandle,           // As per xTaskCreate() parameter.\r
+                                 xStack,             // Pointer to the buffer that the task being created will use as its stack.\r
+                                 &xTCB );            // Pointer to a structure in which the TCB of the task being created will be stored.\r
+ }\r
+   </pre>\r
+ * \defgroup xTaskCreateStatic xTaskCreateStatic\r
+ * \ingroup Tasks\r
+ */\r
+#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+       #define xTaskCreateStatic( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask, puxStackBuffer, pxDummyTCB ) xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), ( puxStackBuffer ), ( pxDummyTCB ), ( NULL ) )\r
+#endif\r
 \r
 /**\r
  * task. h\r
@@ -411,7 +581,7 @@ TaskHandle_t xHandle;
  * \defgroup xTaskCreateRestricted xTaskCreateRestricted\r
  * \ingroup Tasks\r
  */\r
-#define xTaskCreateRestricted( x, pxCreatedTask ) xTaskGenericCreate( ((x)->pvTaskCode), ((x)->pcName), ((x)->usStackDepth), ((x)->pvParameters), ((x)->uxPriority), (pxCreatedTask), ((x)->puxStackBuffer), ((x)->xRegions) )\r
+#define xTaskCreateRestricted( x, pxCreatedTask ) xTaskGenericCreate( ((x)->pvTaskCode), ((x)->pcName), ((x)->usStackDepth), ((x)->pvParameters), ((x)->uxPriority), (pxCreatedTask), ((x)->puxStackBuffer), ( NULL ), ((x)->xRegions) )\r
 \r
 /**\r
  * task. h\r
@@ -1812,6 +1982,22 @@ void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPri
  */\r
 uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
 \r
+/**\r
+ * task. h\r
+ * <PRE>BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );</pre>\r
+ *\r
+ * If the notification state of the task referenced by the handle xTask is\r
+ * eNotified, then set the task's notification state to eNotWaitingNotification.\r
+ * The task's notification value is not altered.  Set xTask to NULL to clear the\r
+ * notification state of the calling task.\r
+ *\r
+ * @return pdTRUE if the task's notification state was set to\r
+ * eNotWaitingNotification, otherwise pdFALSE.\r
+ * \defgroup xTaskNotifyStateClear xTaskNotifyStateClear\r
+ * \ingroup TaskNotifications\r
+ */\r
+BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );\r
+\r
 /*-----------------------------------------------------------\r
  * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES\r
  *----------------------------------------------------------*/\r
@@ -1967,7 +2153,7 @@ BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGE
  * Generic version of the task creation function which is in turn called by the\r
  * xTaskCreate() and xTaskCreateRestricted() macros.\r
  */\r
-BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask, StackType_t * const puxStackBuffer, const MemoryRegion_t * const xRegions ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask, StackType_t * const puxStackBuffer, DummyTCB_t * const pxTCBBuffer, const MemoryRegion_t * const xRegions ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
 \r
 /*\r
  * Get the uxTCBNumber assigned to the task referenced by the xTask parameter.\r