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