]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/include/task.h
Fix spelling issues.
[freertos] / FreeRTOS / Source / include / task.h
index 54c93a34dcdcdccf9426e61450e2264785941c7f..1ee178ad97037cabe7e230a0276f1e64a92eb1dc 100644 (file)
@@ -1,71 +1,29 @@
 /*\r
-    FreeRTOS V9.0.0 - Copyright (C) 2016 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
-    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
-\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 on the following\r
-    link: http://www.freertos.org/a00114.html\r
-\r
-    ***************************************************************************\r
-     *                                                                       *\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
-     *    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/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.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
-    mission critical applications that require provable dependability.\r
-\r
-    1 tab == 4 spaces!\r
-*/\r
+ * FreeRTOS Kernel V10.2.1\r
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+ * this software and associated documentation files (the "Software"), to deal in\r
+ * the Software without restriction, including without limitation the rights to\r
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
+ * the Software, and to permit persons to whom the Software is furnished to do so,\r
+ * subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included in all\r
+ * copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ *\r
+ * http://www.FreeRTOS.org\r
+ * http://aws.amazon.com/freertos\r
+ *\r
+ * 1 tab == 4 spaces!\r
+ */\r
 \r
 \r
 #ifndef INC_TASK_H\r
@@ -85,10 +43,18 @@ extern "C" {
  * MACROS AND DEFINITIONS\r
  *----------------------------------------------------------*/\r
 \r
-#define tskKERNEL_VERSION_NUMBER "V9.0.0"\r
-#define tskKERNEL_VERSION_MAJOR 9\r
-#define tskKERNEL_VERSION_MINOR 0\r
-#define tskKERNEL_VERSION_BUILD 0\r
+#define tskKERNEL_VERSION_NUMBER "V10.2.1"\r
+#define tskKERNEL_VERSION_MAJOR 10\r
+#define tskKERNEL_VERSION_MINOR 2\r
+#define tskKERNEL_VERSION_BUILD 1\r
+\r
+/* MPU region parameters passed in ulParameters\r
+ * of MemoryRegion_t struct. */\r
+#define tskMPU_REGION_READ_ONLY                        ( 1UL << 0UL )\r
+#define tskMPU_REGION_READ_WRITE               ( 1UL << 1UL )\r
+#define tskMPU_REGION_EXECUTE_NEVER            ( 1UL << 2UL )\r
+#define tskMPU_REGION_NORMAL_MEMORY            ( 1UL << 3UL )\r
+#define tskMPU_REGION_DEVICE_MEMORY            ( 1UL << 4UL )\r
 \r
 /**\r
  * task. h\r
@@ -100,7 +66,8 @@ extern "C" {
  * \defgroup TaskHandle_t TaskHandle_t\r
  * \ingroup Tasks\r
  */\r
-typedef void * TaskHandle_t;\r
+struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */\r
+typedef struct tskTaskControlBlock* TaskHandle_t;\r
 \r
 /*\r
  * Defines the prototype to which the application task hook function must\r
@@ -116,7 +83,7 @@ typedef enum
        eBlocked,               /* The task being queried is in the Blocked state. */\r
        eSuspended,             /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */\r
        eDeleted,               /* The task being queried has been deleted, but its TCB has not yet been freed. */\r
-       eInvalid                        /* Used as an 'invalid state' value. */\r
+       eInvalid                /* Used as an 'invalid state' value. */\r
 } eTaskState;\r
 \r
 /* Actions that can be performed when vTaskNotify() is called. */\r
@@ -155,7 +122,7 @@ typedef struct xTASK_PARAMETERS
 {\r
        TaskFunction_t pvTaskCode;\r
        const char * const pcName;      /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
-       uint16_t usStackDepth;\r
+       configSTACK_DEPTH_TYPE usStackDepth;\r
        void *pvParameters;\r
        UBaseType_t uxPriority;\r
        StackType_t *puxStackBuffer;\r
@@ -177,7 +144,7 @@ typedef struct xTASK_STATUS
        UBaseType_t uxBasePriority;             /* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex.  Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */\r
        uint32_t ulRunTimeCounter;              /* The total run time allocated to the task so far, as defined by the run time stats clock.  See http://www.freertos.org/rtos-run-time-stats.html.  Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */\r
        StackType_t *pxStackBase;               /* Points to the lowest address of the task's stack area. */\r
-       uint16_t usStackHighWaterMark;  /* The minimum amount of stack space that has remained for the task since the task was created.  The closer this value is to zero the closer the task has come to overflowing its stack. */\r
+       configSTACK_DEPTH_TYPE usStackHighWaterMark;    /* The minimum amount of stack space that has remained for the task since the task was created.  The closer this value is to zero the closer the task has come to overflowing its stack. */\r
 } TaskStatus_t;\r
 \r
 /* Possible return values for eTaskConfirmSleepModeStatus(). */\r
