]> begriffs open source - freertos/blob - include/task.h
Add SPDX and MIT to lexicon
[freertos] / include / task.h
1 /*
2  * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3  * Copyright (C) 2021 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * SPDX-License-Identifier: MIT
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy of
8  * this software and associated documentation files (the "Software"), to deal in
9  * the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11  * the Software, and to permit persons to whom the Software is furnished to do so,
12  * subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all
15  * copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  * https://www.FreeRTOS.org
25  * https://github.com/FreeRTOS
26  *
27  */
28
29
30 #ifndef INC_TASK_H
31 #define INC_TASK_H
32
33 #ifndef INC_FREERTOS_H
34     #error "include FreeRTOS.h must appear in source files before include task.h"
35 #endif
36
37 #include "list.h"
38
39 /* *INDENT-OFF* */
40 #ifdef __cplusplus
41     extern "C" {
42 #endif
43 /* *INDENT-ON* */
44
45 /*-----------------------------------------------------------
46 * MACROS AND DEFINITIONS
47 *----------------------------------------------------------*/
48
49 #define tskKERNEL_VERSION_NUMBER       "V10.4.999"
50 #define tskKERNEL_VERSION_MAJOR        10
51 #define tskKERNEL_VERSION_MINOR        4
52 #define tskKERNEL_VERSION_BUILD        999
53
54 /* MPU region parameters passed in ulParameters
55  * of MemoryRegion_t struct. */
56 #define tskMPU_REGION_READ_ONLY        ( 1UL << 0UL )
57 #define tskMPU_REGION_READ_WRITE       ( 1UL << 1UL )
58 #define tskMPU_REGION_EXECUTE_NEVER    ( 1UL << 2UL )
59 #define tskMPU_REGION_NORMAL_MEMORY    ( 1UL << 3UL )
60 #define tskMPU_REGION_DEVICE_MEMORY    ( 1UL << 4UL )
61
62 /* The direct to task notification feature used to have only a single notification
63  * per task.  Now there is an array of notifications per task that is dimensioned by
64  * configTASK_NOTIFICATION_ARRAY_ENTRIES.  For backward compatibility, any use of the
65  * original direct to task notification defaults to using the first index in the
66  * array. */
67 #define tskDEFAULT_INDEX_TO_NOTIFY     ( 0 )
68
69 /**
70  * task. h
71  *
72  * Type by which tasks are referenced.  For example, a call to xTaskCreate
73  * returns (via a pointer parameter) an TaskHandle_t variable that can then
74  * be used as a parameter to vTaskDelete to delete the task.
75  *
76  * \defgroup TaskHandle_t TaskHandle_t
77  * \ingroup Tasks
78  */
79 struct tskTaskControlBlock;     /* The old naming convention is used to prevent breaking kernel aware debuggers. */
80 typedef struct tskTaskControlBlock * TaskHandle_t;
81
82 /*
83  * Defines the prototype to which the application task hook function must
84  * conform.
85  */
86 typedef BaseType_t (* TaskHookFunction_t)( void * );
87
88 /* Task states returned by eTaskGetState. */
89 typedef enum
90 {
91     eRunning = 0,     /* A task is querying the state of itself, so must be running. */
92     eReady,           /* The task being queried is in a ready or pending ready list. */
93     eBlocked,         /* The task being queried is in the Blocked state. */
94     eSuspended,       /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */
95     eDeleted,         /* The task being queried has been deleted, but its TCB has not yet been freed. */
96     eInvalid          /* Used as an 'invalid state' value. */
97 } eTaskState;
98
99 /* Actions that can be performed when vTaskNotify() is called. */
100 typedef enum
101 {
102     eNoAction = 0,                /* Notify the task without updating its notify value. */
103     eSetBits,                     /* Set bits in the task's notification value. */
104     eIncrement,                   /* Increment the task's notification value. */
105     eSetValueWithOverwrite,       /* Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */
106     eSetValueWithoutOverwrite     /* Set the task's notification value if the previous value has been read by the task. */
107 } eNotifyAction;
108
109 /*
110  * Used internally only.
111  */
112 typedef struct xTIME_OUT
113 {
114     BaseType_t xOverflowCount;
115     TickType_t xTimeOnEntering;
116 } TimeOut_t;
117
118 /*
119  * Defines the memory ranges allocated to the task when an MPU is used.
120  */
121 typedef struct xMEMORY_REGION
122 {
123     void * pvBaseAddress;
124     uint32_t ulLengthInBytes;
125     uint32_t ulParameters;
126 } MemoryRegion_t;
127
128 /*
129  * Parameters required to create an MPU protected task.
130  */
131 typedef struct xTASK_PARAMETERS
132 {
133     TaskFunction_t pvTaskCode;
134     const char * pcName;     /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
135     configSTACK_DEPTH_TYPE usStackDepth;
136     void * pvParameters;
137     UBaseType_t uxPriority;
138     StackType_t * puxStackBuffer;
139     MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ];
140     #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
141         StaticTask_t * const pxTaskBuffer;
142     #endif
143 } TaskParameters_t;
144
145 /* Used with the uxTaskGetSystemState() function to return the state of each task
146  * in the system. */
147 typedef struct xTASK_STATUS
148 {
149     TaskHandle_t xHandle;                            /* The handle of the task to which the rest of the information in the structure relates. */
150     const char * pcTaskName;                         /* A pointer to the task's name.  This value will be invalid if the task was deleted since the structure was populated! */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
151     UBaseType_t xTaskNumber;                         /* A number unique to the task. */
152     eTaskState eCurrentState;                        /* The state in which the task existed when the structure was populated. */
153     UBaseType_t uxCurrentPriority;                   /* The priority at which the task was running (may be inherited) when the structure was populated. */
154     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. */
155     uint32_t ulRunTimeCounter;                       /* The total run time allocated to the task so far, as defined by the run time stats clock.  See https://www.FreeRTOS.org/rtos-run-time-stats.html.  Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */
156     StackType_t * pxStackBase;                       /* Points to the lowest address of the task's stack area. */
157     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. */
158 } TaskStatus_t;
159
160 /* Possible return values for eTaskConfirmSleepModeStatus(). */
161 typedef enum
162 {
163     eAbortSleep = 0,           /* A task has been made ready or a context switch pended since portSUPPRESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */
164     eStandardSleep,            /* Enter a sleep mode that will not last any longer than the expected idle time. */
165     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. */
166 } eSleepModeStatus;
167
168 /**
169  * Defines the priority used by the idle task.  This must not be modified.
170  *
171  * \ingroup TaskUtils
172  */
173 #define tskIDLE_PRIORITY    ( ( UBaseType_t ) 0U )
174
175 /**
176  * task. h
177  *
178  * Macro for forcing a context switch.
179  *
180  * \defgroup taskYIELD taskYIELD
181  * \ingroup SchedulerControl
182  */
183 #define taskYIELD()                        portYIELD()
184
185 /**
186  * task. h
187  *
188  * Macro to mark the start of a critical code region.  Preemptive context
189  * switches cannot occur when in a critical region.
190  *
191  * NOTE: This may alter the stack (depending on the portable implementation)
192  * so must be used with care!
193  *
194  * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL
195  * \ingroup SchedulerControl
196  */
197 #define taskENTER_CRITICAL()               portENTER_CRITICAL()
198 #define taskENTER_CRITICAL_FROM_ISR()      portSET_INTERRUPT_MASK_FROM_ISR()
199
200 /**
201  * task. h
202  *
203  * Macro to mark the end of a critical code region.  Preemptive context
204  * switches cannot occur when in a critical region.
205  *
206  * NOTE: This may alter the stack (depending on the portable implementation)
207  * so must be used with care!
208  *
209  * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL
210  * \ingroup SchedulerControl
211  */
212 #define taskEXIT_CRITICAL()                portEXIT_CRITICAL()
213 #define taskEXIT_CRITICAL_FROM_ISR( x )    portCLEAR_INTERRUPT_MASK_FROM_ISR( x )
214
215 /**
216  * task. h
217  *
218  * Macro to disable all maskable interrupts.
219  *
220  * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS
221  * \ingroup SchedulerControl
222  */
223 #define taskDISABLE_INTERRUPTS()           portDISABLE_INTERRUPTS()
224
225 /**
226  * task. h
227  *
228  * Macro to enable microcontroller interrupts.
229  *
230  * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS
231  * \ingroup SchedulerControl
232  */
233 #define taskENABLE_INTERRUPTS()            portENABLE_INTERRUPTS()
234
235 /* Definitions returned by xTaskGetSchedulerState().  taskSCHEDULER_SUSPENDED is
236  * 0 to generate more optimal code when configASSERT() is defined as the constant
237  * is used in assert() statements. */
238 #define taskSCHEDULER_SUSPENDED      ( ( BaseType_t ) 0 )
239 #define taskSCHEDULER_NOT_STARTED    ( ( BaseType_t ) 1 )
240 #define taskSCHEDULER_RUNNING        ( ( BaseType_t ) 2 )
241
242
243 /*-----------------------------------------------------------
244 * TASK CREATION API
245 *----------------------------------------------------------*/
246
247 /**
248  * task. h
249  * <pre>
250  * BaseType_t xTaskCreate(
251  *                            TaskFunction_t pxTaskCode,
252  *                            const char *pcName,
253  *                            configSTACK_DEPTH_TYPE usStackDepth,
254  *                            void *pvParameters,
255  *                            UBaseType_t uxPriority,
256  *                            TaskHandle_t *pxCreatedTask
257  *                        );
258  * </pre>
259  *
260  * Create a new task and add it to the list of tasks that are ready to run.
261  *
262  * Internally, within the FreeRTOS implementation, tasks use two blocks of
263  * memory.  The first block is used to hold the task's data structures.  The
264  * second block is used by the task as its stack.  If a task is created using
265  * xTaskCreate() then both blocks of memory are automatically dynamically
266  * allocated inside the xTaskCreate() function.  (see
267  * https://www.FreeRTOS.org/a00111.html).  If a task is created using
268  * xTaskCreateStatic() then the application writer must provide the required
269  * memory.  xTaskCreateStatic() therefore allows a task to be created without
270  * using any dynamic memory allocation.
271  *
272  * See xTaskCreateStatic() for a version that does not use any dynamic memory
273  * allocation.
274  *
275  * xTaskCreate() can only be used to create a task that has unrestricted
276  * access to the entire microcontroller memory map.  Systems that include MPU
277  * support can alternatively create an MPU constrained task using
278  * xTaskCreateRestricted().
279  *
280  * @param pxTaskCode Pointer to the task entry function.  Tasks
281  * must be implemented to never return (i.e. continuous loop).
282  *
283  * @param pcName A descriptive name for the task.  This is mainly used to
284  * facilitate debugging.  Max length defined by configMAX_TASK_NAME_LEN - default
285  * is 16.
286  *
287  * @param usStackDepth The size of the task stack specified as the number of
288  * variables the stack can hold - not the number of bytes.  For example, if
289  * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes
290  * will be allocated for stack storage.
291  *
292  * @param pvParameters Pointer that will be used as the parameter for the task
293  * being created.
294  *
295  * @param uxPriority The priority at which the task should run.  Systems that
296  * include MPU support can optionally create tasks in a privileged (system)
297  * mode by setting bit portPRIVILEGE_BIT of the priority parameter.  For
298  * example, to create a privileged task at priority 2 the uxPriority parameter
299  * should be set to ( 2 | portPRIVILEGE_BIT ).
300  *
301  * @param pxCreatedTask Used to pass back a handle by which the created task
302  * can be referenced.
303  *
304  * @return pdPASS if the task was successfully created and added to a ready
305  * list, otherwise an error code defined in the file projdefs.h
306  *
307  * Example usage:
308  * <pre>
309  * // Task to be created.
310  * void vTaskCode( void * pvParameters )
311  * {
312  *   for( ;; )
313  *   {
314  *       // Task code goes here.
315  *   }
316  * }
317  *
318  * // Function that creates a task.
319  * void vOtherFunction( void )
320  * {
321  * static uint8_t ucParameterToPass;
322  * TaskHandle_t xHandle = NULL;
323  *
324  *   // Create the task, storing the handle.  Note that the passed parameter ucParameterToPass
325  *   // must exist for the lifetime of the task, so in this case is declared static.  If it was just an
326  *   // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time
327  *   // the new task attempts to access it.
328  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
329  *   configASSERT( xHandle );
330  *
331  *   // Use the handle to delete the task.
332  *   if( xHandle != NULL )
333  *   {
334  *      vTaskDelete( xHandle );
335  *   }
336  * }
337  * </pre>
338  * \defgroup xTaskCreate xTaskCreate
339  * \ingroup Tasks
340  */
341 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
342     BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
343                             const char * const pcName,     /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
344                             const configSTACK_DEPTH_TYPE usStackDepth,
345                             void * const pvParameters,
346                             UBaseType_t uxPriority,
347                             TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
348 #endif
349
350 /**
351  * task. h
352  * <pre>
353 * TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
354  *                               const char *pcName,
355  *                               uint32_t ulStackDepth,
356  *                               void *pvParameters,
357  *                               UBaseType_t uxPriority,
358  *                               StackType_t *puxStackBuffer,
359  *                               StaticTask_t *pxTaskBuffer );
360  * </pre>
361  *
362  * Create a new task and add it to the list of tasks that are ready to run.
363  *
364  * Internally, within the FreeRTOS implementation, tasks use two blocks of
365  * memory.  The first block is used to hold the task's data structures.  The
366  * second block is used by the task as its stack.  If a task is created using
367  * xTaskCreate() then both blocks of memory are automatically dynamically
368  * allocated inside the xTaskCreate() function.  (see
369  * https://www.FreeRTOS.org/a00111.html).  If a task is created using
370  * xTaskCreateStatic() then the application writer must provide the required
371  * memory.  xTaskCreateStatic() therefore allows a task to be created without
372  * using any dynamic memory allocation.
373  *
374  * @param pxTaskCode Pointer to the task entry function.  Tasks
375  * must be implemented to never return (i.e. continuous loop).
376  *
377  * @param pcName A descriptive name for the task.  This is mainly used to
378  * facilitate debugging.  The maximum length of the string is defined by
379  * configMAX_TASK_NAME_LEN in FreeRTOSConfig.h.
380  *
381  * @param ulStackDepth The size of the task stack specified as the number of
382  * variables the stack can hold - not the number of bytes.  For example, if
383  * the stack is 32-bits wide and ulStackDepth is defined as 100 then 400 bytes
384  * will be allocated for stack storage.
385  *
386  * @param pvParameters Pointer that will be used as the parameter for the task
387  * being created.
388  *
389  * @param uxPriority The priority at which the task will run.
390  *
391  * @param puxStackBuffer Must point to a StackType_t array that has at least
392  * ulStackDepth indexes - the array will then be used as the task's stack,
393  * removing the need for the stack to be allocated dynamically.
394  *
395  * @param pxTaskBuffer Must point to a variable of type StaticTask_t, which will
396  * then be used to hold the task's data structures, removing the need for the
397  * memory to be allocated dynamically.
398  *
399  * @return If neither puxStackBuffer nor pxTaskBuffer are NULL, then the task
400  * will be created and a handle to the created task is returned.  If either
401  * puxStackBuffer or pxTaskBuffer are NULL then the task will not be created and
402  * NULL is returned.
403  *
404  * Example usage:
405  * <pre>
406  *
407  *  // Dimensions of the buffer that the task being created will use as its stack.
408  *  // NOTE:  This is the number of words the stack will hold, not the number of
409  *  // bytes.  For example, if each stack item is 32-bits, and this is set to 100,
410  *  // then 400 bytes (100 * 32-bits) will be allocated.
411  #define STACK_SIZE 200
412  *
413  *  // Structure that will hold the TCB of the task being created.
414  *  StaticTask_t xTaskBuffer;
415  *
416  *  // Buffer that the task being created will use as its stack.  Note this is
417  *  // an array of StackType_t variables.  The size of StackType_t is dependent on
418  *  // the RTOS port.
419  *  StackType_t xStack[ STACK_SIZE ];
420  *
421  *  // Function that implements the task being created.
422  *  void vTaskCode( void * pvParameters )
423  *  {
424  *      // The parameter value is expected to be 1 as 1 is passed in the
425  *      // pvParameters value in the call to xTaskCreateStatic().
426  *      configASSERT( ( uint32_t ) pvParameters == 1UL );
427  *
428  *      for( ;; )
429  *      {
430  *          // Task code goes here.
431  *      }
432  *  }
433  *
434  *  // Function that creates a task.
435  *  void vOtherFunction( void )
436  *  {
437  *      TaskHandle_t xHandle = NULL;
438  *
439  *      // Create the task without using any dynamic memory allocation.
440  *      xHandle = xTaskCreateStatic(
441  *                    vTaskCode,       // Function that implements the task.
442  *                    "NAME",          // Text name for the task.
443  *                    STACK_SIZE,      // Stack size in words, not bytes.
444  *                    ( void * ) 1,    // Parameter passed into the task.
445  *                    tskIDLE_PRIORITY,// Priority at which the task is created.
446  *                    xStack,          // Array to use as the task's stack.
447  *                    &xTaskBuffer );  // Variable to hold the task's data structure.
448  *
449  *      // puxStackBuffer and pxTaskBuffer were not NULL, so the task will have
450  *      // been created, and xHandle will be the task's handle.  Use the handle
451  *      // to suspend the task.
452  *      vTaskSuspend( xHandle );
453  *  }
454  * </pre>
455  * \defgroup xTaskCreateStatic xTaskCreateStatic
456  * \ingroup Tasks
457  */
458 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
459     TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
460                                     const char * const pcName,     /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
461                                     const uint32_t ulStackDepth,
462                                     void * const pvParameters,
463                                     UBaseType_t uxPriority,
464                                     StackType_t * const puxStackBuffer,
465                                     StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION;
466 #endif /* configSUPPORT_STATIC_ALLOCATION */
467
468 /**
469  * task. h
470  * <pre>
471  * BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
472  * </pre>
473  *
474  * Only available when configSUPPORT_DYNAMIC_ALLOCATION is set to 1.
475  *
476  * xTaskCreateRestricted() should only be used in systems that include an MPU
477  * implementation.
478  *
479  * Create a new task and add it to the list of tasks that are ready to run.
480  * The function parameters define the memory regions and associated access
481  * permissions allocated to the task.
482  *
483  * See xTaskCreateRestrictedStatic() for a version that does not use any
484  * dynamic memory allocation.
485  *
486  * @param pxTaskDefinition Pointer to a structure that contains a member
487  * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
488  * documentation) plus an optional stack buffer and the memory region
489  * definitions.
490  *
491  * @param pxCreatedTask Used to pass back a handle by which the created task
492  * can be referenced.
493  *
494  * @return pdPASS if the task was successfully created and added to a ready
495  * list, otherwise an error code defined in the file projdefs.h
496  *
497  * Example usage:
498  * <pre>
499  * // Create an TaskParameters_t structure that defines the task to be created.
500  * static const TaskParameters_t xCheckTaskParameters =
501  * {
502  *  vATask,     // pvTaskCode - the function that implements the task.
503  *  "ATask",    // pcName - just a text name for the task to assist debugging.
504  *  100,        // usStackDepth - the stack size DEFINED IN WORDS.
505  *  NULL,       // pvParameters - passed into the task function as the function parameters.
506  *  ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
507  *  cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
508  *
509  *  // xRegions - Allocate up to three separate memory regions for access by
510  *  // the task, with appropriate access permissions.  Different processors have
511  *  // different memory alignment requirements - refer to the FreeRTOS documentation
512  *  // for full information.
513  *  {
514  *      // Base address                 Length  Parameters
515  *      { cReadWriteArray,              32,     portMPU_REGION_READ_WRITE },
516  *      { cReadOnlyArray,               32,     portMPU_REGION_READ_ONLY },
517  *      { cPrivilegedOnlyAccessArray,   128,    portMPU_REGION_PRIVILEGED_READ_WRITE }
518  *  }
519  * };
520  *
521  * int main( void )
522  * {
523  * TaskHandle_t xHandle;
524  *
525  *  // Create a task from the const structure defined above.  The task handle
526  *  // is requested (the second parameter is not NULL) but in this case just for
527  *  // demonstration purposes as its not actually used.
528  *  xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
529  *
530  *  // Start the scheduler.
531  *  vTaskStartScheduler();
532  *
533  *  // Will only get here if there was insufficient memory to create the idle
534  *  // and/or timer task.
535  *  for( ;; );
536  * }
537  * </pre>
538  * \defgroup xTaskCreateRestricted xTaskCreateRestricted
539  * \ingroup Tasks
540  */
541 #if ( portUSING_MPU_WRAPPERS == 1 )
542     BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition,
543                                       TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
544 #endif
545
546 /**
547  * task. h
548  * <pre>
549  * BaseType_t xTaskCreateRestrictedStatic( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
550  * </pre>
551  *
552  * Only available when configSUPPORT_STATIC_ALLOCATION is set to 1.
553  *
554  * xTaskCreateRestrictedStatic() should only be used in systems that include an
555  * MPU implementation.
556  *
557  * Internally, within the FreeRTOS implementation, tasks use two blocks of
558  * memory.  The first block is used to hold the task's data structures.  The
559  * second block is used by the task as its stack.  If a task is created using
560  * xTaskCreateRestricted() then the stack is provided by the application writer,
561  * and the memory used to hold the task's data structure is automatically
562  * dynamically allocated inside the xTaskCreateRestricted() function.  If a task
563  * is created using xTaskCreateRestrictedStatic() then the application writer
564  * must provide the memory used to hold the task's data structures too.
565  * xTaskCreateRestrictedStatic() therefore allows a memory protected task to be
566  * created without using any dynamic memory allocation.
567  *
568  * @param pxTaskDefinition Pointer to a structure that contains a member
569  * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
570  * documentation) plus an optional stack buffer and the memory region
571  * definitions.  If configSUPPORT_STATIC_ALLOCATION is set to 1 the structure
572  * contains an additional member, which is used to point to a variable of type
573  * StaticTask_t - which is then used to hold the task's data structure.
574  *
575  * @param pxCreatedTask Used to pass back a handle by which the created task
576  * can be referenced.
577  *
578  * @return pdPASS if the task was successfully created and added to a ready
579  * list, otherwise an error code defined in the file projdefs.h
580  *
581  * Example usage:
582  * <pre>
583  * // Create an TaskParameters_t structure that defines the task to be created.
584  * // The StaticTask_t variable is only included in the structure when
585  * // configSUPPORT_STATIC_ALLOCATION is set to 1.  The PRIVILEGED_DATA macro can
586  * // be used to force the variable into the RTOS kernel's privileged data area.
587  * static PRIVILEGED_DATA StaticTask_t xTaskBuffer;
588  * static const TaskParameters_t xCheckTaskParameters =
589  * {
590  *  vATask,     // pvTaskCode - the function that implements the task.
591  *  "ATask",    // pcName - just a text name for the task to assist debugging.
592  *  100,        // usStackDepth - the stack size DEFINED IN WORDS.
593  *  NULL,       // pvParameters - passed into the task function as the function parameters.
594  *  ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
595  *  cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
596  *
597  *  // xRegions - Allocate up to three separate memory regions for access by
598  *  // the task, with appropriate access permissions.  Different processors have
599  *  // different memory alignment requirements - refer to the FreeRTOS documentation
600  *  // for full information.
601  *  {
602  *      // Base address                 Length  Parameters
603  *      { cReadWriteArray,              32,     portMPU_REGION_READ_WRITE },
604  *      { cReadOnlyArray,               32,     portMPU_REGION_READ_ONLY },
605  *      { cPrivilegedOnlyAccessArray,   128,    portMPU_REGION_PRIVILEGED_READ_WRITE }
606  *  }
607  *
608  *  &xTaskBuffer; // Holds the task's data structure.
609  * };
610  *
611  * int main( void )
612  * {
613  * TaskHandle_t xHandle;
614  *
615  *  // Create a task from the const structure defined above.  The task handle
616  *  // is requested (the second parameter is not NULL) but in this case just for
617  *  // demonstration purposes as its not actually used.
618  *  xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
619  *
620  *  // Start the scheduler.
621  *  vTaskStartScheduler();
622  *
623  *  // Will only get here if there was insufficient memory to create the idle
624  *  // and/or timer task.
625  *  for( ;; );
626  * }
627  * </pre>
628  * \defgroup xTaskCreateRestrictedStatic xTaskCreateRestrictedStatic
629  * \ingroup Tasks
630  */
631 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
632     BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition,
633                                             TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
634 #endif
635
636 /**
637  * task. h
638  * <pre>
639  * void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions );
640  * </pre>
641  *
642  * Memory regions are assigned to a restricted task when the task is created by
643  * a call to xTaskCreateRestricted().  These regions can be redefined using
644  * vTaskAllocateMPURegions().
645  *
646  * @param xTask The handle of the task being updated.
647  *
648  * @param xRegions A pointer to a MemoryRegion_t structure that contains the
649  * new memory region definitions.
650  *
651  * Example usage:
652  * <pre>
653  * // Define an array of MemoryRegion_t structures that configures an MPU region
654  * // allowing read/write access for 1024 bytes starting at the beginning of the
655  * // ucOneKByte array.  The other two of the maximum 3 definable regions are
656  * // unused so set to zero.
657  * static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =
658  * {
659  *  // Base address     Length      Parameters
660  *  { ucOneKByte,       1024,       portMPU_REGION_READ_WRITE },
661  *  { 0,                0,          0 },
662  *  { 0,                0,          0 }
663  * };
664  *
665  * void vATask( void *pvParameters )
666  * {
667  *  // This task was created such that it has access to certain regions of
668  *  // memory as defined by the MPU configuration.  At some point it is
669  *  // desired that these MPU regions are replaced with that defined in the
670  *  // xAltRegions const struct above.  Use a call to vTaskAllocateMPURegions()
671  *  // for this purpose.  NULL is used as the task handle to indicate that this
672  *  // function should modify the MPU regions of the calling task.
673  *  vTaskAllocateMPURegions( NULL, xAltRegions );
674  *
675  *  // Now the task can continue its function, but from this point on can only
676  *  // access its stack and the ucOneKByte array (unless any other statically
677  *  // defined or shared regions have been declared elsewhere).
678  * }
679  * </pre>
680  * \defgroup xTaskCreateRestricted xTaskCreateRestricted
681  * \ingroup Tasks
682  */
683 void vTaskAllocateMPURegions( TaskHandle_t xTask,
684                               const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION;
685
686 /**
687  * task. h
688  * <pre>
689  * void vTaskDelete( TaskHandle_t xTaskToDelete );
690  * </pre>
691  *
692  * INCLUDE_vTaskDelete must be defined as 1 for this function to be available.
693  * See the configuration section for more information.
694  *
695  * Remove a task from the RTOS real time kernel's management.  The task being
696  * deleted will be removed from all ready, blocked, suspended and event lists.
697  *
698  * NOTE:  The idle task is responsible for freeing the kernel allocated
699  * memory from tasks that have been deleted.  It is therefore important that
700  * the idle task is not starved of microcontroller processing time if your
701  * application makes any calls to vTaskDelete ().  Memory allocated by the
702  * task code is not automatically freed, and should be freed before the task
703  * is deleted.
704  *
705  * See the demo application file death.c for sample code that utilises
706  * vTaskDelete ().
707  *
708  * @param xTaskToDelete The handle of the task to be deleted.  Passing NULL will
709  * cause the calling task to be deleted.
710  *
711  * Example usage:
712  * <pre>
713  * void vOtherFunction( void )
714  * {
715  * TaskHandle_t xHandle;
716  *
717  *   // Create the task, storing the handle.
718  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
719  *
720  *   // Use the handle to delete the task.
721  *   vTaskDelete( xHandle );
722  * }
723  * </pre>
724  * \defgroup vTaskDelete vTaskDelete
725  * \ingroup Tasks
726  */
727 void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
728
729 /*-----------------------------------------------------------
730 * TASK CONTROL API
731 *----------------------------------------------------------*/
732
733 /**
734  * task. h
735  * <pre>
736  * void vTaskDelay( const TickType_t xTicksToDelay );
737  * </pre>
738  *
739  * Delay a task for a given number of ticks.  The actual time that the
740  * task remains blocked depends on the tick rate.  The constant
741  * portTICK_PERIOD_MS can be used to calculate real time from the tick
742  * rate - with the resolution of one tick period.
743  *
744  * INCLUDE_vTaskDelay must be defined as 1 for this function to be available.
745  * See the configuration section for more information.
746  *
747  *
748  * vTaskDelay() specifies a time at which the task wishes to unblock relative to
749  * the time at which vTaskDelay() is called.  For example, specifying a block
750  * period of 100 ticks will cause the task to unblock 100 ticks after
751  * vTaskDelay() is called.  vTaskDelay() does not therefore provide a good method
752  * of controlling the frequency of a periodic task as the path taken through the
753  * code, as well as other task and interrupt activity, will effect the frequency
754  * at which vTaskDelay() gets called and therefore the time at which the task
755  * next executes.  See xTaskDelayUntil() for an alternative API function designed
756  * to facilitate fixed frequency execution.  It does this by specifying an
757  * absolute time (rather than a relative time) at which the calling task should
758  * unblock.
759  *
760  * @param xTicksToDelay The amount of time, in tick periods, that
761  * the calling task should block.
762  *
763  * Example usage:
764  *
765  * void vTaskFunction( void * pvParameters )
766  * {
767  * // Block for 500ms.
768  * const TickType_t xDelay = 500 / portTICK_PERIOD_MS;
769  *
770  *   for( ;; )
771  *   {
772  *       // Simply toggle the LED every 500ms, blocking between each toggle.
773  *       vToggleLED();
774  *       vTaskDelay( xDelay );
775  *   }
776  * }
777  *
778  * \defgroup vTaskDelay vTaskDelay
779  * \ingroup TaskCtrl
780  */
781 void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
782
783 /**
784  * task. h
785  * <pre>
786  * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
787  * </pre>
788  *
789  * INCLUDE_xTaskDelayUntil must be defined as 1 for this function to be available.
790  * See the configuration section for more information.
791  *
792  * Delay a task until a specified time.  This function can be used by periodic
793  * tasks to ensure a constant execution frequency.
794  *
795  * This function differs from vTaskDelay () in one important aspect:  vTaskDelay () will
796  * cause a task to block for the specified number of ticks from the time vTaskDelay () is
797  * called.  It is therefore difficult to use vTaskDelay () by itself to generate a fixed
798  * execution frequency as the time between a task starting to execute and that task
799  * calling vTaskDelay () may not be fixed [the task may take a different path though the
800  * code between calls, or may get interrupted or preempted a different number of times
801  * each time it executes].
802  *
803  * Whereas vTaskDelay () specifies a wake time relative to the time at which the function
804  * is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to
805  * unblock.
806  *
807  * The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a
808  * time specified in milliseconds with a resolution of one tick period.
809  *
810  * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the
811  * task was last unblocked.  The variable must be initialised with the current time
812  * prior to its first use (see the example below).  Following this the variable is
813  * automatically updated within xTaskDelayUntil ().
814  *
815  * @param xTimeIncrement The cycle time period.  The task will be unblocked at
816  * time *pxPreviousWakeTime + xTimeIncrement.  Calling xTaskDelayUntil with the
817  * same xTimeIncrement parameter value will cause the task to execute with
818  * a fixed interface period.
819  *
820  * @return Value which can be used to check whether the task was actually delayed.
821  * Will be pdTRUE if the task way delayed and pdFALSE otherwise.  A task will not
822  * be delayed if the next expected wake time is in the past.
823  *
824  * Example usage:
825  * <pre>
826  * // Perform an action every 10 ticks.
827  * void vTaskFunction( void * pvParameters )
828  * {
829  * TickType_t xLastWakeTime;
830  * const TickType_t xFrequency = 10;
831  * BaseType_t xWasDelayed;
832  *
833  *     // Initialise the xLastWakeTime variable with the current time.
834  *     xLastWakeTime = xTaskGetTickCount ();
835  *     for( ;; )
836  *     {
837  *         // Wait for the next cycle.
838  *         xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency );
839  *
840  *         // Perform action here. xWasDelayed value can be used to determine
841  *         // whether a deadline was missed if the code here took too long.
842  *     }
843  * }
844  * </pre>
845  * \defgroup xTaskDelayUntil xTaskDelayUntil
846  * \ingroup TaskCtrl
847  */
848 BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
849                             const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
850
851 /*
852  * vTaskDelayUntil() is the older version of xTaskDelayUntil() and does not
853  * return a value.
854  */
855 #define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement )       \
856 {                                                                   \
857     ( void ) xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); \
858 }
859
860
861 /**
862  * task. h
863  * <pre>
864  * BaseType_t xTaskAbortDelay( TaskHandle_t xTask );
865  * </pre>
866  *
867  * INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this
868  * function to be available.
869  *
870  * A task will enter the Blocked state when it is waiting for an event.  The
871  * event it is waiting for can be a temporal event (waiting for a time), such
872  * as when vTaskDelay() is called, or an event on an object, such as when
873  * xQueueReceive() or ulTaskNotifyTake() is called.  If the handle of a task
874  * that is in the Blocked state is used in a call to xTaskAbortDelay() then the
875  * task will leave the Blocked state, and return from whichever function call
876  * placed the task into the Blocked state.
877  *
878  * There is no 'FromISR' version of this function as an interrupt would need to
879  * know which object a task was blocked on in order to know which actions to
880  * take.  For example, if the task was blocked on a queue the interrupt handler
881  * would then need to know if the queue was locked.
882  *
883  * @param xTask The handle of the task to remove from the Blocked state.
884  *
885  * @return If the task referenced by xTask was not in the Blocked state then
886  * pdFAIL is returned.  Otherwise pdPASS is returned.
887  *
888  * \defgroup xTaskAbortDelay xTaskAbortDelay
889  * \ingroup TaskCtrl
890  */
891 BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
892
893 /**
894  * task. h
895  * <pre>
896  * UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask );
897  * </pre>
898  *
899  * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available.
900  * See the configuration section for more information.
901  *
902  * Obtain the priority of any task.
903  *
904  * @param xTask Handle of the task to be queried.  Passing a NULL
905  * handle results in the priority of the calling task being returned.
906  *
907  * @return The priority of xTask.
908  *
909  * Example usage:
910  * <pre>
911  * void vAFunction( void )
912  * {
913  * TaskHandle_t xHandle;
914  *
915  *   // Create a task, storing the handle.
916  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
917  *
918  *   // ...
919  *
920  *   // Use the handle to obtain the priority of the created task.
921  *   // It was created with tskIDLE_PRIORITY, but may have changed
922  *   // it itself.
923  *   if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
924  *   {
925  *       // The task has changed it's priority.
926  *   }
927  *
928  *   // ...
929  *
930  *   // Is our priority higher than the created task?
931  *   if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
932  *   {
933  *       // Our priority (obtained using NULL handle) is higher.
934  *   }
935  * }
936  * </pre>
937  * \defgroup uxTaskPriorityGet uxTaskPriorityGet
938  * \ingroup TaskCtrl
939  */
940 UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
941
942 /**
943  * task. h
944  * <pre>
945  * UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask );
946  * </pre>
947  *
948  * A version of uxTaskPriorityGet() that can be used from an ISR.
949  */
950 UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
951
952 /**
953  * task. h
954  * <pre>
955  * eTaskState eTaskGetState( TaskHandle_t xTask );
956  * </pre>
957  *
958  * INCLUDE_eTaskGetState must be defined as 1 for this function to be available.
959  * See the configuration section for more information.
960  *
961  * Obtain the state of any task.  States are encoded by the eTaskState
962  * enumerated type.
963  *
964  * @param xTask Handle of the task to be queried.
965  *
966  * @return The state of xTask at the time the function was called.  Note the
967  * state of the task might change between the function being called, and the
968  * functions return value being tested by the calling task.
969  */
970 eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
971
972 /**
973  * task. h
974  * <pre>
975  * void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState );
976  * </pre>
977  *
978  * configUSE_TRACE_FACILITY must be defined as 1 for this function to be
979  * available.  See the configuration section for more information.
980  *
981  * Populates a TaskStatus_t structure with information about a task.
982  *
983  * @param xTask Handle of the task being queried.  If xTask is NULL then
984  * information will be returned about the calling task.
985  *
986  * @param pxTaskStatus A pointer to the TaskStatus_t structure that will be
987  * filled with information about the task referenced by the handle passed using
988  * the xTask parameter.
989  *
990  * @xGetFreeStackSpace The TaskStatus_t structure contains a member to report
991  * the stack high water mark of the task being queried.  Calculating the stack
992  * high water mark takes a relatively long time, and can make the system
993  * temporarily unresponsive - so the xGetFreeStackSpace parameter is provided to
994  * allow the high water mark checking to be skipped.  The high watermark value
995  * will only be written to the TaskStatus_t structure if xGetFreeStackSpace is
996  * not set to pdFALSE;
997  *
998  * @param eState The TaskStatus_t structure contains a member to report the
999  * state of the task being queried.  Obtaining the task state is not as fast as
1000  * a simple assignment - so the eState parameter is provided to allow the state
1001  * information to be omitted from the TaskStatus_t structure.  To obtain state
1002  * information then set eState to eInvalid - otherwise the value passed in
1003  * eState will be reported as the task state in the TaskStatus_t structure.
1004  *
1005  * Example usage:
1006  * <pre>
1007  * void vAFunction( void )
1008  * {
1009  * TaskHandle_t xHandle;
1010  * TaskStatus_t xTaskDetails;
1011  *
1012  *  // Obtain the handle of a task from its name.
1013  *  xHandle = xTaskGetHandle( "Task_Name" );
1014  *
1015  *  // Check the handle is not NULL.
1016  *  configASSERT( xHandle );
1017  *
1018  *  // Use the handle to obtain further information about the task.
1019  *  vTaskGetInfo( xHandle,
1020  *                &xTaskDetails,
1021  *                pdTRUE, // Include the high water mark in xTaskDetails.
1022  *                eInvalid ); // Include the task state in xTaskDetails.
1023  * }
1024  * </pre>
1025  * \defgroup vTaskGetInfo vTaskGetInfo
1026  * \ingroup TaskCtrl
1027  */
1028 void vTaskGetInfo( TaskHandle_t xTask,
1029                    TaskStatus_t * pxTaskStatus,
1030                    BaseType_t xGetFreeStackSpace,
1031                    eTaskState eState ) PRIVILEGED_FUNCTION;
1032
1033 /**
1034  * task. h
1035  * <pre>
1036  * void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );
1037  * </pre>
1038  *
1039  * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.
1040  * See the configuration section for more information.
1041  *
1042  * Set the priority of any task.
1043  *
1044  * A context switch will occur before the function returns if the priority
1045  * being set is higher than the currently executing task.
1046  *
1047  * @param xTask Handle to the task for which the priority is being set.
1048  * Passing a NULL handle results in the priority of the calling task being set.
1049  *
1050  * @param uxNewPriority The priority to which the task will be set.
1051  *
1052  * Example usage:
1053  * <pre>
1054  * void vAFunction( void )
1055  * {
1056  * TaskHandle_t xHandle;
1057  *
1058  *   // Create a task, storing the handle.
1059  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1060  *
1061  *   // ...
1062  *
1063  *   // Use the handle to raise the priority of the created task.
1064  *   vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
1065  *
1066  *   // ...
1067  *
1068  *   // Use a NULL handle to raise our priority to the same value.
1069  *   vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
1070  * }
1071  * </pre>
1072  * \defgroup vTaskPrioritySet vTaskPrioritySet
1073  * \ingroup TaskCtrl
1074  */
1075 void vTaskPrioritySet( TaskHandle_t xTask,
1076                        UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
1077
1078 /**
1079  * task. h
1080  * <pre>
1081  * void vTaskSuspend( TaskHandle_t xTaskToSuspend );
1082  * </pre>
1083  *
1084  * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
1085  * See the configuration section for more information.
1086  *
1087  * Suspend any task.  When suspended a task will never get any microcontroller
1088  * processing time, no matter what its priority.
1089  *
1090  * Calls to vTaskSuspend are not accumulative -
1091  * i.e. calling vTaskSuspend () twice on the same task still only requires one
1092  * call to vTaskResume () to ready the suspended task.
1093  *
1094  * @param xTaskToSuspend Handle to the task being suspended.  Passing a NULL
1095  * handle will cause the calling task to be suspended.
1096  *
1097  * Example usage:
1098  * <pre>
1099  * void vAFunction( void )
1100  * {
1101  * TaskHandle_t xHandle;
1102  *
1103  *   // Create a task, storing the handle.
1104  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1105  *
1106  *   // ...
1107  *
1108  *   // Use the handle to suspend the created task.
1109  *   vTaskSuspend( xHandle );
1110  *
1111  *   // ...
1112  *
1113  *   // The created task will not run during this period, unless
1114  *   // another task calls vTaskResume( xHandle ).
1115  *
1116  *   //...
1117  *
1118  *
1119  *   // Suspend ourselves.
1120  *   vTaskSuspend( NULL );
1121  *
1122  *   // We cannot get here unless another task calls vTaskResume
1123  *   // with our handle as the parameter.
1124  * }
1125  * </pre>
1126  * \defgroup vTaskSuspend vTaskSuspend
1127  * \ingroup TaskCtrl
1128  */
1129 void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION;
1130
1131 /**
1132  * task. h
1133  * <pre>
1134  * void vTaskResume( TaskHandle_t xTaskToResume );
1135  * </pre>
1136  *
1137  * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
1138  * See the configuration section for more information.
1139  *
1140  * Resumes a suspended task.
1141  *
1142  * A task that has been suspended by one or more calls to vTaskSuspend ()
1143  * will be made available for running again by a single call to
1144  * vTaskResume ().
1145  *
1146  * @param xTaskToResume Handle to the task being readied.
1147  *
1148  * Example usage:
1149  * <pre>
1150  * void vAFunction( void )
1151  * {
1152  * TaskHandle_t xHandle;
1153  *
1154  *   // Create a task, storing the handle.
1155  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1156  *
1157  *   // ...
1158  *
1159  *   // Use the handle to suspend the created task.
1160  *   vTaskSuspend( xHandle );
1161  *
1162  *   // ...
1163  *
1164  *   // The created task will not run during this period, unless
1165  *   // another task calls vTaskResume( xHandle ).
1166  *
1167  *   //...
1168  *
1169  *
1170  *   // Resume the suspended task ourselves.
1171  *   vTaskResume( xHandle );
1172  *
1173  *   // The created task will once again get microcontroller processing
1174  *   // time in accordance with its priority within the system.
1175  * }
1176  * </pre>
1177  * \defgroup vTaskResume vTaskResume
1178  * \ingroup TaskCtrl
1179  */
1180 void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
1181
1182 /**
1183  * task. h
1184  * <pre>
1185  * void xTaskResumeFromISR( TaskHandle_t xTaskToResume );
1186  * </pre>
1187  *
1188  * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be
1189  * available.  See the configuration section for more information.
1190  *
1191  * An implementation of vTaskResume() that can be called from within an ISR.
1192  *
1193  * A task that has been suspended by one or more calls to vTaskSuspend ()
1194  * will be made available for running again by a single call to
1195  * xTaskResumeFromISR ().
1196  *
1197  * xTaskResumeFromISR() should not be used to synchronise a task with an
1198  * interrupt if there is a chance that the interrupt could arrive prior to the
1199  * task being suspended - as this can lead to interrupts being missed. Use of a
1200  * semaphore as a synchronisation mechanism would avoid this eventuality.
1201  *
1202  * @param xTaskToResume Handle to the task being readied.
1203  *
1204  * @return pdTRUE if resuming the task should result in a context switch,
1205  * otherwise pdFALSE. This is used by the ISR to determine if a context switch
1206  * may be required following the ISR.
1207  *
1208  * \defgroup vTaskResumeFromISR vTaskResumeFromISR
1209  * \ingroup TaskCtrl
1210  */
1211 BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
1212
1213 /*-----------------------------------------------------------
1214 * SCHEDULER CONTROL
1215 *----------------------------------------------------------*/
1216
1217 /**
1218  * task. h
1219  * <pre>
1220  * void vTaskStartScheduler( void );
1221  * </pre>
1222  *
1223  * Starts the real time kernel tick processing.  After calling the kernel
1224  * has control over which tasks are executed and when.
1225  *
1226  * See the demo application file main.c for an example of creating
1227  * tasks and starting the kernel.
1228  *
1229  * Example usage:
1230  * <pre>
1231  * void vAFunction( void )
1232  * {
1233  *   // Create at least one task before starting the kernel.
1234  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
1235  *
1236  *   // Start the real time kernel with preemption.
1237  *   vTaskStartScheduler ();
1238  *
1239  *   // Will not get here unless a task calls vTaskEndScheduler ()
1240  * }
1241  * </pre>
1242  *
1243  * \defgroup vTaskStartScheduler vTaskStartScheduler
1244  * \ingroup SchedulerControl
1245  */
1246 void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;
1247
1248 /**
1249  * task. h
1250  * <pre>
1251  * void vTaskEndScheduler( void );
1252  * </pre>
1253  *
1254  * NOTE:  At the time of writing only the x86 real mode port, which runs on a PC
1255  * in place of DOS, implements this function.
1256  *
1257  * Stops the real time kernel tick.  All created tasks will be automatically
1258  * deleted and multitasking (either preemptive or cooperative) will
1259  * stop.  Execution then resumes from the point where vTaskStartScheduler ()
1260  * was called, as if vTaskStartScheduler () had just returned.
1261  *
1262  * See the demo application file main. c in the demo/PC directory for an
1263  * example that uses vTaskEndScheduler ().
1264  *
1265  * vTaskEndScheduler () requires an exit function to be defined within the
1266  * portable layer (see vPortEndScheduler () in port. c for the PC port).  This
1267  * performs hardware specific operations such as stopping the kernel tick.
1268  *
1269  * vTaskEndScheduler () will cause all of the resources allocated by the
1270  * kernel to be freed - but will not free resources allocated by application
1271  * tasks.
1272  *
1273  * Example usage:
1274  * <pre>
1275  * void vTaskCode( void * pvParameters )
1276  * {
1277  *   for( ;; )
1278  *   {
1279  *       // Task code goes here.
1280  *
1281  *       // At some point we want to end the real time kernel processing
1282  *       // so call ...
1283  *       vTaskEndScheduler ();
1284  *   }
1285  * }
1286  *
1287  * void vAFunction( void )
1288  * {
1289  *   // Create at least one task before starting the kernel.
1290  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
1291  *
1292  *   // Start the real time kernel with preemption.
1293  *   vTaskStartScheduler ();
1294  *
1295  *   // Will only get here when the vTaskCode () task has called
1296  *   // vTaskEndScheduler ().  When we get here we are back to single task
1297  *   // execution.
1298  * }
1299  * </pre>
1300  *
1301  * \defgroup vTaskEndScheduler vTaskEndScheduler
1302  * \ingroup SchedulerControl
1303  */
1304 void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;
1305
1306 /**
1307  * task. h
1308  * <pre>
1309  * void vTaskSuspendAll( void );
1310  * </pre>
1311  *
1312  * Suspends the scheduler without disabling interrupts.  Context switches will
1313  * not occur while the scheduler is suspended.
1314  *
1315  * After calling vTaskSuspendAll () the calling task will continue to execute
1316  * without risk of being swapped out until a call to xTaskResumeAll () has been
1317  * made.
1318  *
1319  * API functions that have the potential to cause a context switch (for example,
1320  * xTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler
1321  * is suspended.
1322  *
1323  * Example usage:
1324  * <pre>
1325  * void vTask1( void * pvParameters )
1326  * {
1327  *   for( ;; )
1328  *   {
1329  *       // Task code goes here.
1330  *
1331  *       // ...
1332  *
1333  *       // At some point the task wants to perform a long operation during
1334  *       // which it does not want to get swapped out.  It cannot use
1335  *       // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
1336  *       // operation may cause interrupts to be missed - including the
1337  *       // ticks.
1338  *
1339  *       // Prevent the real time kernel swapping out the task.
1340  *       vTaskSuspendAll ();
1341  *
1342  *       // Perform the operation here.  There is no need to use critical
1343  *       // sections as we have all the microcontroller processing time.
1344  *       // During this time interrupts will still operate and the kernel
1345  *       // tick count will be maintained.
1346  *
1347  *       // ...
1348  *
1349  *       // The operation is complete.  Restart the kernel.
1350  *       xTaskResumeAll ();
1351  *   }
1352  * }
1353  * </pre>
1354  * \defgroup vTaskSuspendAll vTaskSuspendAll
1355  * \ingroup SchedulerControl
1356  */
1357 void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;
1358
1359 /**
1360  * task. h
1361  * <pre>
1362  * BaseType_t xTaskResumeAll( void );
1363  * </pre>
1364  *
1365  * Resumes scheduler activity after it was suspended by a call to
1366  * vTaskSuspendAll().
1367  *
1368  * xTaskResumeAll() only resumes the scheduler.  It does not unsuspend tasks
1369  * that were previously suspended by a call to vTaskSuspend().
1370  *
1371  * @return If resuming the scheduler caused a context switch then pdTRUE is
1372  *         returned, otherwise pdFALSE is returned.
1373  *
1374  * Example usage:
1375  * <pre>
1376  * void vTask1( void * pvParameters )
1377  * {
1378  *   for( ;; )
1379  *   {
1380  *       // Task code goes here.
1381  *
1382  *       // ...
1383  *
1384  *       // At some point the task wants to perform a long operation during
1385  *       // which it does not want to get swapped out.  It cannot use
1386  *       // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
1387  *       // operation may cause interrupts to be missed - including the
1388  *       // ticks.
1389  *
1390  *       // Prevent the real time kernel swapping out the task.
1391  *       vTaskSuspendAll ();
1392  *
1393  *       // Perform the operation here.  There is no need to use critical
1394  *       // sections as we have all the microcontroller processing time.
1395  *       // During this time interrupts will still operate and the real
1396  *       // time kernel tick count will be maintained.
1397  *
1398  *       // ...
1399  *
1400  *       // The operation is complete.  Restart the kernel.  We want to force
1401  *       // a context switch - but there is no point if resuming the scheduler
1402  *       // caused a context switch already.
1403  *       if( !xTaskResumeAll () )
1404  *       {
1405  *            taskYIELD ();
1406  *       }
1407  *   }
1408  * }
1409  * </pre>
1410  * \defgroup xTaskResumeAll xTaskResumeAll
1411  * \ingroup SchedulerControl
1412  */
1413 BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION;
1414
1415 /*-----------------------------------------------------------
1416 * TASK UTILITIES
1417 *----------------------------------------------------------*/
1418
1419 /**
1420  * task. h
1421  * <PRE>TickType_t xTaskGetTickCount( void );</PRE>
1422  *
1423  * @return The count of ticks since vTaskStartScheduler was called.
1424  *
1425  * \defgroup xTaskGetTickCount xTaskGetTickCount
1426  * \ingroup TaskUtils
1427  */
1428 TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;
1429
1430 /**
1431  * task. h
1432  * <PRE>TickType_t xTaskGetTickCountFromISR( void );</PRE>
1433  *
1434  * @return The count of ticks since vTaskStartScheduler was called.
1435  *
1436  * This is a version of xTaskGetTickCount() that is safe to be called from an
1437  * ISR - provided that TickType_t is the natural word size of the
1438  * microcontroller being used or interrupt nesting is either not supported or
1439  * not being used.
1440  *
1441  * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR
1442  * \ingroup TaskUtils
1443  */
1444 TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION;
1445
1446 /**
1447  * task. h
1448  * <PRE>uint16_t uxTaskGetNumberOfTasks( void );</PRE>
1449  *
1450  * @return The number of tasks that the real time kernel is currently managing.
1451  * This includes all ready, blocked and suspended tasks.  A task that
1452  * has been deleted but not yet freed by the idle task will also be
1453  * included in the count.
1454  *
1455  * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks
1456  * \ingroup TaskUtils
1457  */
1458 UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;
1459
1460 /**
1461  * task. h
1462  * <PRE>char *pcTaskGetName( TaskHandle_t xTaskToQuery );</PRE>
1463  *
1464  * @return The text (human readable) name of the task referenced by the handle
1465  * xTaskToQuery.  A task can query its own name by either passing in its own
1466  * handle, or by setting xTaskToQuery to NULL.
1467  *
1468  * \defgroup pcTaskGetName pcTaskGetName
1469  * \ingroup TaskUtils
1470  */
1471 char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION;     /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1472
1473 /**
1474  * task. h
1475  * <PRE>TaskHandle_t xTaskGetHandle( const char *pcNameToQuery );</PRE>
1476  *
1477  * NOTE:  This function takes a relatively long time to complete and should be
1478  * used sparingly.
1479  *
1480  * @return The handle of the task that has the human readable name pcNameToQuery.
1481  * NULL is returned if no matching name is found.  INCLUDE_xTaskGetHandle
1482  * must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available.
1483  *
1484  * \defgroup pcTaskGetHandle pcTaskGetHandle
1485  * \ingroup TaskUtils
1486  */
1487 TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION;     /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1488
1489 /**
1490  * task.h
1491  * <PRE>UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );</PRE>
1492  *
1493  * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for
1494  * this function to be available.
1495  *
1496  * Returns the high water mark of the stack associated with xTask.  That is,
1497  * the minimum free stack space there has been (in words, so on a 32 bit machine
1498  * a value of 1 means 4 bytes) since the task started.  The smaller the returned
1499  * number the closer the task has come to overflowing its stack.
1500  *
1501  * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
1502  * same except for their return type.  Using configSTACK_DEPTH_TYPE allows the
1503  * user to determine the return type.  It gets around the problem of the value
1504  * overflowing on 8-bit types without breaking backward compatibility for
1505  * applications that expect an 8-bit return type.
1506  *
1507  * @param xTask Handle of the task associated with the stack to be checked.
1508  * Set xTask to NULL to check the stack of the calling task.
1509  *
1510  * @return The smallest amount of free stack space there has been (in words, so
1511  * actual spaces on the stack rather than bytes) since the task referenced by
1512  * xTask was created.
1513  */
1514 UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1515
1516 /**
1517  * task.h
1518  * <PRE>configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask );</PRE>
1519  *
1520  * INCLUDE_uxTaskGetStackHighWaterMark2 must be set to 1 in FreeRTOSConfig.h for
1521  * this function to be available.
1522  *
1523  * Returns the high water mark of the stack associated with xTask.  That is,
1524  * the minimum free stack space there has been (in words, so on a 32 bit machine
1525  * a value of 1 means 4 bytes) since the task started.  The smaller the returned
1526  * number the closer the task has come to overflowing its stack.
1527  *
1528  * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
1529  * same except for their return type.  Using configSTACK_DEPTH_TYPE allows the
1530  * user to determine the return type.  It gets around the problem of the value
1531  * overflowing on 8-bit types without breaking backward compatibility for
1532  * applications that expect an 8-bit return type.
1533  *
1534  * @param xTask Handle of the task associated with the stack to be checked.
1535  * Set xTask to NULL to check the stack of the calling task.
1536  *
1537  * @return The smallest amount of free stack space there has been (in words, so
1538  * actual spaces on the stack rather than bytes) since the task referenced by
1539  * xTask was created.
1540  */
1541 configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1542
1543 /* When using trace macros it is sometimes necessary to include task.h before
1544  * FreeRTOS.h.  When this is done TaskHookFunction_t will not yet have been defined,
1545  * so the following two prototypes will cause a compilation error.  This can be
1546  * fixed by simply guarding against the inclusion of these two prototypes unless
1547  * they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration
1548  * constant. */
1549 #ifdef configUSE_APPLICATION_TASK_TAG
1550     #if configUSE_APPLICATION_TASK_TAG == 1
1551
1552 /**
1553  * task.h
1554  * <pre>
1555  * void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );
1556  * </pre>
1557  *
1558  * Sets pxHookFunction to be the task hook function used by the task xTask.
1559  * Passing xTask as NULL has the effect of setting the calling tasks hook
1560  * function.
1561  */
1562         void vTaskSetApplicationTaskTag( TaskHandle_t xTask,
1563                                          TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION;
1564
1565 /**
1566  * task.h
1567  * <pre>
1568  * void xTaskGetApplicationTaskTag( TaskHandle_t xTask );
1569  * </pre>
1570  *
1571  * Returns the pxHookFunction value assigned to the task xTask.  Do not
1572  * call from an interrupt service routine - call
1573  * xTaskGetApplicationTaskTagFromISR() instead.
1574  */
1575         TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1576
1577 /**
1578  * task.h
1579  * <pre>
1580  * void xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );
1581  * </pre>
1582  *
1583  * Returns the pxHookFunction value assigned to the task xTask.  Can
1584  * be called from an interrupt service routine.
1585  */
1586         TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1587     #endif /* configUSE_APPLICATION_TASK_TAG ==1 */
1588 #endif /* ifdef configUSE_APPLICATION_TASK_TAG */
1589
1590 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
1591
1592 /* Each task contains an array of pointers that is dimensioned by the
1593  * configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h.  The
1594  * kernel does not use the pointers itself, so the application writer can use
1595  * the pointers for any purpose they wish.  The following two functions are
1596  * used to set and query a pointer respectively. */
1597     void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet,
1598                                             BaseType_t xIndex,
1599                                             void * pvValue ) PRIVILEGED_FUNCTION;
1600     void * pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery,
1601                                                BaseType_t xIndex ) PRIVILEGED_FUNCTION;
1602
1603 #endif
1604
1605 #if ( configCHECK_FOR_STACK_OVERFLOW > 0 )
1606
1607      /**
1608       * task.h
1609       * <pre>void vApplicationStackOverflowHook( TaskHandle_t xTask char *pcTaskName); </pre>
1610       *
1611       * The application stack overflow hook is called when a stack overflow is detected for a task.
1612       *
1613       * Details on stack overflow detection can be found here: https://www.FreeRTOS.org/Stacks-and-stack-overflow-checking.html
1614       *
1615       * @param xTask the task that just exceeded its stack boundaries.
1616       * @param pcTaskName A character string containing the name of the offending task.
1617       */
1618      void vApplicationStackOverflowHook( TaskHandle_t xTask,
1619                                                char * pcTaskName );
1620
1621 #endif
1622
1623 #if  (  configUSE_TICK_HOOK > 0 )
1624     /**
1625      *  task.h
1626      *  <pre>void vApplicationTickHook( void ); </pre>
1627      *
1628      * This hook function is called in the system tick handler after any OS work is completed.
1629      */
1630     void vApplicationTickHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */
1631
1632 #endif
1633
1634 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1635     /**
1636      * task.h
1637      * <pre>void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) </pre>
1638      *
1639      * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Idle Task TCB.  This function is required when
1640      * configSUPPORT_STATIC_ALLOCATION is set.  For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION
1641      *
1642      * @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer
1643      * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task
1644      * @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
1645      */
1646     void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
1647                                                StackType_t ** ppxIdleTaskStackBuffer,
1648                                                uint32_t * pulIdleTaskStackSize ); /*lint !e526 Symbol not defined as it is an application callback. */
1649 #endif
1650
1651 /**
1652  * task.h
1653  * <pre>
1654  * BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );
1655  * </pre>
1656  *
1657  * Calls the hook function associated with xTask.  Passing xTask as NULL has
1658  * the effect of calling the Running tasks (the calling task) hook function.
1659  *
1660  * pvParameter is passed to the hook function for the task to interpret as it
1661  * wants.  The return value is the value returned by the task hook function
1662  * registered by the user.
1663  */
1664 BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask,
1665                                          void * pvParameter ) PRIVILEGED_FUNCTION;
1666
1667 /**
1668  * xTaskGetIdleTaskHandle() is only available if
1669  * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.
1670  *
1671  * Simply returns the handle of the idle task.  It is not valid to call
1672  * xTaskGetIdleTaskHandle() before the scheduler has been started.
1673  */
1674 TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
1675
1676 /**
1677  * configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for
1678  * uxTaskGetSystemState() to be available.
1679  *
1680  * uxTaskGetSystemState() populates an TaskStatus_t structure for each task in
1681  * the system.  TaskStatus_t structures contain, among other things, members
1682  * for the task handle, task name, task priority, task state, and total amount
1683  * of run time consumed by the task.  See the TaskStatus_t structure
1684  * definition in this file for the full member list.
1685  *
1686  * NOTE:  This function is intended for debugging use only as its use results in
1687  * the scheduler remaining suspended for an extended period.
1688  *
1689  * @param pxTaskStatusArray A pointer to an array of TaskStatus_t structures.
1690  * The array must contain at least one TaskStatus_t structure for each task
1691  * that is under the control of the RTOS.  The number of tasks under the control
1692  * of the RTOS can be determined using the uxTaskGetNumberOfTasks() API function.
1693  *
1694  * @param uxArraySize The size of the array pointed to by the pxTaskStatusArray
1695  * parameter.  The size is specified as the number of indexes in the array, or
1696  * the number of TaskStatus_t structures contained in the array, not by the
1697  * number of bytes in the array.
1698  *
1699  * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in
1700  * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the
1701  * total run time (as defined by the run time stats clock, see
1702  * https://www.FreeRTOS.org/rtos-run-time-stats.html) since the target booted.
1703  * pulTotalRunTime can be set to NULL to omit the total run time information.
1704  *
1705  * @return The number of TaskStatus_t structures that were populated by
1706  * uxTaskGetSystemState().  This should equal the number returned by the
1707  * uxTaskGetNumberOfTasks() API function, but will be zero if the value passed
1708  * in the uxArraySize parameter was too small.
1709  *
1710  * Example usage:
1711  * <pre>
1712  *  // This example demonstrates how a human readable table of run time stats
1713  *  // information is generated from raw data provided by uxTaskGetSystemState().
1714  *  // The human readable table is written to pcWriteBuffer
1715  *  void vTaskGetRunTimeStats( char *pcWriteBuffer )
1716  *  {
1717  *  TaskStatus_t *pxTaskStatusArray;
1718  *  volatile UBaseType_t uxArraySize, x;
1719  *  uint32_t ulTotalRunTime, ulStatsAsPercentage;
1720  *
1721  *      // Make sure the write buffer does not contain a string.
1722  * pcWriteBuffer = 0x00;
1723  *
1724  *      // Take a snapshot of the number of tasks in case it changes while this
1725  *      // function is executing.
1726  *      uxArraySize = uxTaskGetNumberOfTasks();
1727  *
1728  *      // Allocate a TaskStatus_t structure for each task.  An array could be
1729  *      // allocated statically at compile time.
1730  *      pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
1731  *
1732  *      if( pxTaskStatusArray != NULL )
1733  *      {
1734  *          // Generate raw status information about each task.
1735  *          uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );
1736  *
1737  *          // For percentage calculations.
1738  *          ulTotalRunTime /= 100UL;
1739  *
1740  *          // Avoid divide by zero errors.
1741  *          if( ulTotalRunTime > 0 )
1742  *          {
1743  *              // For each populated position in the pxTaskStatusArray array,
1744  *              // format the raw data as human readable ASCII data
1745  *              for( x = 0; x < uxArraySize; x++ )
1746  *              {
1747  *                  // What percentage of the total run time has the task used?
1748  *                  // This will always be rounded down to the nearest integer.
1749  *                  // ulTotalRunTimeDiv100 has already been divided by 100.
1750  *                  ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;
1751  *
1752  *                  if( ulStatsAsPercentage > 0UL )
1753  *                  {
1754  *                      sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
1755  *                  }
1756  *                  else
1757  *                  {
1758  *                      // If the percentage is zero here then the task has
1759  *                      // consumed less than 1% of the total run time.
1760  *                      sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );
1761  *                  }
1762  *
1763  *                  pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );
1764  *              }
1765  *          }
1766  *
1767  *          // The array is no longer needed, free the memory it consumes.
1768  *          vPortFree( pxTaskStatusArray );
1769  *      }
1770  *  }
1771  *  </pre>
1772  */
1773 UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray,
1774                                   const UBaseType_t uxArraySize,
1775                                   uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION;
1776
1777 /**
1778  * task. h
1779  * <PRE>void vTaskList( char *pcWriteBuffer );</PRE>
1780  *
1781  * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must
1782  * both be defined as 1 for this function to be available.  See the
1783  * configuration section of the FreeRTOS.org website for more information.
1784  *
1785  * NOTE 1: This function will disable interrupts for its duration.  It is
1786  * not intended for normal application runtime use but as a debug aid.
1787  *
1788  * Lists all the current tasks, along with their current state and stack
1789  * usage high water mark.
1790  *
1791  * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or
1792  * suspended ('S').
1793  *
1794  * PLEASE NOTE:
1795  *
1796  * This function is provided for convenience only, and is used by many of the
1797  * demo applications.  Do not consider it to be part of the scheduler.
1798  *
1799  * vTaskList() calls uxTaskGetSystemState(), then formats part of the
1800  * uxTaskGetSystemState() output into a human readable table that displays task:
1801  * names, states, priority, stack usage and task number.
1802  * Stack usage specified as the number of unused StackType_t words stack can hold
1803  * on top of stack - not the number of bytes.
1804  *
1805  * vTaskList() has a dependency on the sprintf() C library function that might
1806  * bloat the code size, use a lot of stack, and provide different results on
1807  * different platforms.  An alternative, tiny, third party, and limited
1808  * functionality implementation of sprintf() is provided in many of the
1809  * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
1810  * printf-stdarg.c does not provide a full snprintf() implementation!).
1811  *
1812  * It is recommended that production systems call uxTaskGetSystemState()
1813  * directly to get access to raw stats data, rather than indirectly through a
1814  * call to vTaskList().
1815  *
1816  * @param pcWriteBuffer A buffer into which the above mentioned details
1817  * will be written, in ASCII form.  This buffer is assumed to be large
1818  * enough to contain the generated report.  Approximately 40 bytes per
1819  * task should be sufficient.
1820  *
1821  * \defgroup vTaskList vTaskList
1822  * \ingroup TaskUtils
1823  */
1824 void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION;     /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1825
1826 /**
1827  * task. h
1828  * <PRE>void vTaskGetRunTimeStats( char *pcWriteBuffer );</PRE>
1829  *
1830  * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
1831  * must both be defined as 1 for this function to be available.  The application
1832  * must also then provide definitions for
1833  * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
1834  * to configure a peripheral timer/counter and return the timers current count
1835  * value respectively.  The counter should be at least 10 times the frequency of
1836  * the tick count.
1837  *
1838  * NOTE 1: This function will disable interrupts for its duration.  It is
1839  * not intended for normal application runtime use but as a debug aid.
1840  *
1841  * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
1842  * accumulated execution time being stored for each task.  The resolution
1843  * of the accumulated time value depends on the frequency of the timer
1844  * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
1845  * Calling vTaskGetRunTimeStats() writes the total execution time of each
1846  * task into a buffer, both as an absolute count value and as a percentage
1847  * of the total system execution time.
1848  *
1849  * NOTE 2:
1850  *
1851  * This function is provided for convenience only, and is used by many of the
1852  * demo applications.  Do not consider it to be part of the scheduler.
1853  *
1854  * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the
1855  * uxTaskGetSystemState() output into a human readable table that displays the
1856  * amount of time each task has spent in the Running state in both absolute and
1857  * percentage terms.
1858  *
1859  * vTaskGetRunTimeStats() has a dependency on the sprintf() C library function
1860  * that might bloat the code size, use a lot of stack, and provide different
1861  * results on different platforms.  An alternative, tiny, third party, and
1862  * limited functionality implementation of sprintf() is provided in many of the
1863  * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
1864  * printf-stdarg.c does not provide a full snprintf() implementation!).
1865  *
1866  * It is recommended that production systems call uxTaskGetSystemState() directly
1867  * to get access to raw stats data, rather than indirectly through a call to
1868  * vTaskGetRunTimeStats().
1869  *
1870  * @param pcWriteBuffer A buffer into which the execution times will be
1871  * written, in ASCII form.  This buffer is assumed to be large enough to
1872  * contain the generated report.  Approximately 40 bytes per task should
1873  * be sufficient.
1874  *
1875  * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats
1876  * \ingroup TaskUtils
1877  */
1878 void vTaskGetRunTimeStats( char * pcWriteBuffer ) PRIVILEGED_FUNCTION;     /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1879
1880 /**
1881  * task. h
1882  * <PRE>uint32_t ulTaskGetIdleRunTimeCounter( void );</PRE>
1883  *
1884  * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
1885  * must both be defined as 1 for this function to be available.  The application
1886  * must also then provide definitions for
1887  * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
1888  * to configure a peripheral timer/counter and return the timers current count
1889  * value respectively.  The counter should be at least 10 times the frequency of
1890  * the tick count.
1891  *
1892  * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
1893  * accumulated execution time being stored for each task.  The resolution
1894  * of the accumulated time value depends on the frequency of the timer
1895  * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
1896  * While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total
1897  * execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter()
1898  * returns the total execution time of just the idle task.
1899  *
1900  * @return The total run time of the idle task.  This is the amount of time the
1901  * idle task has actually been executing.  The unit of time is dependent on the
1902  * frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
1903  * portGET_RUN_TIME_COUNTER_VALUE() macros.
1904  *
1905  * \defgroup ulTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter
1906  * \ingroup TaskUtils
1907  */
1908 uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION;
1909
1910 /**
1911  * task. h
1912  * <PRE>BaseType_t xTaskNotifyIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction );</PRE>
1913  * <PRE>BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );</PRE>
1914  *
1915  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
1916  *
1917  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
1918  * functions to be available.
1919  *
1920  * Sends a direct to task notification to a task, with an optional value and
1921  * action.
1922  *
1923  * Each task has a private array of "notification values" (or 'notifications'),
1924  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
1925  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
1926  * array, and (for backward compatibility) defaults to 1 if left undefined.
1927  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
1928  *
1929  * Events can be sent to a task using an intermediary object.  Examples of such
1930  * objects are queues, semaphores, mutexes and event groups.  Task notifications
1931  * are a method of sending an event directly to a task without the need for such
1932  * an intermediary object.
1933  *
1934  * A notification sent to a task can optionally perform an action, such as
1935  * update, overwrite or increment one of the task's notification values.  In
1936  * that way task notifications can be used to send data to a task, or be used as
1937  * light weight and fast binary or counting semaphores.
1938  *
1939  * A task can use xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() to
1940  * [optionally] block to wait for a notification to be pending.  The task does
1941  * not consume any CPU time while it is in the Blocked state.
1942  *
1943  * A notification sent to a task will remain pending until it is cleared by the
1944  * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
1945  * un-indexed equivalents).  If the task was already in the Blocked state to
1946  * wait for a notification when the notification arrives then the task will
1947  * automatically be removed from the Blocked state (unblocked) and the
1948  * notification cleared.
1949  *
1950  * **NOTE** Each notification within the array operates independently - a task
1951  * can only block on one notification within the array at a time and will not be
1952  * unblocked by a notification sent to any other array index.
1953  *
1954  * Backward compatibility information:
1955  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
1956  * all task notification API functions operated on that value. Replacing the
1957  * single notification value with an array of notification values necessitated a
1958  * new set of API functions that could address specific notifications within the
1959  * array.  xTaskNotify() is the original API function, and remains backward
1960  * compatible by always operating on the notification value at index 0 in the
1961  * array. Calling xTaskNotify() is equivalent to calling xTaskNotifyIndexed()
1962  * with the uxIndexToNotify parameter set to 0.
1963  *
1964  * @param xTaskToNotify The handle of the task being notified.  The handle to a
1965  * task can be returned from the xTaskCreate() API function used to create the
1966  * task, and the handle of the currently running task can be obtained by calling
1967  * xTaskGetCurrentTaskHandle().
1968  *
1969  * @param uxIndexToNotify The index within the target task's array of
1970  * notification values to which the notification is to be sent.  uxIndexToNotify
1971  * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.  xTaskNotify() does
1972  * not have this parameter and always sends notifications to index 0.
1973  *
1974  * @param ulValue Data that can be sent with the notification.  How the data is
1975  * used depends on the value of the eAction parameter.
1976  *
1977  * @param eAction Specifies how the notification updates the task's notification
1978  * value, if at all.  Valid values for eAction are as follows:
1979  *
1980  * eSetBits -
1981  * The target notification value is bitwise ORed with ulValue.
1982  * xTaskNotifyIndexed() always returns pdPASS in this case.
1983  *
1984  * eIncrement -
1985  * The target notification value is incremented.  ulValue is not used and
1986  * xTaskNotifyIndexed() always returns pdPASS in this case.
1987  *
1988  * eSetValueWithOverwrite -
1989  * The target notification value is set to the value of ulValue, even if the
1990  * task being notified had not yet processed the previous notification at the
1991  * same array index (the task already had a notification pending at that index).
1992  * xTaskNotifyIndexed() always returns pdPASS in this case.
1993  *
1994  * eSetValueWithoutOverwrite -
1995  * If the task being notified did not already have a notification pending at the
1996  * same array index then the target notification value is set to ulValue and
1997  * xTaskNotifyIndexed() will return pdPASS.  If the task being notified already
1998  * had a notification pending at the same array index then no action is
1999  * performed and pdFAIL is returned.
2000  *
2001  * eNoAction -
2002  * The task receives a notification at the specified array index without the
2003  * notification value at that index being updated.  ulValue is not used and
2004  * xTaskNotifyIndexed() always returns pdPASS in this case.
2005  *
2006  * pulPreviousNotificationValue -
2007  * Can be used to pass out the subject task's notification value before any
2008  * bits are modified by the notify function.
2009  *
2010  * @return Dependent on the value of eAction.  See the description of the
2011  * eAction parameter.
2012  *
2013  * \defgroup xTaskNotifyIndexed xTaskNotifyIndexed
2014  * \ingroup TaskNotifications
2015  */
2016 BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify,
2017                                UBaseType_t uxIndexToNotify,
2018                                uint32_t ulValue,
2019                                eNotifyAction eAction,
2020                                uint32_t * pulPreviousNotificationValue ) PRIVILEGED_FUNCTION;
2021 #define xTaskNotify( xTaskToNotify, ulValue, eAction ) \
2022     xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL )
2023 #define xTaskNotifyIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction ) \
2024     xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL )
2025
2026 /**
2027  * task. h
2028  * <PRE>BaseType_t xTaskNotifyAndQueryIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue );</PRE>
2029  * <PRE>BaseType_t xTaskNotifyAndQuery( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue );</PRE>
2030  *
2031  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2032  *
2033  * xTaskNotifyAndQueryIndexed() performs the same operation as
2034  * xTaskNotifyIndexed() with the addition that it also returns the subject
2035  * task's prior notification value (the notification value at the time the
2036  * function is called rather than when the function returns) in the additional
2037  * pulPreviousNotifyValue parameter.
2038  *
2039  * xTaskNotifyAndQuery() performs the same operation as xTaskNotify() with the
2040  * addition that it also returns the subject task's prior notification value
2041  * (the notification value as it was at the time the function is called, rather
2042  * than when the function returns) in the additional pulPreviousNotifyValue
2043  * parameter.
2044  *
2045  * \defgroup xTaskNotifyAndQueryIndexed xTaskNotifyAndQueryIndexed
2046  * \ingroup TaskNotifications
2047  */
2048 #define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) \
2049     xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
2050 #define xTaskNotifyAndQueryIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotifyValue ) \
2051     xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
2052
2053 /**
2054  * task. h
2055  * <PRE>BaseType_t xTaskNotifyIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );</PRE>
2056  * <PRE>BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );</PRE>
2057  *
2058  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2059  *
2060  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2061  * functions to be available.
2062  *
2063  * A version of xTaskNotifyIndexed() that can be used from an interrupt service
2064  * routine (ISR).
2065  *
2066  * Each task has a private array of "notification values" (or 'notifications'),
2067  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
2068  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2069  * array, and (for backward compatibility) defaults to 1 if left undefined.
2070  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2071  *
2072  * Events can be sent to a task using an intermediary object.  Examples of such
2073  * objects are queues, semaphores, mutexes and event groups.  Task notifications
2074  * are a method of sending an event directly to a task without the need for such
2075  * an intermediary object.
2076  *
2077  * A notification sent to a task can optionally perform an action, such as
2078  * update, overwrite or increment one of the task's notification values.  In
2079  * that way task notifications can be used to send data to a task, or be used as
2080  * light weight and fast binary or counting semaphores.
2081  *
2082  * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a
2083  * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block
2084  * to wait for a notification value to have a non-zero value.  The task does
2085  * not consume any CPU time while it is in the Blocked state.
2086  *
2087  * A notification sent to a task will remain pending until it is cleared by the
2088  * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
2089  * un-indexed equivalents).  If the task was already in the Blocked state to
2090  * wait for a notification when the notification arrives then the task will
2091  * automatically be removed from the Blocked state (unblocked) and the
2092  * notification cleared.
2093  *
2094  * **NOTE** Each notification within the array operates independently - a task
2095  * can only block on one notification within the array at a time and will not be
2096  * unblocked by a notification sent to any other array index.
2097  *
2098  * Backward compatibility information:
2099  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2100  * all task notification API functions operated on that value. Replacing the
2101  * single notification value with an array of notification values necessitated a
2102  * new set of API functions that could address specific notifications within the
2103  * array.  xTaskNotifyFromISR() is the original API function, and remains
2104  * backward compatible by always operating on the notification value at index 0
2105  * within the array. Calling xTaskNotifyFromISR() is equivalent to calling
2106  * xTaskNotifyIndexedFromISR() with the uxIndexToNotify parameter set to 0.
2107  *
2108  * @param uxIndexToNotify The index within the target task's array of
2109  * notification values to which the notification is to be sent.  uxIndexToNotify
2110  * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.  xTaskNotifyFromISR()
2111  * does not have this parameter and always sends notifications to index 0.
2112  *
2113  * @param xTaskToNotify The handle of the task being notified.  The handle to a
2114  * task can be returned from the xTaskCreate() API function used to create the
2115  * task, and the handle of the currently running task can be obtained by calling
2116  * xTaskGetCurrentTaskHandle().
2117  *
2118  * @param ulValue Data that can be sent with the notification.  How the data is
2119  * used depends on the value of the eAction parameter.
2120  *
2121  * @param eAction Specifies how the notification updates the task's notification
2122  * value, if at all.  Valid values for eAction are as follows:
2123  *
2124  * eSetBits -
2125  * The task's notification value is bitwise ORed with ulValue.  xTaskNotify()
2126  * always returns pdPASS in this case.
2127  *
2128  * eIncrement -
2129  * The task's notification value is incremented.  ulValue is not used and
2130  * xTaskNotify() always returns pdPASS in this case.
2131  *
2132  * eSetValueWithOverwrite -
2133  * The task's notification value is set to the value of ulValue, even if the
2134  * task being notified had not yet processed the previous notification (the
2135  * task already had a notification pending).  xTaskNotify() always returns
2136  * pdPASS in this case.
2137  *
2138  * eSetValueWithoutOverwrite -
2139  * If the task being notified did not already have a notification pending then
2140  * the task's notification value is set to ulValue and xTaskNotify() will
2141  * return pdPASS.  If the task being notified already had a notification
2142  * pending then no action is performed and pdFAIL is returned.
2143  *
2144  * eNoAction -
2145  * The task receives a notification without its notification value being
2146  * updated.  ulValue is not used and xTaskNotify() always returns pdPASS in
2147  * this case.
2148  *
2149  * @param pxHigherPriorityTaskWoken  xTaskNotifyFromISR() will set
2150  * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
2151  * task to which the notification was sent to leave the Blocked state, and the
2152  * unblocked task has a priority higher than the currently running task.  If
2153  * xTaskNotifyFromISR() sets this value to pdTRUE then a context switch should
2154  * be requested before the interrupt is exited.  How a context switch is
2155  * requested from an ISR is dependent on the port - see the documentation page
2156  * for the port in use.
2157  *
2158  * @return Dependent on the value of eAction.  See the description of the
2159  * eAction parameter.
2160  *
2161  * \defgroup xTaskNotifyIndexedFromISR xTaskNotifyIndexedFromISR
2162  * \ingroup TaskNotifications
2163  */
2164 BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify,
2165                                       UBaseType_t uxIndexToNotify,
2166                                       uint32_t ulValue,
2167                                       eNotifyAction eAction,
2168                                       uint32_t * pulPreviousNotificationValue,
2169                                       BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
2170 #define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \
2171     xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
2172 #define xTaskNotifyIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \
2173     xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
2174
2175 /**
2176  * task. h
2177  * <PRE>BaseType_t xTaskNotifyAndQueryIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken );</PRE>
2178  * <PRE>BaseType_t xTaskNotifyAndQueryFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken );</PRE>
2179  *
2180  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2181  *
2182  * xTaskNotifyAndQueryIndexedFromISR() performs the same operation as
2183  * xTaskNotifyIndexedFromISR() with the addition that it also returns the
2184  * subject task's prior notification value (the notification value at the time
2185  * the function is called rather than at the time the function returns) in the
2186  * additional pulPreviousNotifyValue parameter.
2187  *
2188  * xTaskNotifyAndQueryFromISR() performs the same operation as
2189  * xTaskNotifyFromISR() with the addition that it also returns the subject
2190  * task's prior notification value (the notification value at the time the
2191  * function is called rather than at the time the function returns) in the
2192  * additional pulPreviousNotifyValue parameter.
2193  *
2194  * \defgroup xTaskNotifyAndQueryIndexedFromISR xTaskNotifyAndQueryIndexedFromISR
2195  * \ingroup TaskNotifications
2196  */
2197 #define xTaskNotifyAndQueryIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \
2198     xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
2199 #define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \
2200     xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
2201
2202 /**
2203  * task. h
2204  * <pre>
2205  * BaseType_t xTaskNotifyWaitIndexed( UBaseType_t uxIndexToWaitOn, uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
2206  *
2207  * BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
2208  * </pre>
2209  *
2210  * Waits for a direct to task notification to be pending at a given index within
2211  * an array of direct to task notifications.
2212  *
2213  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2214  *
2215  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
2216  * function to be available.
2217  *
2218  * Each task has a private array of "notification values" (or 'notifications'),
2219  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
2220  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2221  * array, and (for backward compatibility) defaults to 1 if left undefined.
2222  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2223  *
2224  * Events can be sent to a task using an intermediary object.  Examples of such
2225  * objects are queues, semaphores, mutexes and event groups.  Task notifications
2226  * are a method of sending an event directly to a task without the need for such
2227  * an intermediary object.
2228  *
2229  * A notification sent to a task can optionally perform an action, such as
2230  * update, overwrite or increment one of the task's notification values.  In
2231  * that way task notifications can be used to send data to a task, or be used as
2232  * light weight and fast binary or counting semaphores.
2233  *
2234  * A notification sent to a task will remain pending until it is cleared by the
2235  * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
2236  * un-indexed equivalents).  If the task was already in the Blocked state to
2237  * wait for a notification when the notification arrives then the task will
2238  * automatically be removed from the Blocked state (unblocked) and the
2239  * notification cleared.
2240  *
2241  * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a
2242  * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block
2243  * to wait for a notification value to have a non-zero value.  The task does
2244  * not consume any CPU time while it is in the Blocked state.
2245  *
2246  * **NOTE** Each notification within the array operates independently - a task
2247  * can only block on one notification within the array at a time and will not be
2248  * unblocked by a notification sent to any other array index.
2249  *
2250  * Backward compatibility information:
2251  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2252  * all task notification API functions operated on that value. Replacing the
2253  * single notification value with an array of notification values necessitated a
2254  * new set of API functions that could address specific notifications within the
2255  * array.  xTaskNotifyWait() is the original API function, and remains backward
2256  * compatible by always operating on the notification value at index 0 in the
2257  * array. Calling xTaskNotifyWait() is equivalent to calling
2258  * xTaskNotifyWaitIndexed() with the uxIndexToWaitOn parameter set to 0.
2259  *
2260  * @param uxIndexToWaitOn The index within the calling task's array of
2261  * notification values on which the calling task will wait for a notification to
2262  * be received.  uxIndexToWaitOn must be less than
2263  * configTASK_NOTIFICATION_ARRAY_ENTRIES.  xTaskNotifyWait() does
2264  * not have this parameter and always waits for notifications on index 0.
2265  *
2266  * @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value
2267  * will be cleared in the calling task's notification value before the task
2268  * checks to see if any notifications are pending, and optionally blocks if no
2269  * notifications are pending.  Setting ulBitsToClearOnEntry to ULONG_MAX (if
2270  * limits.h is included) or 0xffffffffUL (if limits.h is not included) will have
2271  * the effect of resetting the task's notification value to 0.  Setting
2272  * ulBitsToClearOnEntry to 0 will leave the task's notification value unchanged.
2273  *
2274  * @param ulBitsToClearOnExit If a notification is pending or received before
2275  * the calling task exits the xTaskNotifyWait() function then the task's
2276  * notification value (see the xTaskNotify() API function) is passed out using
2277  * the pulNotificationValue parameter.  Then any bits that are set in
2278  * ulBitsToClearOnExit will be cleared in the task's notification value (note
2279  * *pulNotificationValue is set before any bits are cleared).  Setting
2280  * ulBitsToClearOnExit to ULONG_MAX (if limits.h is included) or 0xffffffffUL
2281  * (if limits.h is not included) will have the effect of resetting the task's
2282  * notification value to 0 before the function exits.  Setting
2283  * ulBitsToClearOnExit to 0 will leave the task's notification value unchanged
2284  * when the function exits (in which case the value passed out in
2285  * pulNotificationValue will match the task's notification value).
2286  *
2287  * @param pulNotificationValue Used to pass the task's notification value out
2288  * of the function.  Note the value passed out will not be effected by the
2289  * clearing of any bits caused by ulBitsToClearOnExit being non-zero.
2290  *
2291  * @param xTicksToWait The maximum amount of time that the task should wait in
2292  * the Blocked state for a notification to be received, should a notification
2293  * not already be pending when xTaskNotifyWait() was called.  The task
2294  * will not consume any processing time while it is in the Blocked state.  This
2295  * is specified in kernel ticks, the macro pdMS_TO_TICKS( value_in_ms ) can be
2296  * used to convert a time specified in milliseconds to a time specified in
2297  * ticks.
2298  *
2299  * @return If a notification was received (including notifications that were
2300  * already pending when xTaskNotifyWait was called) then pdPASS is
2301  * returned.  Otherwise pdFAIL is returned.
2302  *
2303  * \defgroup xTaskNotifyWaitIndexed xTaskNotifyWaitIndexed
2304  * \ingroup TaskNotifications
2305  */
2306 BaseType_t xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn,
2307                                    uint32_t ulBitsToClearOnEntry,
2308                                    uint32_t ulBitsToClearOnExit,
2309                                    uint32_t * pulNotificationValue,
2310                                    TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2311 #define xTaskNotifyWait( ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \
2312     xTaskGenericNotifyWait( tskDEFAULT_INDEX_TO_NOTIFY, ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) )
2313 #define xTaskNotifyWaitIndexed( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \
2314     xTaskGenericNotifyWait( ( uxIndexToWaitOn ), ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) )
2315
2316 /**
2317  * task. h
2318  * <PRE>BaseType_t xTaskNotifyGiveIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify );</PRE>
2319  * <PRE>BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );</PRE>
2320  *
2321  * Sends a direct to task notification to a particular index in the target
2322  * task's notification array in a manner similar to giving a counting semaphore.
2323  *
2324  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
2325  *
2326  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2327  * macros to be available.
2328  *
2329  * Each task has a private array of "notification values" (or 'notifications'),
2330  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
2331  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2332  * array, and (for backward compatibility) defaults to 1 if left undefined.
2333  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2334  *
2335  * Events can be sent to a task using an intermediary object.  Examples of such
2336  * objects are queues, semaphores, mutexes and event groups.  Task notifications
2337  * are a method of sending an event directly to a task without the need for such
2338  * an intermediary object.
2339  *
2340  * A notification sent to a task can optionally perform an action, such as
2341  * update, overwrite or increment one of the task's notification values.  In
2342  * that way task notifications can be used to send data to a task, or be used as
2343  * light weight and fast binary or counting semaphores.
2344  *
2345  * xTaskNotifyGiveIndexed() is a helper macro intended for use when task
2346  * notifications are used as light weight and faster binary or counting
2347  * semaphore equivalents.  Actual FreeRTOS semaphores are given using the
2348  * xSemaphoreGive() API function, the equivalent action that instead uses a task
2349  * notification is xTaskNotifyGiveIndexed().
2350  *
2351  * When task notifications are being used as a binary or counting semaphore
2352  * equivalent then the task being notified should wait for the notification
2353  * using the ulTaskNotificationTakeIndexed() API function rather than the
2354  * xTaskNotifyWaitIndexed() API function.
2355  *
2356  * **NOTE** Each notification within the array operates independently - a task
2357  * can only block on one notification within the array at a time and will not be
2358  * unblocked by a notification sent to any other array index.
2359  *
2360  * Backward compatibility information:
2361  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2362  * all task notification API functions operated on that value. Replacing the
2363  * single notification value with an array of notification values necessitated a
2364  * new set of API functions that could address specific notifications within the
2365  * array.  xTaskNotifyGive() is the original API function, and remains backward
2366  * compatible by always operating on the notification value at index 0 in the
2367  * array. Calling xTaskNotifyGive() is equivalent to calling
2368  * xTaskNotifyGiveIndexed() with the uxIndexToNotify parameter set to 0.
2369  *
2370  * @param xTaskToNotify The handle of the task being notified.  The handle to a
2371  * task can be returned from the xTaskCreate() API function used to create the
2372  * task, and the handle of the currently running task can be obtained by calling
2373  * xTaskGetCurrentTaskHandle().
2374  *
2375  * @param uxIndexToNotify The index within the target task's array of
2376  * notification values to which the notification is to be sent.  uxIndexToNotify
2377  * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.  xTaskNotifyGive()
2378  * does not have this parameter and always sends notifications to index 0.
2379  *
2380  * @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the
2381  * eAction parameter set to eIncrement - so pdPASS is always returned.
2382  *
2383  * \defgroup xTaskNotifyGiveIndexed xTaskNotifyGiveIndexed
2384  * \ingroup TaskNotifications
2385  */
2386 #define xTaskNotifyGive( xTaskToNotify ) \
2387     xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( 0 ), eIncrement, NULL )
2388 #define xTaskNotifyGiveIndexed( xTaskToNotify, uxIndexToNotify ) \
2389     xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( 0 ), eIncrement, NULL )
2390
2391 /**
2392  * task. h
2393  * <PRE>void vTaskNotifyGiveIndexedFromISR( TaskHandle_t xTaskHandle, UBaseType_t uxIndexToNotify, BaseType_t *pxHigherPriorityTaskWoken );</PRE>
2394  * <PRE>void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );</PRE>
2395  *
2396  * A version of xTaskNotifyGiveIndexed() that can be called from an interrupt
2397  * service routine (ISR).
2398  *
2399  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
2400  *
2401  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro
2402  * to be available.
2403  *
2404  * Each task has a private array of "notification values" (or 'notifications'),
2405  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
2406  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2407  * array, and (for backward compatibility) defaults to 1 if left undefined.
2408  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2409  *
2410  * Events can be sent to a task using an intermediary object.  Examples of such
2411  * objects are queues, semaphores, mutexes and event groups.  Task notifications
2412  * are a method of sending an event directly to a task without the need for such
2413  * an intermediary object.
2414  *
2415  * A notification sent to a task can optionally perform an action, such as
2416  * update, overwrite or increment one of the task's notification values.  In
2417  * that way task notifications can be used to send data to a task, or be used as
2418  * light weight and fast binary or counting semaphores.
2419  *
2420  * vTaskNotifyGiveIndexedFromISR() is intended for use when task notifications
2421  * are used as light weight and faster binary or counting semaphore equivalents.
2422  * Actual FreeRTOS semaphores are given from an ISR using the
2423  * xSemaphoreGiveFromISR() API function, the equivalent action that instead uses
2424  * a task notification is vTaskNotifyGiveIndexedFromISR().
2425  *
2426  * When task notifications are being used as a binary or counting semaphore
2427  * equivalent then the task being notified should wait for the notification
2428  * using the ulTaskNotificationTakeIndexed() API function rather than the
2429  * xTaskNotifyWaitIndexed() API function.
2430  *
2431  * **NOTE** Each notification within the array operates independently - a task
2432  * can only block on one notification within the array at a time and will not be
2433  * unblocked by a notification sent to any other array index.
2434  *
2435  * Backward compatibility information:
2436  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2437  * all task notification API functions operated on that value. Replacing the
2438  * single notification value with an array of notification values necessitated a
2439  * new set of API functions that could address specific notifications within the
2440  * array.  xTaskNotifyFromISR() is the original API function, and remains
2441  * backward compatible by always operating on the notification value at index 0
2442  * within the array. Calling xTaskNotifyGiveFromISR() is equivalent to calling
2443  * xTaskNotifyGiveIndexedFromISR() with the uxIndexToNotify parameter set to 0.
2444  *
2445  * @param xTaskToNotify The handle of the task being notified.  The handle to a
2446  * task can be returned from the xTaskCreate() API function used to create the
2447  * task, and the handle of the currently running task can be obtained by calling
2448  * xTaskGetCurrentTaskHandle().
2449  *
2450  * @param uxIndexToNotify The index within the target task's array of
2451  * notification values to which the notification is to be sent.  uxIndexToNotify
2452  * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
2453  * xTaskNotifyGiveFromISR() does not have this parameter and always sends
2454  * notifications to index 0.
2455  *
2456  * @param pxHigherPriorityTaskWoken  vTaskNotifyGiveFromISR() will set
2457  * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
2458  * task to which the notification was sent to leave the Blocked state, and the
2459  * unblocked task has a priority higher than the currently running task.  If
2460  * vTaskNotifyGiveFromISR() sets this value to pdTRUE then a context switch
2461  * should be requested before the interrupt is exited.  How a context switch is
2462  * requested from an ISR is dependent on the port - see the documentation page
2463  * for the port in use.
2464  *
2465  * \defgroup vTaskNotifyGiveIndexedFromISR vTaskNotifyGiveIndexedFromISR
2466  * \ingroup TaskNotifications
2467  */
2468 void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify,
2469                                     UBaseType_t uxIndexToNotify,
2470                                     BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
2471 #define vTaskNotifyGiveFromISR( xTaskToNotify, pxHigherPriorityTaskWoken ) \
2472     vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( pxHigherPriorityTaskWoken ) );
2473 #define vTaskNotifyGiveIndexedFromISR( xTaskToNotify, uxIndexToNotify, pxHigherPriorityTaskWoken ) \
2474     vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( pxHigherPriorityTaskWoken ) );
2475
2476 /**
2477  * task. h
2478  * <pre>
2479  * uint32_t ulTaskNotifyTakeIndexed( UBaseType_t uxIndexToWaitOn, BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
2480  *
2481  * uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
2482  * </pre>
2483  *
2484  * Waits for a direct to task notification on a particular index in the calling
2485  * task's notification array in a manner similar to taking a counting semaphore.
2486  *
2487  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2488  *
2489  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
2490  * function to be available.
2491  *
2492  * Each task has a private array of "notification values" (or 'notifications'),
2493  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
2494  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2495  * array, and (for backward compatibility) defaults to 1 if left undefined.
2496  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2497  *
2498  * Events can be sent to a task using an intermediary object.  Examples of such
2499  * objects are queues, semaphores, mutexes and event groups.  Task notifications
2500  * are a method of sending an event directly to a task without the need for such
2501  * an intermediary object.
2502  *
2503  * A notification sent to a task can optionally perform an action, such as
2504  * update, overwrite or increment one of the task's notification values.  In
2505  * that way task notifications can be used to send data to a task, or be used as
2506  * light weight and fast binary or counting semaphores.
2507  *
2508  * ulTaskNotifyTakeIndexed() is intended for use when a task notification is
2509  * used as a faster and lighter weight binary or counting semaphore alternative.
2510  * Actual FreeRTOS semaphores are taken using the xSemaphoreTake() API function,
2511  * the equivalent action that instead uses a task notification is
2512  * ulTaskNotifyTakeIndexed().
2513  *
2514  * When a task is using its notification value as a binary or counting semaphore
2515  * other tasks should send notifications to it using the xTaskNotifyGiveIndexed()
2516  * macro, or xTaskNotifyIndex() function with the eAction parameter set to
2517  * eIncrement.
2518  *
2519  * ulTaskNotifyTakeIndexed() can either clear the task's notification value at
2520  * the array index specified by the uxIndexToWaitOn parameter to zero on exit,
2521  * in which case the notification value acts like a binary semaphore, or
2522  * decrement the notification value on exit, in which case the notification
2523  * value acts like a counting semaphore.
2524  *
2525  * A task can use ulTaskNotifyTakeIndexed() to [optionally] block to wait for
2526  * a notification.  The task does not consume any CPU time while it is in the
2527  * Blocked state.
2528  *
2529  * Where as xTaskNotifyWaitIndexed() will return when a notification is pending,
2530  * ulTaskNotifyTakeIndexed() will return when the task's notification value is
2531  * not zero.
2532  *
2533  * **NOTE** Each notification within the array operates independently - a task
2534  * can only block on one notification within the array at a time and will not be
2535  * unblocked by a notification sent to any other array index.
2536  *
2537  * Backward compatibility information:
2538  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2539  * all task notification API functions operated on that value. Replacing the
2540  * single notification value with an array of notification values necessitated a
2541  * new set of API functions that could address specific notifications within the
2542  * array.  ulTaskNotifyTake() is the original API function, and remains backward
2543  * compatible by always operating on the notification value at index 0 in the
2544  * array. Calling ulTaskNotifyTake() is equivalent to calling
2545  * ulTaskNotifyTakeIndexed() with the uxIndexToWaitOn parameter set to 0.
2546  *
2547  * @param uxIndexToWaitOn The index within the calling task's array of
2548  * notification values on which the calling task will wait for a notification to
2549  * be non-zero.  uxIndexToWaitOn must be less than
2550  * configTASK_NOTIFICATION_ARRAY_ENTRIES.  xTaskNotifyTake() does
2551  * not have this parameter and always waits for notifications on index 0.
2552  *
2553  * @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's
2554  * notification value is decremented when the function exits.  In this way the
2555  * notification value acts like a counting semaphore.  If xClearCountOnExit is
2556  * not pdFALSE then the task's notification value is cleared to zero when the
2557  * function exits.  In this way the notification value acts like a binary
2558  * semaphore.
2559  *
2560  * @param xTicksToWait The maximum amount of time that the task should wait in
2561  * the Blocked state for the task's notification value to be greater than zero,
2562  * should the count not already be greater than zero when
2563  * ulTaskNotifyTake() was called.  The task will not consume any processing
2564  * time while it is in the Blocked state.  This is specified in kernel ticks,
2565  * the macro pdMS_TO_TICKS( value_in_ms ) can be used to convert a time
2566  * specified in milliseconds to a time specified in ticks.
2567  *
2568  * @return The task's notification count before it is either cleared to zero or
2569  * decremented (see the xClearCountOnExit parameter).
2570  *
2571  * \defgroup ulTaskNotifyTakeIndexed ulTaskNotifyTakeIndexed
2572  * \ingroup TaskNotifications
2573  */
2574 uint32_t ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn,
2575                                   BaseType_t xClearCountOnExit,
2576                                   TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2577 #define ulTaskNotifyTake( xClearCountOnExit, xTicksToWait ) \
2578     ulTaskGenericNotifyTake( ( tskDEFAULT_INDEX_TO_NOTIFY ), ( xClearCountOnExit ), ( xTicksToWait ) )
2579 #define ulTaskNotifyTakeIndexed( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait ) \
2580     ulTaskGenericNotifyTake( ( uxIndexToWaitOn ), ( xClearCountOnExit ), ( xTicksToWait ) )
2581
2582 /**
2583  * task. h
2584  * <pre>
2585  * BaseType_t xTaskNotifyStateClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToCLear );
2586  *
2587  * BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
2588  * </pre>
2589  *
2590  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2591  *
2592  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2593  * functions to be available.
2594  *
2595  * Each task has a private array of "notification values" (or 'notifications'),
2596  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
2597  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2598  * array, and (for backward compatibility) defaults to 1 if left undefined.
2599  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2600  *
2601  * If a notification is sent to an index within the array of notifications then
2602  * the notification at that index is said to be 'pending' until it is read or
2603  * explicitly cleared by the receiving task.  xTaskNotifyStateClearIndexed()
2604  * is the function that clears a pending notification without reading the
2605  * notification value.  The notification value at the same array index is not
2606  * altered.  Set xTask to NULL to clear the notification state of the calling
2607  * task.
2608  *
2609  * Backward compatibility information:
2610  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2611  * all task notification API functions operated on that value. Replacing the
2612  * single notification value with an array of notification values necessitated a
2613  * new set of API functions that could address specific notifications within the
2614  * array.  xTaskNotifyStateClear() is the original API function, and remains
2615  * backward compatible by always operating on the notification value at index 0
2616  * within the array. Calling xTaskNotifyStateClear() is equivalent to calling
2617  * xTaskNotifyStateClearIndexed() with the uxIndexToNotify parameter set to 0.
2618  *
2619  * @param xTask The handle of the RTOS task that will have a notification state
2620  * cleared.  Set xTask to NULL to clear a notification state in the calling
2621  * task.  To obtain a task's handle create the task using xTaskCreate() and
2622  * make use of the pxCreatedTask parameter, or create the task using
2623  * xTaskCreateStatic() and store the returned value, or use the task's name in
2624  * a call to xTaskGetHandle().
2625  *
2626  * @param uxIndexToClear The index within the target task's array of
2627  * notification values to act upon.  For example, setting uxIndexToClear to 1
2628  * will clear the state of the notification at index 1 within the array.
2629  * uxIndexToClear must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
2630  * ulTaskNotifyStateClear() does not have this parameter and always acts on the
2631  * notification at index 0.
2632  *
2633  * @return pdTRUE if the task's notification state was set to
2634  * eNotWaitingNotification, otherwise pdFALSE.
2635  *
2636  * \defgroup xTaskNotifyStateClearIndexed xTaskNotifyStateClearIndexed
2637  * \ingroup TaskNotifications
2638  */
2639 BaseType_t xTaskGenericNotifyStateClear( TaskHandle_t xTask,
2640                                          UBaseType_t uxIndexToClear ) PRIVILEGED_FUNCTION;
2641 #define xTaskNotifyStateClear( xTask ) \
2642     xTaskGenericNotifyStateClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ) )
2643 #define xTaskNotifyStateClearIndexed( xTask, uxIndexToClear ) \
2644     xTaskGenericNotifyStateClear( ( xTask ), ( uxIndexToClear ) )
2645
2646 /**
2647  * task. h
2648  * <pre>
2649  * uint32_t ulTaskNotifyValueClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear );
2650  *
2651  * uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear );
2652  * </pre>
2653  *
2654  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2655  *
2656  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2657  * functions to be available.
2658  *
2659  * Each task has a private array of "notification values" (or 'notifications'),
2660  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
2661  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2662  * array, and (for backward compatibility) defaults to 1 if left undefined.
2663  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2664  *
2665  * ulTaskNotifyValueClearIndexed() clears the bits specified by the
2666  * ulBitsToClear bit mask in the notification value at array index uxIndexToClear
2667  * of the task referenced by xTask.
2668  *
2669  * Backward compatibility information:
2670  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2671  * all task notification API functions operated on that value. Replacing the
2672  * single notification value with an array of notification values necessitated a
2673  * new set of API functions that could address specific notifications within the
2674  * array.  ulTaskNotifyValueClear() is the original API function, and remains
2675  * backward compatible by always operating on the notification value at index 0
2676  * within the array. Calling ulTaskNotifyValueClear() is equivalent to calling
2677  * ulTaskNotifyValueClearIndexed() with the uxIndexToClear parameter set to 0.
2678  *
2679  * @param xTask The handle of the RTOS task that will have bits in one of its
2680  * notification values cleared. Set xTask to NULL to clear bits in a
2681  * notification value of the calling task.  To obtain a task's handle create the
2682  * task using xTaskCreate() and make use of the pxCreatedTask parameter, or
2683  * create the task using xTaskCreateStatic() and store the returned value, or
2684  * use the task's name in a call to xTaskGetHandle().
2685  *
2686  * @param uxIndexToClear The index within the target task's array of
2687  * notification values in which to clear the bits.  uxIndexToClear
2688  * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
2689  * ulTaskNotifyValueClear() does not have this parameter and always clears bits
2690  * in the notification value at index 0.
2691  *
2692  * @param ulBitsToClear Bit mask of the bits to clear in the notification value of
2693  * xTask. Set a bit to 1 to clear the corresponding bits in the task's notification
2694  * value. Set ulBitsToClear to 0xffffffff (UINT_MAX on 32-bit architectures) to clear
2695  * the notification value to 0.  Set ulBitsToClear to 0 to query the task's
2696  * notification value without clearing any bits.
2697  *
2698  *
2699  * @return The value of the target task's notification value before the bits
2700  * specified by ulBitsToClear were cleared.
2701  * \defgroup ulTaskNotifyValueClear ulTaskNotifyValueClear
2702  * \ingroup TaskNotifications
2703  */
2704 uint32_t ulTaskGenericNotifyValueClear( TaskHandle_t xTask,
2705                                         UBaseType_t uxIndexToClear,
2706                                         uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
2707 #define ulTaskNotifyValueClear( xTask, ulBitsToClear ) \
2708     ulTaskGenericNotifyValueClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulBitsToClear ) )
2709 #define ulTaskNotifyValueClearIndexed( xTask, uxIndexToClear, ulBitsToClear ) \
2710     ulTaskGenericNotifyValueClear( ( xTask ), ( uxIndexToClear ), ( ulBitsToClear ) )
2711
2712 /**
2713  * task.h
2714  * <pre>
2715  * void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut );
2716  * </pre>
2717  *
2718  * Capture the current time for future use with xTaskCheckForTimeOut().
2719  *
2720  * @param pxTimeOut Pointer to a timeout object into which the current time
2721  * is to be captured.  The captured time includes the tick count and the number
2722  * of times the tick count has overflowed since the system first booted.
2723  * \defgroup vTaskSetTimeOutState vTaskSetTimeOutState
2724  * \ingroup TaskCtrl
2725  */
2726 void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
2727
2728 /**
2729  * task.h
2730  * <pre>
2731  * BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait );
2732  * </pre>
2733  *
2734  * Determines if pxTicksToWait ticks has passed since a time was captured
2735  * using a call to vTaskSetTimeOutState().  The captured time includes the tick
2736  * count and the number of times the tick count has overflowed.
2737  *
2738  * @param pxTimeOut The time status as captured previously using
2739  * vTaskSetTimeOutState. If the timeout has not yet occurred, it is updated
2740  * to reflect the current time status.
2741  * @param pxTicksToWait The number of ticks to check for timeout i.e. if
2742  * pxTicksToWait ticks have passed since pxTimeOut was last updated (either by
2743  * vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred.
2744  * If the timeout has not occurred, pxTicksToWait is updated to reflect the
2745  * number of remaining ticks.
2746  *
2747  * @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is
2748  * returned and pxTicksToWait is updated to reflect the number of remaining
2749  * ticks.
2750  *
2751  * @see https://www.FreeRTOS.org/xTaskCheckForTimeOut.html
2752  *
2753  * Example Usage:
2754  * <pre>
2755  *  // Driver library function used to receive uxWantedBytes from an Rx buffer
2756  *  // that is filled by a UART interrupt. If there are not enough bytes in the
2757  *  // Rx buffer then the task enters the Blocked state until it is notified that
2758  *  // more data has been placed into the buffer. If there is still not enough
2759  *  // data then the task re-enters the Blocked state, and xTaskCheckForTimeOut()
2760  *  // is used to re-calculate the Block time to ensure the total amount of time
2761  *  // spent in the Blocked state does not exceed MAX_TIME_TO_WAIT. This
2762  *  // continues until either the buffer contains at least uxWantedBytes bytes,
2763  *  // or the total amount of time spent in the Blocked state reaches
2764  *  // MAX_TIME_TO_WAIT â€“ at which point the task reads however many bytes are
2765  *  // available up to a maximum of uxWantedBytes.
2766  *
2767  *  size_t xUART_Receive( uint8_t *pucBuffer, size_t uxWantedBytes )
2768  *  {
2769  *  size_t uxReceived = 0;
2770  *  TickType_t xTicksToWait = MAX_TIME_TO_WAIT;
2771  *  TimeOut_t xTimeOut;
2772  *
2773  *      // Initialize xTimeOut.  This records the time at which this function
2774  *      // was entered.
2775  *      vTaskSetTimeOutState( &xTimeOut );
2776  *
2777  *      // Loop until the buffer contains the wanted number of bytes, or a
2778  *      // timeout occurs.
2779  *      while( UART_bytes_in_rx_buffer( pxUARTInstance ) < uxWantedBytes )
2780  *      {
2781  *          // The buffer didn't contain enough data so this task is going to
2782  *          // enter the Blocked state. Adjusting xTicksToWait to account for
2783  *          // any time that has been spent in the Blocked state within this
2784  *          // function so far to ensure the total amount of time spent in the
2785  *          // Blocked state does not exceed MAX_TIME_TO_WAIT.
2786  *          if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) != pdFALSE )
2787  *          {
2788  *              //Timed out before the wanted number of bytes were available,
2789  *              // exit the loop.
2790  *              break;
2791  *          }
2792  *
2793  *          // Wait for a maximum of xTicksToWait ticks to be notified that the
2794  *          // receive interrupt has placed more data into the buffer.
2795  *          ulTaskNotifyTake( pdTRUE, xTicksToWait );
2796  *      }
2797  *
2798  *      // Attempt to read uxWantedBytes from the receive buffer into pucBuffer.
2799  *      // The actual number of bytes read (which might be less than
2800  *      // uxWantedBytes) is returned.
2801  *      uxReceived = UART_read_from_receive_buffer( pxUARTInstance,
2802  *                                                  pucBuffer,
2803  *                                                  uxWantedBytes );
2804  *
2805  *      return uxReceived;
2806  *  }
2807  * </pre>
2808  * \defgroup xTaskCheckForTimeOut xTaskCheckForTimeOut
2809  * \ingroup TaskCtrl
2810  */
2811 BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut,
2812                                  TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;
2813
2814 /**
2815  * task.h
2816  * <pre>
2817  * BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp );
2818  * </pre>
2819  *
2820  * This function corrects the tick count value after the application code has held
2821  * interrupts disabled for an extended period resulting in tick interrupts having
2822  * been missed.
2823  *
2824  * This function is similar to vTaskStepTick(), however, unlike
2825  * vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a
2826  * time at which a task should be removed from the blocked state.  That means
2827  * tasks may have to be removed from the blocked state as the tick count is
2828  * moved.
2829  *
2830  * @param xTicksToCatchUp The number of tick interrupts that have been missed due to
2831  * interrupts being disabled.  Its value is not computed automatically, so must be
2832  * computed by the application writer.
2833  *
2834  * @return pdTRUE if moving the tick count forward resulted in a task leaving the
2835  * blocked state and a context switch being performed.  Otherwise pdFALSE.
2836  *
2837  * \defgroup xTaskCatchUpTicks xTaskCatchUpTicks
2838  * \ingroup TaskCtrl
2839  */
2840 BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION;
2841
2842
2843 /*-----------------------------------------------------------
2844 * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
2845 *----------------------------------------------------------*/
2846
2847 /*
2848  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS ONLY
2849  * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
2850  * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2851  *
2852  * Called from the real time kernel tick (either preemptive or cooperative),
2853  * this increments the tick count and checks if any tasks that are blocked
2854  * for a finite period required removing from a blocked list and placing on
2855  * a ready list.  If a non-zero value is returned then a context switch is
2856  * required because either:
2857  *   + A task was removed from a blocked list because its timeout had expired,
2858  *     or
2859  *   + Time slicing is in use and there is a task of equal priority to the
2860  *     currently running task.
2861  */
2862 BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;
2863
2864 /*
2865  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN
2866  * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2867  *
2868  * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
2869  *
2870  * Removes the calling task from the ready list and places it both
2871  * on the list of tasks waiting for a particular event, and the
2872  * list of delayed tasks.  The task will be removed from both lists
2873  * and replaced on the ready list should either the event occur (and
2874  * there be no higher priority tasks waiting on the same event) or
2875  * the delay period expires.
2876  *
2877  * The 'unordered' version replaces the event list item value with the
2878  * xItemValue value, and inserts the list item at the end of the list.
2879  *
2880  * The 'ordered' version uses the existing event list item value (which is the
2881  * owning task's priority) to insert the list item into the event list in task
2882  * priority order.
2883  *
2884  * @param pxEventList The list containing tasks that are blocked waiting
2885  * for the event to occur.
2886  *
2887  * @param xItemValue The item value to use for the event list item when the
2888  * event list is not ordered by task priority.
2889  *
2890  * @param xTicksToWait The maximum amount of time that the task should wait
2891  * for the event to occur.  This is specified in kernel ticks, the constant
2892  * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time
2893  * period.
2894  */
2895 void vTaskPlaceOnEventList( List_t * const pxEventList,
2896                             const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2897 void vTaskPlaceOnUnorderedEventList( List_t * pxEventList,
2898                                      const TickType_t xItemValue,
2899                                      const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2900
2901 /*
2902  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN
2903  * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2904  *
2905  * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
2906  *
2907  * This function performs nearly the same function as vTaskPlaceOnEventList().
2908  * The difference being that this function does not permit tasks to block
2909  * indefinitely, whereas vTaskPlaceOnEventList() does.
2910  *
2911  */
2912 void vTaskPlaceOnEventListRestricted( List_t * const pxEventList,
2913                                       TickType_t xTicksToWait,
2914                                       const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;
2915
2916 /*
2917  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN
2918  * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2919  *
2920  * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
2921  *
2922  * Removes a task from both the specified event list and the list of blocked
2923  * tasks, and places it on a ready queue.
2924  *
2925  * xTaskRemoveFromEventList()/vTaskRemoveFromUnorderedEventList() will be called
2926  * if either an event occurs to unblock a task, or the block timeout period
2927  * expires.
2928  *
2929  * xTaskRemoveFromEventList() is used when the event list is in task priority
2930  * order.  It removes the list item from the head of the event list as that will
2931  * have the highest priority owning task of all the tasks on the event list.
2932  * vTaskRemoveFromUnorderedEventList() is used when the event list is not
2933  * ordered and the event list items hold something other than the owning tasks
2934  * priority.  In this case the event list item value is updated to the value
2935  * passed in the xItemValue parameter.
2936  *
2937  * @return pdTRUE if the task being removed has a higher priority than the task
2938  * making the call, otherwise pdFALSE.
2939  */
2940 BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION;
2941 void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem,
2942                                         const TickType_t xItemValue ) PRIVILEGED_FUNCTION;
2943
2944 /*
2945  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS ONLY
2946  * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
2947  * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2948  *
2949  * Sets the pointer to the current TCB to the TCB of the highest priority task
2950  * that is ready to run.
2951  */
2952 portDONT_DISCARD void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;
2953
2954 /*
2955  * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE.  THEY ARE USED BY
2956  * THE EVENT BITS MODULE.
2957  */
2958 TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION;
2959
2960 /*
2961  * Return the handle of the calling task.
2962  */
2963 TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;
2964
2965 /*
2966  * Shortcut used by the queue implementation to prevent unnecessary call to
2967  * taskYIELD();
2968  */
2969 void vTaskMissedYield( void ) PRIVILEGED_FUNCTION;
2970
2971 /*
2972  * Returns the scheduler state as taskSCHEDULER_RUNNING,
2973  * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.
2974  */
2975 BaseType_t xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION;
2976
2977 /*
2978  * Raises the priority of the mutex holder to that of the calling task should
2979  * the mutex holder have a priority less than the calling task.
2980  */
2981 BaseType_t xTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
2982
2983 /*
2984  * Set the priority of a task back to its proper priority in the case that it
2985  * inherited a higher priority while it was holding a semaphore.
2986  */
2987 BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
2988
2989 /*
2990  * If a higher priority task attempting to obtain a mutex caused a lower
2991  * priority task to inherit the higher priority task's priority - but the higher
2992  * priority task then timed out without obtaining the mutex, then the lower
2993  * priority task will disinherit the priority again - but only down as far as
2994  * the highest priority task that is still waiting for the mutex (if there were
2995  * more than one task waiting for the mutex).
2996  */
2997 void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder,
2998                                           UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION;
2999
3000 /*
3001  * Get the uxTCBNumber assigned to the task referenced by the xTask parameter.
3002  */
3003 UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
3004
3005 /*
3006  * Set the uxTaskNumber of the task referenced by the xTask parameter to
3007  * uxHandle.
3008  */
3009 void vTaskSetTaskNumber( TaskHandle_t xTask,
3010                          const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION;
3011
3012 /*
3013  * Only available when configUSE_TICKLESS_IDLE is set to 1.
3014  * If tickless mode is being used, or a low power mode is implemented, then
3015  * the tick interrupt will not execute during idle periods.  When this is the
3016  * case, the tick count value maintained by the scheduler needs to be kept up
3017  * to date with the actual execution time by being skipped forward by a time
3018  * equal to the idle period.
3019  */
3020 void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION;
3021
3022 /*
3023  * Only available when configUSE_TICKLESS_IDLE is set to 1.
3024  * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port
3025  * specific sleep function to determine if it is ok to proceed with the sleep,
3026  * and if it is ok to proceed, if it is ok to sleep indefinitely.
3027  *
3028  * This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only
3029  * called with the scheduler suspended, not from within a critical section.  It
3030  * is therefore possible for an interrupt to request a context switch between
3031  * portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being
3032  * entered.  eTaskConfirmSleepModeStatus() should be called from a short
3033  * critical section between the timer being stopped and the sleep mode being
3034  * entered to ensure it is ok to proceed into the sleep mode.
3035  */
3036 eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;
3037
3038 /*
3039  * For internal use only.  Increment the mutex held count when a mutex is
3040  * taken and return the handle of the task that has taken the mutex.
3041  */
3042 TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;
3043
3044 /*
3045  * For internal use only.  Same as vTaskSetTimeOutState(), but without a critical
3046  * section.
3047  */
3048 void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
3049
3050
3051 /* *INDENT-OFF* */
3052 #ifdef __cplusplus
3053     }
3054 #endif
3055 /* *INDENT-ON* */
3056 #endif /* INC_TASK_H */