]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/include/task.h
Rename DummyTCB_t to StaticTCB_t.
[freertos] / FreeRTOS / Source / include / task.h
index f9af55730c2e59e6b045d20ae7883627de07023a..1108d34212811f20ef8c7bb9415ece7572a2fc33 100644 (file)
@@ -1,60 +1,64 @@
 /*\r
-    FreeRTOS V8.1.2 - Copyright (C) 2014 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
 \r
-    ***************************************************************************\r
-     *                                                                       *\r
-     *    FreeRTOS provides completely free yet professionally developed,    *\r
-     *    robust, strictly quality controlled, supported, and cross          *\r
-     *    platform software that has become a de facto standard.             *\r
-     *                                                                       *\r
-     *    Help yourself get started quickly and support the FreeRTOS         *\r
-     *    project by purchasing a FreeRTOS tutorial book, reference          *\r
-     *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
-     *                                                                       *\r
-     *    Thank you!                                                         *\r
-     *                                                                       *\r
-    ***************************************************************************\r
-\r
     This file is part of the FreeRTOS distribution.\r
 \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
     >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
     >>!   obliged to provide the source code for proprietary components     !<<\r
     >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
 \r
     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
-    FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
     link: http://www.freertos.org/a00114.html\r
 \r
-    1 tab == 4 spaces!\r
-\r
     ***************************************************************************\r
      *                                                                       *\r
-     *    Having a problem?  Start by reading the FAQ "My application does   *\r
-     *    not run, what could be wrong?"                                     *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
      *                                                                       *\r
-     *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
      *                                                                       *\r
     ***************************************************************************\r
 \r
-    http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
-    license and Real Time Engineers Ltd. contact details.\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
 \r
     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
 \r
-    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
-    Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
-    licenses offer ticketed support, indemnification and middleware.\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
 \r
     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
     engineered and independently SIL3 certified version for use in safety and\r
@@ -81,10 +85,10 @@ extern "C" {
  * MACROS AND DEFINITIONS\r
  *----------------------------------------------------------*/\r
 \r
-#define tskKERNEL_VERSION_NUMBER "V8.1.2"\r
+#define tskKERNEL_VERSION_NUMBER "V8.2.3"\r
 #define tskKERNEL_VERSION_MAJOR 8\r
-#define tskKERNEL_VERSION_MINOR 1\r
-#define tskKERNEL_VERSION_BUILD 2\r
+#define tskKERNEL_VERSION_MINOR 2\r
+#define tskKERNEL_VERSION_BUILD 3\r
 \r
 /**\r
  * task. h\r
@@ -117,13 +121,19 @@ typedef enum
 /* Actions that can be performed when vTaskNotify() is called. */\r
 typedef enum\r
 {\r
-       eNoAction,                                      /* Notify the task without updating its notify value. */\r
+       eNoAction = 0,                          /* Notify the task without updating its notify value. */\r
        eSetBits,                                       /* Set bits in the task's notification value. */\r
        eIncrement,                                     /* Increment the task's notification value. */\r
        eSetValueWithOverwrite,         /* Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */\r
        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
@@ -179,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
@@ -210,6 +279,7 @@ typedef enum
  * \ingroup SchedulerControl\r
  */\r
 #define taskENTER_CRITICAL()           portENTER_CRITICAL()\r
+#define taskENTER_CRITICAL_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()\r
 \r
 /**\r
  * task. h\r
@@ -224,7 +294,7 @@ typedef enum
  * \ingroup SchedulerControl\r
  */\r
 #define taskEXIT_CRITICAL()                    portEXIT_CRITICAL()\r
-\r
+#define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x )\r
 /**\r
  * task. h\r
  *\r
@@ -337,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
@@ -406,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
@@ -1154,6 +1329,18 @@ constant. */
        #endif /* configUSE_APPLICATION_TASK_TAG ==1 */\r
 #endif /* ifdef configUSE_APPLICATION_TASK_TAG */\r
 \r
+#if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )\r
+\r
+       /* Each task contains an array of pointers that is dimensioned by the\r
+       configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h.  The\r
+       kernel does not use the pointers itself, so the application writer can use\r
+       the pointers for any purpose they wish.  The following two functions are\r
+       used to set and query a pointer respectively. */\r
+       void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ) PRIVILEGED_FUNCTION;\r
+       void *pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) PRIVILEGED_FUNCTION;\r
+\r
+#endif\r
+\r
 /**\r
  * task.h\r
  * <pre>BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );</pre>\r
@@ -1174,7 +1361,7 @@ BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter )
  * Simply returns the handle of the idle task.  It is not valid to call\r
  * xTaskGetIdleTaskHandle() before the scheduler has been started.\r
  */\r