@@ -347,13 +314,13 @@ is used in assert() statements. */
         // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time\r
         // the new task attempts to access it.\r
         xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );\r
-     configASSERT( xHandle );\r
+        configASSERT( xHandle );\r
 \r
         // Use the handle to delete the task.\r
-     if( xHandle != NULL )\r
-     {\r
-            vTaskDelete( xHandle );\r
-     }\r
+        if( xHandle != NULL )\r
+        {\r
+               vTaskDelete( xHandle );\r
+        }\r
  }\r
    </pre>\r
  * \defgroup xTaskCreate xTaskCreate\r
@@ -417,9 +384,9 @@ is used in assert() statements. */
  * memory to be allocated dynamically.\r
  *\r
  * @return If neither pxStackBuffer or pxTaskBuffer are NULL, then the task will\r
- * be created and pdPASS is returned.  If either pxStackBuffer or pxTaskBuffer\r
- * are NULL then the task will not be created and\r
- * errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY is returned.\r
+ * be created and a handle to the created task is returned.  If either\r
+ * pxStackBuffer or pxTaskBuffer are NULL then the task will not be created and\r
+ * NULL is returned.\r
  *\r
  * Example usage:\r
    <pre>\r
@@ -531,9 +498,9 @@ static const TaskParameters_t xCheckTaskParameters =
        // for full information.\r
        {\r
                // Base address                                 Length  Parameters\r
-        { cReadWriteArray,                             32,             portMPU_REGION_READ_WRITE },\r
-        { cReadOnlyArray,                              32,             portMPU_REGION_READ_ONLY },\r
-        { cPrivilegedOnlyAccessArray,  128,    portMPU_REGION_PRIVILEGED_READ_WRITE }\r
+               { cReadWriteArray,                              32,             portMPU_REGION_READ_WRITE },\r
+               { cReadOnlyArray,                               32,             portMPU_REGION_READ_ONLY },\r
+               { cPrivilegedOnlyAccessArray,   128,    portMPU_REGION_PRIVILEGED_READ_WRITE }\r
        }\r
 };\r
 \r
@@ -617,9 +584,9 @@ static const TaskParameters_t xCheckTaskParameters =
        // for full information.\r
        {\r
                // Base address                                 Length  Parameters\r
-        { cReadWriteArray,                             32,             portMPU_REGION_READ_WRITE },\r
-        { cReadOnlyArray,                              32,             portMPU_REGION_READ_ONLY },\r
-        { cPrivilegedOnlyAccessArray,  128,    portMPU_REGION_PRIVILEGED_READ_WRITE }\r
+               { cReadWriteArray,                              32,             portMPU_REGION_READ_WRITE },\r
+               { cReadOnlyArray,                               32,             portMPU_REGION_READ_ONLY },\r
+               { cPrivilegedOnlyAccessArray,   128,    portMPU_REGION_PRIVILEGED_READ_WRITE }\r
        }\r
 \r
        &xTaskBuffer; // Holds the task's data structure.\r
@@ -864,6 +831,11 @@ void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xT
  * task will leave the Blocked state, and return from whichever function call\r
  * placed the task into the Blocked state.\r
  *\r
+ * There is no 'FromISR' version of this function as an interrupt would need to\r
+ * know which object a task was blocked on in order to know which actions to\r
+ * take.  For example, if the task was blocked on a queue the interrupt handler\r
+ * would then need to know if the queue was locked.\r
+ *\r
  * @param xTask The handle of the task to remove from the Blocked state.\r
  *\r
  * @return If the task referenced by xTask was not in the Blocked state then\r
@@ -876,7 +848,7 @@ BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
 \r
 /**\r
  * task. h\r
- * <pre>UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask );</pre>\r
+ * <pre>UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask );</pre>\r
  *\r
  * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available.\r
  * See the configuration section for more information.\r
@@ -919,15 +891,15 @@ BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
  * \defgroup uxTaskPriorityGet uxTaskPriorityGet\r
  * \ingroup TaskCtrl\r
  */\r
-UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
+UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
- * <pre>UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask );</pre>\r
+ * <pre>UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask );</pre>\r
  *\r
  * A version of uxTaskPriorityGet() that can be used from an ISR.\r
  */\r
-UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
+UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
@@ -1454,6 +1426,12 @@ TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) PRIVILEGED_FUNCTION; /*
  * a value of 1 means 4 bytes) since the task started.  The smaller the returned\r
  * number the closer the task has come to overflowing its stack.\r
  *\r
+ * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the\r
+ * same except for their return type.  Using configSTACK_DEPTH_TYPE allows the\r
+ * user to determine the return type.  It gets around the problem of the value\r
+ * overflowing on 8-bit types without breaking backward compatibility for\r
+ * applications that expect an 8-bit return type.\r
+ *\r
  * @param xTask Handle of the task associated with the stack to be checked.\r
  * Set xTask to NULL to check the stack of the calling task.\r
  *\r
@@ -1463,6 +1441,33 @@ TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) PRIVILEGED_FUNCTION; /*
  */\r
 UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
 \r
+/**\r
+ * task.h\r
+ * <PRE>configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask );</PRE>\r
+ *\r
+ * INCLUDE_uxTaskGetStackHighWaterMark2 must be set to 1 in FreeRTOSConfig.h for\r
+ * this function to be available.\r
+ *\r
+ * Returns the high water mark of the stack associated with xTask.  That is,\r
+ * the minimum free stack space there has been (in words, so on a 32 bit machine\r
+ * a value of 1 means 4 bytes) since the task started.  The smaller the returned\r
+ * number the closer the task has come to overflowing its stack.\r
+ *\r
+ * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the\r
+ * same except for their return type.  Using configSTACK_DEPTH_TYPE allows the\r
+ * user to determine the return type.  It gets around the problem of the value\r
+ * overflowing on 8-bit types without breaking backward compatibility for\r
+ * applications that expect an 8-bit return type.\r
+ *\r
+ * @param xTask Handle of the task associated with the stack to be checked.\r
+ * Set xTask to NULL to check the stack of the calling task.\r
+ *\r
+ * @return The smallest amount of free stack space there has been (in words, so\r
+ * actual spaces on the stack rather than bytes) since the task referenced by\r
+ * xTask was created.\r
+ */\r
+configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
+\r
 /* When using trace macros it is sometimes necessary to include task.h before\r
 FreeRTOS.h.  When this is done TaskHookFunction_t will not yet have been defined,\r
 so the following two prototypes will cause a compilation error.  This can be\r
@@ -1485,9 +1490,20 @@ constant. */
                 * task.h\r
                 * <pre>void xTaskGetApplicationTaskTag( TaskHandle_t xTask );</pre>\r
                 *\r
-                * Returns the pxHookFunction value assigned to the task xTask.\r
+                * Returns the pxHookFunction value assigned to the task xTask.  Do not\r
+                * call from an interrupt service routine - call\r
+                * xTaskGetApplicationTaskTagFromISR() instead.\r
                 */\r
                TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
+\r
+               /**\r
+                * task.h\r
+                * <pre>void xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );</pre>\r
+                *\r
+                * Returns the pxHookFunction value assigned to the task xTask.  Can\r
+                * be called from an interrupt service routine.\r
+                */\r
+               TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
        #endif /* configUSE_APPLICATION_TASK_TAG ==1 */\r
 #endif /* ifdef configUSE_APPLICATION_TASK_TAG */\r
 \r
@@ -1725,6 +1741,36 @@ void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unquali
  */\r
 void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
 \r
