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