-TaskHandle_t xTaskGetIdleTaskHandle( void );\r
+TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for\r
@@ -1273,7 +1460,7 @@ TaskHandle_t xTaskGetIdleTaskHandle( void );
        }\r
        </pre>\r
  */\r
-UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime );\r
+UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
@@ -1380,8 +1567,8 @@ void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e9
  * task. h\r
  * <PRE>BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );</PRE>\r
  *\r
- * configUSE_TASK_NOTIFICATIONS must be defined as 1 for this function to be\r
- * available.\r
+ * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this\r
+ * function to be available.\r
  *\r
  * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private\r
  * "notification value", which is a 32-bit unsigned integer (uint32_t).\r
@@ -1403,14 +1590,11 @@ void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e9
  * (unblocked) and the notification cleared.\r
  *\r
  * A task can use xTaskNotifyWait() to [optionally] block to wait for a\r
- * notification to be pending, or xTaskNotifyTake() to [optionally] block\r
+ * notification to be pending, or ulTaskNotifyTake() to [optionally] block\r
  * to wait for its notification value to have a non-zero value.  The task does\r
  * not consume any CPU time while it is in the Blocked state.\r
  *\r
- * See http://www.FreeRTOS.org/RTOS_task_notifications.html for details of when\r
- * it is best to use a task notification to send an event to a task compared to\r
- * when it is best to use an intermediary object (such as a queue, semaphore,\r
- * mutex or event group) to send an event to a task.\r
+ * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.\r
  *\r
  * @param xTaskToNotify The handle of the task being notified.  The handle to a\r
  * task can be returned from the xTaskCreate() API function used to create the\r
@@ -1423,30 +1607,34 @@ void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e9
  * @param eAction Specifies how the notification updates the task's notification\r
  * value, if at all.  Valid values for eAction are as follows:\r
  *\r
- *     eSetBits -\r
- *     The task's notification value is bitwise ORed with ulValue.  xTaskNofify()\r
- *     always returns pdPASS in this case.\r
+ * eSetBits -\r
+ * The task's notification value is bitwise ORed with ulValue.  xTaskNofify()\r
+ * always returns pdPASS in this case.\r
  *\r
- *     eIncrement -\r
- *     The task's notification value is incremented.  ulValue is not used and\r
- *     xTaskNotify() always returns pdPASS in this case.\r
+ * eIncrement -\r
+ * The task's notification value is incremented.  ulValue is not used and\r
+ * xTaskNotify() always returns pdPASS in this case.\r
  *\r
- *     eSetValueWithOverwrite -\r
- *     The task's notification value is set to the value of ulValue, even if the\r
- *     task being notified had not yet processed the previous notification (the\r
- *     task already had a notification pending).  xTaskNotify() always returns\r
- *     pdPASS in this case.\r
+ * eSetValueWithOverwrite -\r
+ * The task's notification value is set to the value of ulValue, even if the\r
+ * task being notified had not yet processed the previous notification (the\r
+ * task already had a notification pending).  xTaskNotify() always returns\r
+ * pdPASS in this case.\r
  *\r