+/**\r
+* task. h\r
+* <PRE>uint32_t ulTaskGetIdleRunTimeCounter( void );</PRE>\r
+*\r
+* configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS\r
+* must both be defined as 1 for this function to be available.  The application\r
+* must also then provide definitions for\r
+* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()\r
+* to configure a peripheral timer/counter and return the timers current count\r
+* value respectively.  The counter should be at least 10 times the frequency of\r
+* the tick count.\r
+*\r
+* Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total\r
+* accumulated execution time being stored for each task.  The resolution\r
+* of the accumulated time value depends on the frequency of the timer\r
+* configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.\r
+* While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total\r
+* execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter()\r
+* returns the total execution time of just the idle task.\r
+*\r
+* @return The total run time of the idle task.  This is the amount of time the\r
+* idle task has actually been executing.  The unit of time is dependent on the\r
+* frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and\r
+* portGET_RUN_TIME_COUNTER_VALUE() macros.\r
+*\r
+* \defgroup ulTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter\r
+* \ingroup TaskUtils\r
+*/\r
+uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION;\r
+\r
 /**\r
  * task. h\r
  * <PRE>BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );</PRE>\r
@@ -2160,6 +2206,121 @@ uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait
  */\r
 BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );\r
 \r
+/**\r
+* task. h\r
+* <PRE>uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear );</pre>\r
+*\r
+* Clears the bits specified by the ulBitsToClear bit mask in the notification\r
+* value of the task referenced by xTask.\r
+*\r
+* Set ulBitsToClear to 0xffffffff (UINT_MAX on 32-bit architectures) to clear\r
+* the notification value to 0.  Set ulBitsToClear to 0 to query the task's\r
+* notification value without clearing any bits.\r
+*\r
+* @return The value of the target task's notification value before the bits\r
+* specified by ulBitsToClear were cleared.\r
+* \defgroup ulTaskNotifyValueClear ulTaskNotifyValueClear\r
+* \ingroup TaskNotifications\r
+*/\r
+uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task.h\r
+ * <pre>void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut )</pre>\r
+ *\r
+ * Capture the current time for future use with xTaskCheckForTimeOut().\r
+ *\r
+ * @param pxTimeOut Pointer to a timeout object into which the current time\r
+ * is to be captured.  The captured time includes the tick count and the number\r
+ * of times the tick count has overflowed since the system first booted.\r
+ * \defgroup vTaskSetTimeOutState vTaskSetTimeOutState\r
+ * \ingroup TaskCtrl\r
+ */\r
+void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task.h\r
+ * <pre>BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait );</pre>\r
+ *\r
+ * Determines if pxTicksToWait ticks has passed since a time was captured\r
+ * using a call to vTaskSetTimeOutState().  The captured time includes the tick\r
+ * count and the number of times the tick count has overflowed.\r
+ *\r
+ * @param pxTimeOut The time status as captured previously using\r
+ * vTaskSetTimeOutState. If the timeout has not yet occurred, it is updated\r
+ * to reflect the current time status.\r
+ * @param pxTicksToWait The number of ticks to check for timeout i.e. if\r
+ * pxTicksToWait ticks have passed since pxTimeOut was last updated (either by\r
+ * vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred.\r
+ * If the timeout has not occurred, pxTIcksToWait is updated to reflect the\r
+ * number of remaining ticks.\r
+ *\r
+ * @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is\r
+ * returned and pxTicksToWait is updated to reflect the number of remaining\r
+ * ticks.\r
+ *\r
+ * @see https://www.freertos.org/xTaskCheckForTimeOut.html\r
+ *\r
+ * Example Usage:\r
+ * <pre>\r
+       // Driver library function used to receive uxWantedBytes from an Rx buffer\r
+       // that is filled by a UART interrupt. If there are not enough bytes in the\r
+       // Rx buffer then the task enters the Blocked state until it is notified that\r
+       // more data has been placed into the buffer. If there is still not enough\r
+       // data then the task re-enters the Blocked state, and xTaskCheckForTimeOut()\r
+       // is used to re-calculate the Block time to ensure the total amount of time\r
+       // spent in the Blocked state does not exceed MAX_TIME_TO_WAIT. This\r
+       // continues until either the buffer contains at least uxWantedBytes bytes,\r
+       // or the total amount of time spent in the Blocked state reaches\r
+       // MAX_TIME_TO_WAIT – at which point the task reads however many bytes are\r
+       // available up to a maximum of uxWantedBytes.\r
+\r
+       size_t xUART_Receive( uint8_t *pucBuffer, size_t uxWantedBytes )\r
+       {\r
+       size_t uxReceived = 0;\r
+       TickType_t xTicksToWait = MAX_TIME_TO_WAIT;\r
+       TimeOut_t xTimeOut;\r
+\r
+               // Initialize xTimeOut.  This records the time at which this function\r
+               // was entered.\r
+               vTaskSetTimeOutState( &xTimeOut );\r
+\r
+               // Loop until the buffer contains the wanted number of bytes, or a\r
+               // timeout occurs.\r
+               while( UART_bytes_in_rx_buffer( pxUARTInstance ) < uxWantedBytes )\r
+               {\r
+                       // The buffer didn't contain enough data so this task is going to\r
+                       // enter the Blocked state. Adjusting xTicksToWait to account for\r
+                       // any time that has been spent in the Blocked state within this\r
+                       // function so far to ensure the total amount of time spent in the\r
+                       // Blocked state does not exceed MAX_TIME_TO_WAIT.\r
+                       if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) != pdFALSE )\r
+                       {\r
+                               //Timed out before the wanted number of bytes were available,\r
+                               // exit the loop.\r
+                               break;\r
+                       }\r
+\r
+                       // Wait for a maximum of xTicksToWait ticks to be notified that the\r
+                       // receive interrupt has placed more data into the buffer.\r
+                       ulTaskNotifyTake( pdTRUE, xTicksToWait );\r
+               }\r
+\r
+               // Attempt to read uxWantedBytes from the receive buffer into pucBuffer.\r
+               // The actual number of bytes read (which might be less than\r
+               // uxWantedBytes) is returned.\r
+               uxReceived = UART_read_from_receive_buffer( pxUARTInstance,\r
+                                                                                                       pucBuffer,\r
+                                                                                                       uxWantedBytes );\r
+\r
+               return uxReceived;\r
+       }\r
+ </pre>\r
+ * \defgroup xTaskCheckForTimeOut xTaskCheckForTimeOut\r
+ * \ingroup TaskCtrl\r
+ */\r
+BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;\r
+\r
 /*-----------------------------------------------------------\r
  * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES\r
  *----------------------------------------------------------*/\r