- *     eSetValueWithoutOverwrite -\r
- *     If the task being notified did not already have a notification pending then\r
- *     the task's notification value is set to ulValue and xTaskNotify() will\r
- *     return pdPASS.  If the task being notified already had a notification\r
- *     pending then no action is performed and pdFAIL is returned.\r
+ * eSetValueWithoutOverwrite -\r
+ * If the task being notified did not already have a notification pending then\r
+ * the task's notification value is set to ulValue and xTaskNotify() will\r
+ * return pdPASS.  If the task being notified already had a notification\r
+ * pending then no action is performed and pdFAIL is returned.\r
  *\r
- *     eNoAction -\r
- *     The task receives a notification without its notification value being\r
- *     updated.  ulValue is not used and xTaskNotify() always returns pdPASS in\r
- *     this case.\r
+ * eNoAction -\r
+ * The task receives a notification without its notification value being\r
+ * updated.  ulValue is not used and xTaskNotify() always returns pdPASS in\r
+ * this case.\r
+ *\r
+ *  pulPreviousNotificationValue -\r
+ *  Can be used to pass out the subject task's notification value before any\r
+ *  bits are modified by the notify function.\r
  *\r
  * @return Dependent on the value of eAction.  See the description of the\r
  * eAction parameter.\r
@@ -1454,14 +1642,16 @@ void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e9
  * \defgroup xTaskNotify xTaskNotify\r
  * \ingroup TaskNotifications\r
  */\r
-BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );\r
+BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) PRIVILEGED_FUNCTION;\r
+#define xTaskNotify( xTaskToNotify, ulValue, eAction ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL )\r
+#define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )\r
 \r
 /**\r
  * task. h\r
  * <PRE>BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );</PRE>\r
  *\r
- * configUSE_TASK_NOTIFICATIONS must be defined as 1 for this function to be\r
- * available.\r
+ * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this\r
+ * function to be available.\r
  *\r
  * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private\r
  * "notification value", which is a 32-bit unsigned integer (uint32_t).\r
@@ -1486,14 +1676,11 @@ BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAct
  * (unblocked) and the notification cleared.\r
  *\r
  * A task can use xTaskNotifyWait() to [optionally] block to wait for a\r
- * notification to be pending, or xTaskNotifyTake() to [optionally] block\r
+ * notification to be pending, or ulTaskNotifyTake() to [optionally] block\r
  * to wait for its notification value to have a non-zero value.  The task does\r
  * not consume any CPU time while it is in the Blocked state.\r
  *\r
- * See http://www.FreeRTOS.org/RTOS_task_notifications.html for details of when\r
- * it is best to use a task notification to send an event to a task compared to\r
- * when it is best to use an intermediary object (such as a queue, semaphore,\r
- * mutex or event group) to send an event to a task.\r
+ * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.\r
  *\r
  * @param xTaskToNotify The handle of the task being notified.  The handle to a\r
  * task can be returned from the xTaskCreate() API function used to create the\r
@@ -1506,30 +1693,30 @@ BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAct
  * @param eAction Specifies how the notification updates the task's notification\r
  * value, if at all.  Valid values for eAction are as follows:\r
  *\r
- *     eSetBits -\r
- *     The task's notification value is bitwise ORed with ulValue.  xTaskNofify()\r
- *     always returns pdPASS in this case.\r
+ * eSetBits -\r
+ * The task's notification value is bitwise ORed with ulValue.  xTaskNofify()\r
+ * always returns pdPASS in this case.\r
  *\r
- *     eIncrement -\r
- *     The task's notification value is incremented.  ulValue is not used and\r
- *     xTaskNotify() always returns pdPASS in this case.\r
+ * eIncrement -\r
+ * The task's notification value is incremented.  ulValue is not used and\r
+ * xTaskNotify() always returns pdPASS in this case.\r
  *\r
- *     eSetValueWithOverwrite -\r
- *     The task's notification value is set to the value of ulValue, even if the\r
- *     task being notified had not yet processed the previous notification (the\r
- *     task already had a notification pending).  xTaskNotify() always returns\r
- *     pdPASS in this case.\r
+ * eSetValueWithOverwrite -\r
+ * The task's notification value is set to the value of ulValue, even if the\r
+ * task being notified had not yet processed the previous notification (the\r
+ * task already had a notification pending).  xTaskNotify() always returns\r
+ * pdPASS in this case.\r
  *\r
- *     eSetValueWithoutOverwrite -\r
- *     If the task being notified did not already have a notification pending then\r
- *     the task's notification value is set to ulValue and xTaskNotify() will\r
- *     return pdPASS.  If the task being notified already had a notification\r
- *     pending then no action is performed and pdFAIL is returned.\r
+ * eSetValueWithoutOverwrite -\r
+ * If the task being notified did not already have a notification pending then\r
+ * the task's notification value is set to ulValue and xTaskNotify() will\r
+ * return pdPASS.  If the task being notified already had a notification\r
+ * pending then no action is performed and pdFAIL is returned.\r
  *\r
- *     eNoAction -\r
- *     The task receives a notification without its notification value being\r
- *     updated.  ulValue is not used and xTaskNotify() always returns pdPASS in\r
- *     this case.\r
+ * eNoAction -\r
+ * The task receives a notification without its notification value being\r
+ * updated.  ulValue is not used and xTaskNotify() always returns pdPASS in\r
+ * this case.\r
  *\r
  * @param pxHigherPriorityTaskWoken  xTaskNotifyFromISR() will set\r
  * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the\r
@@ -1546,14 +1733,16 @@ BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAct
  * \defgroup xTaskNotify xTaskNotify\r
  * \ingroup TaskNotifications\r
  */\r
-BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );\r
+BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;\r
+#define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )\r
+#define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )\r
 \r
 /**\r
  * task. h\r
- * <PRE>BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, BaseType_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );</pre>\r
+ * <PRE>BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );</pre>\r
  *\r
- * configUSE_TASK_NOTIFICATIONS must be defined as 1 for this function to be\r
- * available.\r
+ * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this\r
+ * function to be available.\r
  *\r
  * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private\r
  * "notification value", which is a 32-bit unsigned integer (uint32_t).\r
@@ -1575,14 +1764,11 @@ BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo
  * (unblocked) and the notification cleared.\r
  *\r
  * A task can use xTaskNotifyWait() to [optionally] block to wait for a\r
- * notification to be pending, or xTaskNotifyTake() to [optionally] block\r
+ * notification to be pending, or ulTaskNotifyTake() to [optionally] block\r
  * to wait for its notification value to have a non-zero value.  The task does\r
  * not consume any CPU time while it is in the Blocked state.\r
  *\r
- * See http://www.FreeRTOS.org/RTOS_task_notifications.html for details of when\r
- * it is best to use a task notification to send an event to a task compared to\r
- * when it is best to use an intermediary object (such as a queue, semaphore,\r
- * mutex or event group) to send an event to a task.\r
+ * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.\r
  *\r
  * @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value\r
  * will be cleared in the calling task's notification value before the task\r
@@ -1624,14 +1810,14 @@ BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNo
  * \defgroup xTaskNotifyWait xTaskNotifyWait\r
  * \ingroup TaskNotifications\r
  */\r
-BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, BaseType_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );\r
+BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
- * <PRE>BaseType_t xTaskNotifyGive( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );\r
+ * <PRE>BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );</PRE>\r
  *\r
- * configUSE_TASK_NOTIFICATIONS must be defined as 1 for this macro to be\r
- * available.\r
+ * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro\r
+ * to be available.\r
  *\r
  * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private\r
  * "notification value", which is a 32-bit unsigned integer (uint32_t).\r