@@ -2263,7 +2424,7 @@ void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const Tick
  * Sets the pointer to the current TCB to the TCB of the highest priority task\r
  * that is ready to run.\r
  */\r
-void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;\r
+portDONT_DISCARD void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE.  THEY ARE USED BY\r
@@ -2276,17 +2437,6 @@ TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION;
  */\r
 TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;\r
 \r
-/*\r
- * Capture the current time status for future reference.\r
- */\r
-void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;\r
-\r
-/*\r
- * Compare the time status now with that previously captured to see if the\r
- * timeout has expired.\r
- */\r
-BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;\r
-\r
 /*\r
  * Shortcut used by the queue implementation to prevent unnecessary call to\r
  * taskYIELD();\r
@@ -2311,6 +2461,16 @@ BaseType_t xTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_F
  */\r
 BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;\r
 \r
+/*\r
+ * If a higher priority task attempting to obtain a mutex caused a lower\r
+ * priority task to inherit the higher priority task's priority - but the higher\r
+ * priority task then timed out without obtaining the mutex, then the lower\r
+ * priority task will disinherit the priority again - but only down as far as\r
+ * the highest priority task that is still waiting for the mutex (if there were\r
+ * more than one task waiting for the mutex).\r
+ */\r
+void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder, UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION;\r
+\r
 /*\r
  * Get the uxTCBNumber assigned to the task referenced by the xTask parameter.\r
  */\r
@@ -2332,8 +2492,21 @@ void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVIL
  */\r
 void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION;\r
 \r
+/* Correct the tick count value after the application code has held\r
+interrupts disabled for an extended period.  xTicksToCatchUp is the number\r
+of tick interrupts that have been missed due to interrupts being disabled.\r
+Its value is not computed automatically, so must be computed by the\r
+application writer.\r
+\r
+This function is similar to vTaskStepTick(), however, unlike\r
+vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a\r
+time at which a task should be removed from the blocked state.  That means\r
+tasks may have to be removed from the blocked state as the tick count is\r
+moved. */\r
+BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION;\r
+\r
 /*\r
- * Only avilable when configUSE_TICKLESS_IDLE is set to 1.\r
+ * Only available when configUSE_TICKLESS_IDLE is set to 1.\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
@@ -2352,7 +2525,14 @@ 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 ) PRIVILEGED_FUNCTION;\r
+TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * For internal use only.  Same as vTaskSetTimeOutState(), but without a critial\r
+ * section.\r
+ */\r
+void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;\r
+\r
 \r
 #ifdef __cplusplus\r
 }\r