@@ -1657,7 +1843,7 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, BaseType_t ulBitsToCl
  * using the ulTaskNotificationTake() API function rather than the\r
  * xTaskNotifyWait() API function.\r
  *\r
- * See http://www.FreeRTOS.org/RTOS_task_notifications.html for more details.\r
+ * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details.\r
  *\r
  * @param xTaskToNotify The handle of the task being notified.  The handle to a\r
  * task can be returned from the xTaskCreate() API function used to create the\r
@@ -1670,14 +1856,14 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, BaseType_t ulBitsToCl
  * \defgroup xTaskNotifyGive xTaskNotifyGive\r
  * \ingroup TaskNotifications\r
  */\r
-#define xTaskNotifyGive( xTaskToNotify ) xTaskNotify( ( xTaskToNotify ), 0, eIncrement );\r
+#define xTaskNotifyGive( xTaskToNotify ) xTaskGenericNotify( ( xTaskToNotify ), ( 0 ), eIncrement, NULL )\r
 \r
 /**\r
  * task. h\r
- * <PRE>BaseType_t xTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );\r
+ * <PRE>void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );\r
  *\r
- * configUSE_TASK_NOTIFICATIONS must be defined as 1 for this macro to be\r
- * available.\r
+ * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro\r
+ * to be available.\r
  *\r
  * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private\r
  * "notification value", which is a 32-bit unsigned integer (uint32_t).\r
@@ -1695,47 +1881,44 @@ BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, BaseType_t ulBitsToCl
  * task notifications can be used to send data to a task, or be used as light\r
  * weight and fast binary or counting semaphores.\r
  *\r
- * xTaskNotifyGiveFromISR() is a helper macro intended for use when task\r
- * notifications are used as light weight and faster binary or counting\r
- * semaphore equivalents.  Actual FreeRTOS semaphores are given from an ISR\r
- * using the xSemaphoreGiveFromISR() API function, the equivalent action that\r
- * instead uses a task notification is xTaskNotifyGiveFromISR().\r
+ * vTaskNotifyGiveFromISR() is intended for use when task notifications are\r
+ * used as light weight and faster binary or counting semaphore equivalents.\r
+ * Actual FreeRTOS semaphores are given from an ISR using the\r
+ * xSemaphoreGiveFromISR() API function, the equivalent action that instead uses\r
+ * a task notification is vTaskNotifyGiveFromISR().\r
  *\r
  * When task notifications are being used as a binary or counting semaphore\r
  * equivalent then the task being notified should wait for the notification\r
  * using the ulTaskNotificationTake() API function rather than the\r
  * xTaskNotifyWait() API function.\r
  *\r
- * See http://www.FreeRTOS.org/RTOS_task_notifications.html for more details.\r
+ * See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details.\r
  *\r
  * @param xTaskToNotify The handle of the task being notified.  The handle to a\r
  * task can be returned from the xTaskCreate() API function used to create the\r
  * task, and the handle of the currently running task can be obtained by calling\r
  * xTaskGetCurrentTaskHandle().\r
  *\r
- * @param pxHigherPriorityTaskWoken  xTaskNotifyGiveFromISR() will set\r
+ * @param pxHigherPriorityTaskWoken  vTaskNotifyGiveFromISR() will set\r
  * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the\r
  * task to which the notification was sent to leave the Blocked state, and the\r
  * unblocked task has a priority higher than the currently running task.  If\r
- * xTaskNotifyGiveFromISR() sets this value to pdTRUE then a context switch\r
+ * vTaskNotifyGiveFromISR() sets this value to pdTRUE then a context switch\r
  * should be requested before the interrupt is exited.  How a context switch is\r
  * requested from an ISR is dependent on the port - see the documentation page\r
  * for the port in use.\r
  *\r
- * @return xTaskNotifyGiveFromISR() is a macro that calls xTaskNotifyFromISR()\r
- * with the eAction parameter set to eIncrement - so pdPASS is always returned.\r
- *\r
  * \defgroup xTaskNotifyWait xTaskNotifyWait\r
  * \ingroup TaskNotifications\r
  */\r
-BaseType_t xTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken );\r
+void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
  * <PRE>uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );</pre>\r
  *\r
- * configUSE_TASK_NOTIFICATIONS must be defined as 1 for this function to be\r
- * available.\r
+ * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this\r
+ * function to be available.\r
  *\r
  * When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private\r
  * "notification value", which is a 32-bit unsigned integer (uint32_t).\r
@@ -1754,30 +1937,27 @@ BaseType_t xTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHig
  * faster and lighter weight binary or counting semaphore alternative.  Actual\r
  * FreeRTOS semaphores are taken using the xSemaphoreTake() API function, the\r
  * equivalent action that instead uses a task notification is\r
- * xTaskNotifyTake().\r
+ * ulTaskNotifyTake().\r
  *\r
  * When a task is using its notification value as a binary or counting semaphore\r
  * other tasks should send notifications to it using the xTaskNotifyGive()\r
  * macro, or xTaskNotify() function with the eAction parameter set to\r
  * eIncrement.\r
  *\r
- * xTaskNotifyTake() can either clear the task's notification value to\r
+ * ulTaskNotifyTake() can either clear the task's notification value to\r
  * zero on exit, in which case the notification value acts like a binary\r
  * semaphore, or decrement the task's notification value on exit, in which case\r
  * the notification value acts like a counting semaphore.\r
  *\r
- * A task can use xTaskNotifyTake() to [optionally] block to wait for a\r
- * the tasks notification value to be non-zero.  The task does not consume any\r
+ * A task can use ulTaskNotifyTake() to [optionally] block to wait for a\r
+ * the task's notification value to be non-zero.  The task does not consume any\r
  * CPU time while it is in the Blocked state.\r
  *\r
  * Where as xTaskNotifyWait() will return when a notification is pending,\r
- * xTaskNotifyTake() will return when the task's notification value is\r
+ * ulTaskNotifyTake() will return when the task's notification value is\r
  * not zero.\r
  *\r
- * See http://www.FreeRTOS.org/RTOS_task_notifications.html for details of when\r
- * it is best to use a task notification to send an event to a task compared to\r
- * when it is best to use an intermediary object (such as a queue, semaphore,\r
- * mutex or event group) to send an event to a task.\r
+ * See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.\r
  *\r
  * @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's\r
  * notification value is decremented when the function exits.  In this way the\r
@@ -1789,7 +1969,7 @@ BaseType_t xTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHig
  * @param xTicksToWait The maximum amount of time that the task should wait in\r
  * the Blocked state for the task's notification value to be greater than zero,\r
  * should the count not already be greater than zero when\r
- * xTaskNotifyTake() was called.  The task will not consume any processing\r
+ * ulTaskNotifyTake() was called.  The task will not consume any processing\r
  * time while it is in the Blocked state.  This is specified in kernel ticks,\r
  * the macro pdMS_TO_TICSK( value_in_ms ) can be used to convert a time\r
  * specified in milliseconds to a time specified in ticks.\r
@@ -1800,7 +1980,23 @@ BaseType_t xTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHig
  * \defgroup ulTaskNotifyTake ulTaskNotifyTake\r
  * \ingroup TaskNotifications\r
  */\r
-uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );\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
@@ -1868,7 +2064,7 @@ void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xIte
  * indefinitely, whereas vTaskPlaceOnEventList() does.\r
  *\r
  */\r
-void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
+void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN\r
@@ -1957,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
@@ -2000,7 +2196,7 @@ eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;
  * For internal use only.  Increment the mutex held count when a mutex is\r
  * taken and return the handle of the task that has taken the mutex.\r
  */\r
-void *pvTaskIncrementMutexHeldCount( void );\r
+void *pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;\r
 \r
 #ifdef __cplusplus\r
 }\r