2 * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * SPDX-License-Identifier: MIT
7 * Permission is hereby granted, free of charge, to any person obtaining a copy of
8 * this software and associated documentation files (the "Software"), to deal in
9 * the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11 * the Software, and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 * https://www.FreeRTOS.org
25 * https://github.com/FreeRTOS
33 #ifndef INC_FREERTOS_H
34 #error "include FreeRTOS.h must appear in source files before include task.h"
45 /*-----------------------------------------------------------
46 * MACROS AND DEFINITIONS
47 *----------------------------------------------------------*/
50 * If tskKERNEL_VERSION_NUMBER ends with + it represents the version in development
51 * after the numbered release.
53 * The tskKERNEL_VERSION_MAJOR, tskKERNEL_VERSION_MINOR, tskKERNEL_VERSION_BUILD
54 * values will reflect the last released version number.
56 #define tskKERNEL_VERSION_NUMBER "V10.4.4+"
57 #define tskKERNEL_VERSION_MAJOR 10
58 #define tskKERNEL_VERSION_MINOR 4
59 #define tskKERNEL_VERSION_BUILD 4
61 /* MPU region parameters passed in ulParameters
62 * of MemoryRegion_t struct. */
63 #define tskMPU_REGION_READ_ONLY ( 1UL << 0UL )
64 #define tskMPU_REGION_READ_WRITE ( 1UL << 1UL )
65 #define tskMPU_REGION_EXECUTE_NEVER ( 1UL << 2UL )
66 #define tskMPU_REGION_NORMAL_MEMORY ( 1UL << 3UL )
67 #define tskMPU_REGION_DEVICE_MEMORY ( 1UL << 4UL )
69 /* MPU region permissions stored in MPU settings to
70 * authorize access requests. */
71 #define tskMPU_READ_PERMISSION ( 1UL << 0UL )
72 #define tskMPU_WRITE_PERMISSION ( 1UL << 1UL )
74 /* The direct to task notification feature used to have only a single notification
75 * per task. Now there is an array of notifications per task that is dimensioned by
76 * configTASK_NOTIFICATION_ARRAY_ENTRIES. For backward compatibility, any use of the
77 * original direct to task notification defaults to using the first index in the
79 #define tskDEFAULT_INDEX_TO_NOTIFY ( 0 )
84 * Type by which tasks are referenced. For example, a call to xTaskCreate
85 * returns (via a pointer parameter) an TaskHandle_t variable that can then
86 * be used as a parameter to vTaskDelete to delete the task.
88 * \defgroup TaskHandle_t TaskHandle_t
91 struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */
92 typedef struct tskTaskControlBlock * TaskHandle_t;
93 typedef const struct tskTaskControlBlock * ConstTaskHandle_t;
96 * Defines the prototype to which the application task hook function must
99 typedef BaseType_t (* TaskHookFunction_t)( void * );
101 /* Task states returned by eTaskGetState. */
104 eRunning = 0, /* A task is querying the state of itself, so must be running. */
105 eReady, /* The task being queried is in a ready or pending ready list. */
106 eBlocked, /* The task being queried is in the Blocked state. */
107 eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */
108 eDeleted, /* The task being queried has been deleted, but its TCB has not yet been freed. */
109 eInvalid /* Used as an 'invalid state' value. */
112 /* Actions that can be performed when vTaskNotify() is called. */
115 eNoAction = 0, /* Notify the task without updating its notify value. */
116 eSetBits, /* Set bits in the task's notification value. */
117 eIncrement, /* Increment the task's notification value. */
118 eSetValueWithOverwrite, /* Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */
119 eSetValueWithoutOverwrite /* Set the task's notification value if the previous value has been read by the task. */
123 * Used internally only.
125 typedef struct xTIME_OUT
127 BaseType_t xOverflowCount;
128 TickType_t xTimeOnEntering;
132 * Defines the memory ranges allocated to the task when an MPU is used.
134 typedef struct xMEMORY_REGION
136 void * pvBaseAddress;
137 uint32_t ulLengthInBytes;
138 uint32_t ulParameters;
142 * Parameters required to create an MPU protected task.
144 typedef struct xTASK_PARAMETERS
146 TaskFunction_t pvTaskCode;
147 const char * pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
148 configSTACK_DEPTH_TYPE usStackDepth;
150 UBaseType_t uxPriority;
151 StackType_t * puxStackBuffer;
152 MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ];
153 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
154 StaticTask_t * const pxTaskBuffer;
158 /* Used with the uxTaskGetSystemState() function to return the state of each task
160 typedef struct xTASK_STATUS
162 TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */
163 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. */
164 UBaseType_t xTaskNumber; /* A number unique to the task. */
165 eTaskState eCurrentState; /* The state in which the task existed when the structure was populated. */
166 UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */
167 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. */
168 configRUN_TIME_COUNTER_TYPE 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. */
169 StackType_t * pxStackBase; /* Points to the lowest address of the task's stack area. */
170 #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )
171 StackType_t * pxTopOfStack; /* Points to the top address of the task's stack area. */
172 StackType_t * pxEndOfStack; /* Points to the end address of the task's stack area. */
174 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. */
175 #if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
176 UBaseType_t uxCoreAffinityMask; /* The core affinity mask for the task */
180 /* Possible return values for eTaskConfirmSleepModeStatus(). */
183 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. */
184 eStandardSleep, /* Enter a sleep mode that will not last any longer than the expected idle time. */
185 #if ( INCLUDE_vTaskSuspend == 1 )
186 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. */
187 #endif /* INCLUDE_vTaskSuspend */
191 * Defines the priority used by the idle task. This must not be modified.
195 #define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U )
198 * Defines affinity to all available cores.
202 #define tskNO_AFFINITY ( ( UBaseType_t ) -1 )
207 * Macro for forcing a context switch.
209 * \defgroup taskYIELD taskYIELD
210 * \ingroup SchedulerControl
212 #define taskYIELD() portYIELD()
217 * Macro to mark the start of a critical code region. Preemptive context
218 * switches cannot occur when in a critical region.
220 * NOTE: This may alter the stack (depending on the portable implementation)
221 * so must be used with care!
223 * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL
224 * \ingroup SchedulerControl
226 #define taskENTER_CRITICAL() portENTER_CRITICAL()
227 #if ( configNUMBER_OF_CORES == 1 )
228 #define taskENTER_CRITICAL_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()
230 #define taskENTER_CRITICAL_FROM_ISR() portENTER_CRITICAL_FROM_ISR()
236 * Macro to mark the end of a critical code region. Preemptive context
237 * switches cannot occur when in a critical region.
239 * NOTE: This may alter the stack (depending on the portable implementation)
240 * so must be used with care!
242 * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL
243 * \ingroup SchedulerControl
245 #define taskEXIT_CRITICAL() portEXIT_CRITICAL()
246 #if ( configNUMBER_OF_CORES == 1 )
247 #define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x )
249 #define taskEXIT_CRITICAL_FROM_ISR( x ) portEXIT_CRITICAL_FROM_ISR( x )
255 * Macro to disable all maskable interrupts.
257 * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS
258 * \ingroup SchedulerControl
260 #define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS()
265 * Macro to enable microcontroller interrupts.
267 * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS
268 * \ingroup SchedulerControl
270 #define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS()
272 /* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is
273 * 0 to generate more optimal code when configASSERT() is defined as the constant
274 * is used in assert() statements. */
275 #define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 )
276 #define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 )
277 #define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 )
279 /* Checks if core ID is valid. */
280 #define taskVALID_CORE_ID( xCoreID ) ( ( ( ( ( BaseType_t ) 0 <= ( xCoreID ) ) && ( ( xCoreID ) < ( BaseType_t ) configNUMBER_OF_CORES ) ) ) ? ( pdTRUE ) : ( pdFALSE ) )
282 /*-----------------------------------------------------------
284 *----------------------------------------------------------*/
289 * BaseType_t xTaskCreate(
290 * TaskFunction_t pxTaskCode,
291 * const char *pcName,
292 * configSTACK_DEPTH_TYPE usStackDepth,
293 * void *pvParameters,
294 * UBaseType_t uxPriority,
295 * TaskHandle_t *pxCreatedTask
299 * Create a new task and add it to the list of tasks that are ready to run.
301 * Internally, within the FreeRTOS implementation, tasks use two blocks of
302 * memory. The first block is used to hold the task's data structures. The
303 * second block is used by the task as its stack. If a task is created using
304 * xTaskCreate() then both blocks of memory are automatically dynamically
305 * allocated inside the xTaskCreate() function. (see
306 * https://www.FreeRTOS.org/a00111.html). If a task is created using
307 * xTaskCreateStatic() then the application writer must provide the required
308 * memory. xTaskCreateStatic() therefore allows a task to be created without
309 * using any dynamic memory allocation.
311 * See xTaskCreateStatic() for a version that does not use any dynamic memory
314 * xTaskCreate() can only be used to create a task that has unrestricted
315 * access to the entire microcontroller memory map. Systems that include MPU
316 * support can alternatively create an MPU constrained task using
317 * xTaskCreateRestricted().
319 * @param pxTaskCode Pointer to the task entry function. Tasks
320 * must be implemented to never return (i.e. continuous loop).
322 * @param pcName A descriptive name for the task. This is mainly used to
323 * facilitate debugging. Max length defined by configMAX_TASK_NAME_LEN - default
326 * @param usStackDepth The size of the task stack specified as the number of
327 * variables the stack can hold - not the number of bytes. For example, if
328 * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes
329 * will be allocated for stack storage.
331 * @param pvParameters Pointer that will be used as the parameter for the task
334 * @param uxPriority The priority at which the task should run. Systems that
335 * include MPU support can optionally create tasks in a privileged (system)
336 * mode by setting bit portPRIVILEGE_BIT of the priority parameter. For
337 * example, to create a privileged task at priority 2 the uxPriority parameter
338 * should be set to ( 2 | portPRIVILEGE_BIT ).
340 * @param pxCreatedTask Used to pass back a handle by which the created task
343 * @return pdPASS if the task was successfully created and added to a ready
344 * list, otherwise an error code defined in the file projdefs.h
348 * // Task to be created.
349 * void vTaskCode( void * pvParameters )
353 * // Task code goes here.
357 * // Function that creates a task.
358 * void vOtherFunction( void )
360 * static uint8_t ucParameterToPass;
361 * TaskHandle_t xHandle = NULL;
363 * // Create the task, storing the handle. Note that the passed parameter ucParameterToPass
364 * // must exist for the lifetime of the task, so in this case is declared static. If it was just an
365 * // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time
366 * // the new task attempts to access it.
367 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
368 * configASSERT( xHandle );
370 * // Use the handle to delete the task.
371 * if( xHandle != NULL )
373 * vTaskDelete( xHandle );
377 * \defgroup xTaskCreate xTaskCreate
380 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
381 BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
382 const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
383 const configSTACK_DEPTH_TYPE usStackDepth,
384 void * const pvParameters,
385 UBaseType_t uxPriority,
386 TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
389 #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
390 BaseType_t xTaskCreateAffinitySet( TaskFunction_t pxTaskCode,
391 const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
392 const configSTACK_DEPTH_TYPE usStackDepth,
393 void * const pvParameters,
394 UBaseType_t uxPriority,
395 UBaseType_t uxCoreAffinityMask,
396 TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
402 * TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
403 * const char *pcName,
404 * uint32_t ulStackDepth,
405 * void *pvParameters,
406 * UBaseType_t uxPriority,
407 * StackType_t *puxStackBuffer,
408 * StaticTask_t *pxTaskBuffer );
411 * Create a new task and add it to the list of tasks that are ready to run.
413 * Internally, within the FreeRTOS implementation, tasks use two blocks of
414 * memory. The first block is used to hold the task's data structures. The
415 * second block is used by the task as its stack. If a task is created using
416 * xTaskCreate() then both blocks of memory are automatically dynamically
417 * allocated inside the xTaskCreate() function. (see
418 * https://www.FreeRTOS.org/a00111.html). If a task is created using
419 * xTaskCreateStatic() then the application writer must provide the required
420 * memory. xTaskCreateStatic() therefore allows a task to be created without
421 * using any dynamic memory allocation.
423 * @param pxTaskCode Pointer to the task entry function. Tasks
424 * must be implemented to never return (i.e. continuous loop).
426 * @param pcName A descriptive name for the task. This is mainly used to
427 * facilitate debugging. The maximum length of the string is defined by
428 * configMAX_TASK_NAME_LEN in FreeRTOSConfig.h.
430 * @param ulStackDepth The size of the task stack specified as the number of
431 * variables the stack can hold - not the number of bytes. For example, if
432 * the stack is 32-bits wide and ulStackDepth is defined as 100 then 400 bytes
433 * will be allocated for stack storage.
435 * @param pvParameters Pointer that will be used as the parameter for the task
438 * @param uxPriority The priority at which the task will run.
440 * @param puxStackBuffer Must point to a StackType_t array that has at least
441 * ulStackDepth indexes - the array will then be used as the task's stack,
442 * removing the need for the stack to be allocated dynamically.
444 * @param pxTaskBuffer Must point to a variable of type StaticTask_t, which will
445 * then be used to hold the task's data structures, removing the need for the
446 * memory to be allocated dynamically.
448 * @return If neither puxStackBuffer nor pxTaskBuffer are NULL, then the task
449 * will be created and a handle to the created task is returned. If either
450 * puxStackBuffer or pxTaskBuffer are NULL then the task will not be created and
456 * // Dimensions of the buffer that the task being created will use as its stack.
457 * // NOTE: This is the number of words the stack will hold, not the number of
458 * // bytes. For example, if each stack item is 32-bits, and this is set to 100,
459 * // then 400 bytes (100 * 32-bits) will be allocated.
460 #define STACK_SIZE 200
462 * // Structure that will hold the TCB of the task being created.
463 * StaticTask_t xTaskBuffer;
465 * // Buffer that the task being created will use as its stack. Note this is
466 * // an array of StackType_t variables. The size of StackType_t is dependent on
468 * StackType_t xStack[ STACK_SIZE ];
470 * // Function that implements the task being created.
471 * void vTaskCode( void * pvParameters )
473 * // The parameter value is expected to be 1 as 1 is passed in the
474 * // pvParameters value in the call to xTaskCreateStatic().
475 * configASSERT( ( uint32_t ) pvParameters == 1UL );
479 * // Task code goes here.
483 * // Function that creates a task.
484 * void vOtherFunction( void )
486 * TaskHandle_t xHandle = NULL;
488 * // Create the task without using any dynamic memory allocation.
489 * xHandle = xTaskCreateStatic(
490 * vTaskCode, // Function that implements the task.
491 * "NAME", // Text name for the task.
492 * STACK_SIZE, // Stack size in words, not bytes.
493 * ( void * ) 1, // Parameter passed into the task.
494 * tskIDLE_PRIORITY,// Priority at which the task is created.
495 * xStack, // Array to use as the task's stack.
496 * &xTaskBuffer ); // Variable to hold the task's data structure.
498 * // puxStackBuffer and pxTaskBuffer were not NULL, so the task will have
499 * // been created, and xHandle will be the task's handle. Use the handle
500 * // to suspend the task.
501 * vTaskSuspend( xHandle );
504 * \defgroup xTaskCreateStatic xTaskCreateStatic
507 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
508 TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
509 const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
510 const uint32_t ulStackDepth,
511 void * const pvParameters,
512 UBaseType_t uxPriority,
513 StackType_t * const puxStackBuffer,
514 StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION;
515 #endif /* configSUPPORT_STATIC_ALLOCATION */
517 #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
518 TaskHandle_t xTaskCreateStaticAffinitySet( TaskFunction_t pxTaskCode,
519 const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
520 const uint32_t ulStackDepth,
521 void * const pvParameters,
522 UBaseType_t uxPriority,
523 StackType_t * const puxStackBuffer,
524 StaticTask_t * const pxTaskBuffer,
525 UBaseType_t uxCoreAffinityMask ) PRIVILEGED_FUNCTION;
531 * BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
534 * Only available when configSUPPORT_DYNAMIC_ALLOCATION is set to 1.
536 * xTaskCreateRestricted() should only be used in systems that include an MPU
539 * Create a new task and add it to the list of tasks that are ready to run.
540 * The function parameters define the memory regions and associated access
541 * permissions allocated to the task.
543 * See xTaskCreateRestrictedStatic() for a version that does not use any
544 * dynamic memory allocation.
546 * @param pxTaskDefinition Pointer to a structure that contains a member
547 * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
548 * documentation) plus an optional stack buffer and the memory region
551 * @param pxCreatedTask Used to pass back a handle by which the created task
554 * @return pdPASS if the task was successfully created and added to a ready
555 * list, otherwise an error code defined in the file projdefs.h
559 * // Create an TaskParameters_t structure that defines the task to be created.
560 * static const TaskParameters_t xCheckTaskParameters =
562 * vATask, // pvTaskCode - the function that implements the task.
563 * "ATask", // pcName - just a text name for the task to assist debugging.
564 * 100, // usStackDepth - the stack size DEFINED IN WORDS.
565 * NULL, // pvParameters - passed into the task function as the function parameters.
566 * ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
567 * cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
569 * // xRegions - Allocate up to three separate memory regions for access by
570 * // the task, with appropriate access permissions. Different processors have
571 * // different memory alignment requirements - refer to the FreeRTOS documentation
572 * // for full information.
574 * // Base address Length Parameters
575 * { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },
576 * { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },
577 * { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }
583 * TaskHandle_t xHandle;
585 * // Create a task from the const structure defined above. The task handle
586 * // is requested (the second parameter is not NULL) but in this case just for
587 * // demonstration purposes as its not actually used.
588 * xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
590 * // Start the scheduler.
591 * vTaskStartScheduler();
593 * // Will only get here if there was insufficient memory to create the idle
594 * // and/or timer task.
598 * \defgroup xTaskCreateRestricted xTaskCreateRestricted
601 #if ( portUSING_MPU_WRAPPERS == 1 )
602 BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition,
603 TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
606 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
607 BaseType_t xTaskCreateRestrictedAffinitySet( const TaskParameters_t * const pxTaskDefinition,
608 UBaseType_t uxCoreAffinityMask,
609 TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
615 * BaseType_t xTaskCreateRestrictedStatic( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
618 * Only available when configSUPPORT_STATIC_ALLOCATION is set to 1.
620 * xTaskCreateRestrictedStatic() should only be used in systems that include an
621 * MPU implementation.
623 * Internally, within the FreeRTOS implementation, tasks use two blocks of
624 * memory. The first block is used to hold the task's data structures. The
625 * second block is used by the task as its stack. If a task is created using
626 * xTaskCreateRestricted() then the stack is provided by the application writer,
627 * and the memory used to hold the task's data structure is automatically
628 * dynamically allocated inside the xTaskCreateRestricted() function. If a task
629 * is created using xTaskCreateRestrictedStatic() then the application writer
630 * must provide the memory used to hold the task's data structures too.
631 * xTaskCreateRestrictedStatic() therefore allows a memory protected task to be
632 * created without using any dynamic memory allocation.
634 * @param pxTaskDefinition Pointer to a structure that contains a member
635 * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
636 * documentation) plus an optional stack buffer and the memory region
637 * definitions. If configSUPPORT_STATIC_ALLOCATION is set to 1 the structure
638 * contains an additional member, which is used to point to a variable of type
639 * StaticTask_t - which is then used to hold the task's data structure.
641 * @param pxCreatedTask Used to pass back a handle by which the created task
644 * @return pdPASS if the task was successfully created and added to a ready
645 * list, otherwise an error code defined in the file projdefs.h
649 * // Create an TaskParameters_t structure that defines the task to be created.
650 * // The StaticTask_t variable is only included in the structure when
651 * // configSUPPORT_STATIC_ALLOCATION is set to 1. The PRIVILEGED_DATA macro can
652 * // be used to force the variable into the RTOS kernel's privileged data area.
653 * static PRIVILEGED_DATA StaticTask_t xTaskBuffer;
654 * static const TaskParameters_t xCheckTaskParameters =
656 * vATask, // pvTaskCode - the function that implements the task.
657 * "ATask", // pcName - just a text name for the task to assist debugging.
658 * 100, // usStackDepth - the stack size DEFINED IN WORDS.
659 * NULL, // pvParameters - passed into the task function as the function parameters.
660 * ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
661 * cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
663 * // xRegions - Allocate up to three separate memory regions for access by
664 * // the task, with appropriate access permissions. Different processors have
665 * // different memory alignment requirements - refer to the FreeRTOS documentation
666 * // for full information.
668 * // Base address Length Parameters
669 * { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },
670 * { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },
671 * { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }
674 * &xTaskBuffer; // Holds the task's data structure.
679 * TaskHandle_t xHandle;
681 * // Create a task from the const structure defined above. The task handle
682 * // is requested (the second parameter is not NULL) but in this case just for
683 * // demonstration purposes as its not actually used.
684 * xTaskCreateRestrictedStatic( &xRegTest1Parameters, &xHandle );
686 * // Start the scheduler.
687 * vTaskStartScheduler();
689 * // Will only get here if there was insufficient memory to create the idle
690 * // and/or timer task.
694 * \defgroup xTaskCreateRestrictedStatic xTaskCreateRestrictedStatic
697 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
698 BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition,
699 TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
702 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
703 BaseType_t xTaskCreateRestrictedStaticAffinitySet( const TaskParameters_t * const pxTaskDefinition,
704 UBaseType_t uxCoreAffinityMask,
705 TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
711 * void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions );
714 * Memory regions are assigned to a restricted task when the task is created by
715 * a call to xTaskCreateRestricted(). These regions can be redefined using
716 * vTaskAllocateMPURegions().
718 * @param xTaskToModify The handle of the task being updated.
720 * @param[in] pxRegions A pointer to a MemoryRegion_t structure that contains the
721 * new memory region definitions.
725 * // Define an array of MemoryRegion_t structures that configures an MPU region
726 * // allowing read/write access for 1024 bytes starting at the beginning of the
727 * // ucOneKByte array. The other two of the maximum 3 definable regions are
728 * // unused so set to zero.
729 * static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =
731 * // Base address Length Parameters
732 * { ucOneKByte, 1024, portMPU_REGION_READ_WRITE },
737 * void vATask( void *pvParameters )
739 * // This task was created such that it has access to certain regions of
740 * // memory as defined by the MPU configuration. At some point it is
741 * // desired that these MPU regions are replaced with that defined in the
742 * // xAltRegions const struct above. Use a call to vTaskAllocateMPURegions()
743 * // for this purpose. NULL is used as the task handle to indicate that this
744 * // function should modify the MPU regions of the calling task.
745 * vTaskAllocateMPURegions( NULL, xAltRegions );
747 * // Now the task can continue its function, but from this point on can only
748 * // access its stack and the ucOneKByte array (unless any other statically
749 * // defined or shared regions have been declared elsewhere).
752 * \defgroup vTaskAllocateMPURegions vTaskAllocateMPURegions
755 void vTaskAllocateMPURegions( TaskHandle_t xTaskToModify,
756 const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION;
761 * void vTaskDelete( TaskHandle_t xTaskToDelete );
764 * INCLUDE_vTaskDelete must be defined as 1 for this function to be available.
765 * See the configuration section for more information.
767 * Remove a task from the RTOS real time kernel's management. The task being
768 * deleted will be removed from all ready, blocked, suspended and event lists.
770 * NOTE: The idle task is responsible for freeing the kernel allocated
771 * memory from tasks that have been deleted. It is therefore important that
772 * the idle task is not starved of microcontroller processing time if your
773 * application makes any calls to vTaskDelete (). Memory allocated by the
774 * task code is not automatically freed, and should be freed before the task
777 * See the demo application file death.c for sample code that utilises
780 * @param xTaskToDelete The handle of the task to be deleted. Passing NULL will
781 * cause the calling task to be deleted.
785 * void vOtherFunction( void )
787 * TaskHandle_t xHandle;
789 * // Create the task, storing the handle.
790 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
792 * // Use the handle to delete the task.
793 * vTaskDelete( xHandle );
796 * \defgroup vTaskDelete vTaskDelete
799 void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
801 /*-----------------------------------------------------------
803 *----------------------------------------------------------*/
808 * void vTaskDelay( const TickType_t xTicksToDelay );
811 * Delay a task for a given number of ticks. The actual time that the
812 * task remains blocked depends on the tick rate. The constant
813 * portTICK_PERIOD_MS can be used to calculate real time from the tick
814 * rate - with the resolution of one tick period.
816 * INCLUDE_vTaskDelay must be defined as 1 for this function to be available.
817 * See the configuration section for more information.
820 * vTaskDelay() specifies a time at which the task wishes to unblock relative to
821 * the time at which vTaskDelay() is called. For example, specifying a block
822 * period of 100 ticks will cause the task to unblock 100 ticks after
823 * vTaskDelay() is called. vTaskDelay() does not therefore provide a good method
824 * of controlling the frequency of a periodic task as the path taken through the
825 * code, as well as other task and interrupt activity, will affect the frequency
826 * at which vTaskDelay() gets called and therefore the time at which the task
827 * next executes. See xTaskDelayUntil() for an alternative API function designed
828 * to facilitate fixed frequency execution. It does this by specifying an
829 * absolute time (rather than a relative time) at which the calling task should
832 * @param xTicksToDelay The amount of time, in tick periods, that
833 * the calling task should block.
837 * void vTaskFunction( void * pvParameters )
839 * // Block for 500ms.
840 * const TickType_t xDelay = 500 / portTICK_PERIOD_MS;
844 * // Simply toggle the LED every 500ms, blocking between each toggle.
846 * vTaskDelay( xDelay );
850 * \defgroup vTaskDelay vTaskDelay
853 void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
858 * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
861 * INCLUDE_xTaskDelayUntil must be defined as 1 for this function to be available.
862 * See the configuration section for more information.
864 * Delay a task until a specified time. This function can be used by periodic
865 * tasks to ensure a constant execution frequency.
867 * This function differs from vTaskDelay () in one important aspect: vTaskDelay () will
868 * cause a task to block for the specified number of ticks from the time vTaskDelay () is
869 * called. It is therefore difficult to use vTaskDelay () by itself to generate a fixed
870 * execution frequency as the time between a task starting to execute and that task
871 * calling vTaskDelay () may not be fixed [the task may take a different path though the
872 * code between calls, or may get interrupted or preempted a different number of times
873 * each time it executes].
875 * Whereas vTaskDelay () specifies a wake time relative to the time at which the function
876 * is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to
879 * The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a
880 * time specified in milliseconds with a resolution of one tick period.
882 * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the
883 * task was last unblocked. The variable must be initialised with the current time
884 * prior to its first use (see the example below). Following this the variable is
885 * automatically updated within xTaskDelayUntil ().
887 * @param xTimeIncrement The cycle time period. The task will be unblocked at
888 * time *pxPreviousWakeTime + xTimeIncrement. Calling xTaskDelayUntil with the
889 * same xTimeIncrement parameter value will cause the task to execute with
890 * a fixed interface period.
892 * @return Value which can be used to check whether the task was actually delayed.
893 * Will be pdTRUE if the task way delayed and pdFALSE otherwise. A task will not
894 * be delayed if the next expected wake time is in the past.
898 * // Perform an action every 10 ticks.
899 * void vTaskFunction( void * pvParameters )
901 * TickType_t xLastWakeTime;
902 * const TickType_t xFrequency = 10;
903 * BaseType_t xWasDelayed;
905 * // Initialise the xLastWakeTime variable with the current time.
906 * xLastWakeTime = xTaskGetTickCount ();
909 * // Wait for the next cycle.
910 * xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency );
912 * // Perform action here. xWasDelayed value can be used to determine
913 * // whether a deadline was missed if the code here took too long.
917 * \defgroup xTaskDelayUntil xTaskDelayUntil
920 BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
921 const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
924 * vTaskDelayUntil() is the older version of xTaskDelayUntil() and does not
927 #define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ) \
929 ( void ) xTaskDelayUntil( ( pxPreviousWakeTime ), ( xTimeIncrement ) ); \
936 * BaseType_t xTaskAbortDelay( TaskHandle_t xTask );
939 * INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this
940 * function to be available.
942 * A task will enter the Blocked state when it is waiting for an event. The
943 * event it is waiting for can be a temporal event (waiting for a time), such
944 * as when vTaskDelay() is called, or an event on an object, such as when
945 * xQueueReceive() or ulTaskNotifyTake() is called. If the handle of a task
946 * that is in the Blocked state is used in a call to xTaskAbortDelay() then the
947 * task will leave the Blocked state, and return from whichever function call
948 * placed the task into the Blocked state.
950 * There is no 'FromISR' version of this function as an interrupt would need to
951 * know which object a task was blocked on in order to know which actions to
952 * take. For example, if the task was blocked on a queue the interrupt handler
953 * would then need to know if the queue was locked.
955 * @param xTask The handle of the task to remove from the Blocked state.
957 * @return If the task referenced by xTask was not in the Blocked state then
958 * pdFAIL is returned. Otherwise pdPASS is returned.
960 * \defgroup xTaskAbortDelay xTaskAbortDelay
963 BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
968 * UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask );
971 * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available.
972 * See the configuration section for more information.
974 * Obtain the priority of any task.
976 * @param xTask Handle of the task to be queried. Passing a NULL
977 * handle results in the priority of the calling task being returned.
979 * @return The priority of xTask.
983 * void vAFunction( void )
985 * TaskHandle_t xHandle;
987 * // Create a task, storing the handle.
988 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
992 * // Use the handle to obtain the priority of the created task.
993 * // It was created with tskIDLE_PRIORITY, but may have changed
995 * if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
997 * // The task has changed it's priority.
1002 * // Is our priority higher than the created task?
1003 * if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
1005 * // Our priority (obtained using NULL handle) is higher.
1009 * \defgroup uxTaskPriorityGet uxTaskPriorityGet
1012 UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1017 * UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask );
1020 * A version of uxTaskPriorityGet() that can be used from an ISR.
1022 UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1027 * eTaskState eTaskGetState( TaskHandle_t xTask );
1030 * INCLUDE_eTaskGetState must be defined as 1 for this function to be available.
1031 * See the configuration section for more information.
1033 * Obtain the state of any task. States are encoded by the eTaskState
1036 * @param xTask Handle of the task to be queried.
1038 * @return The state of xTask at the time the function was called. Note the
1039 * state of the task might change between the function being called, and the
1040 * functions return value being tested by the calling task.
1042 eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1047 * void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState );
1050 * configUSE_TRACE_FACILITY must be defined as 1 for this function to be
1051 * available. See the configuration section for more information.
1053 * Populates a TaskStatus_t structure with information about a task.
1055 * @param xTask Handle of the task being queried. If xTask is NULL then
1056 * information will be returned about the calling task.
1058 * @param pxTaskStatus A pointer to the TaskStatus_t structure that will be
1059 * filled with information about the task referenced by the handle passed using
1060 * the xTask parameter.
1062 * @param xGetFreeStackSpace The TaskStatus_t structure contains a member to report
1063 * the stack high water mark of the task being queried. Calculating the stack
1064 * high water mark takes a relatively long time, and can make the system
1065 * temporarily unresponsive - so the xGetFreeStackSpace parameter is provided to
1066 * allow the high water mark checking to be skipped. The high watermark value
1067 * will only be written to the TaskStatus_t structure if xGetFreeStackSpace is
1068 * not set to pdFALSE;
1070 * @param eState The TaskStatus_t structure contains a member to report the
1071 * state of the task being queried. Obtaining the task state is not as fast as
1072 * a simple assignment - so the eState parameter is provided to allow the state
1073 * information to be omitted from the TaskStatus_t structure. To obtain state
1074 * information then set eState to eInvalid - otherwise the value passed in
1075 * eState will be reported as the task state in the TaskStatus_t structure.
1079 * void vAFunction( void )
1081 * TaskHandle_t xHandle;
1082 * TaskStatus_t xTaskDetails;
1084 * // Obtain the handle of a task from its name.
1085 * xHandle = xTaskGetHandle( "Task_Name" );
1087 * // Check the handle is not NULL.
1088 * configASSERT( xHandle );
1090 * // Use the handle to obtain further information about the task.
1091 * vTaskGetInfo( xHandle,
1093 * pdTRUE, // Include the high water mark in xTaskDetails.
1094 * eInvalid ); // Include the task state in xTaskDetails.
1097 * \defgroup vTaskGetInfo vTaskGetInfo
1100 void vTaskGetInfo( TaskHandle_t xTask,
1101 TaskStatus_t * pxTaskStatus,
1102 BaseType_t xGetFreeStackSpace,
1103 eTaskState eState ) PRIVILEGED_FUNCTION;
1108 * void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );
1111 * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.
1112 * See the configuration section for more information.
1114 * Set the priority of any task.
1116 * A context switch will occur before the function returns if the priority
1117 * being set is higher than the currently executing task.
1119 * @param xTask Handle to the task for which the priority is being set.
1120 * Passing a NULL handle results in the priority of the calling task being set.
1122 * @param uxNewPriority The priority to which the task will be set.
1126 * void vAFunction( void )
1128 * TaskHandle_t xHandle;
1130 * // Create a task, storing the handle.
1131 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1135 * // Use the handle to raise the priority of the created task.
1136 * vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
1140 * // Use a NULL handle to raise our priority to the same value.
1141 * vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
1144 * \defgroup vTaskPrioritySet vTaskPrioritySet
1147 void vTaskPrioritySet( TaskHandle_t xTask,
1148 UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
1153 * void vTaskSuspend( TaskHandle_t xTaskToSuspend );
1156 * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
1157 * See the configuration section for more information.
1159 * Suspend any task. When suspended a task will never get any microcontroller
1160 * processing time, no matter what its priority.
1162 * Calls to vTaskSuspend are not accumulative -
1163 * i.e. calling vTaskSuspend () twice on the same task still only requires one
1164 * call to vTaskResume () to ready the suspended task.
1166 * @param xTaskToSuspend Handle to the task being suspended. Passing a NULL
1167 * handle will cause the calling task to be suspended.
1171 * void vAFunction( void )
1173 * TaskHandle_t xHandle;
1175 * // Create a task, storing the handle.
1176 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1180 * // Use the handle to suspend the created task.
1181 * vTaskSuspend( xHandle );
1185 * // The created task will not run during this period, unless
1186 * // another task calls vTaskResume( xHandle ).
1191 * // Suspend ourselves.
1192 * vTaskSuspend( NULL );
1194 * // We cannot get here unless another task calls vTaskResume
1195 * // with our handle as the parameter.
1198 * \defgroup vTaskSuspend vTaskSuspend
1201 void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION;
1206 * void vTaskResume( TaskHandle_t xTaskToResume );
1209 * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
1210 * See the configuration section for more information.
1212 * Resumes a suspended task.
1214 * A task that has been suspended by one or more calls to vTaskSuspend ()
1215 * will be made available for running again by a single call to
1218 * @param xTaskToResume Handle to the task being readied.
1222 * void vAFunction( void )
1224 * TaskHandle_t xHandle;
1226 * // Create a task, storing the handle.
1227 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1231 * // Use the handle to suspend the created task.
1232 * vTaskSuspend( xHandle );
1236 * // The created task will not run during this period, unless
1237 * // another task calls vTaskResume( xHandle ).
1242 * // Resume the suspended task ourselves.
1243 * vTaskResume( xHandle );
1245 * // The created task will once again get microcontroller processing
1246 * // time in accordance with its priority within the system.
1249 * \defgroup vTaskResume vTaskResume
1252 void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
1257 * void xTaskResumeFromISR( TaskHandle_t xTaskToResume );
1260 * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be
1261 * available. See the configuration section for more information.
1263 * An implementation of vTaskResume() that can be called from within an ISR.
1265 * A task that has been suspended by one or more calls to vTaskSuspend ()
1266 * will be made available for running again by a single call to
1267 * xTaskResumeFromISR ().
1269 * xTaskResumeFromISR() should not be used to synchronise a task with an
1270 * interrupt if there is a chance that the interrupt could arrive prior to the
1271 * task being suspended - as this can lead to interrupts being missed. Use of a
1272 * semaphore as a synchronisation mechanism would avoid this eventuality.
1274 * @param xTaskToResume Handle to the task being readied.
1276 * @return pdTRUE if resuming the task should result in a context switch,
1277 * otherwise pdFALSE. This is used by the ISR to determine if a context switch
1278 * may be required following the ISR.
1280 * \defgroup vTaskResumeFromISR vTaskResumeFromISR
1283 BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
1285 #if ( configUSE_CORE_AFFINITY == 1 )
1288 * @brief Sets the core affinity mask for a task.
1290 * It sets the cores on which a task can run. configUSE_CORE_AFFINITY must
1291 * be defined as 1 for this function to be available.
1293 * @param xTask The handle of the task to set the core affinity mask for.
1294 * Passing NULL will set the core affinity mask for the calling task.
1296 * @param uxCoreAffinityMask A bitwise value that indicates the cores on
1297 * which the task can run. Cores are numbered from 0 to configNUMBER_OF_CORES - 1.
1298 * For example, to ensure that a task can run on core 0 and core 1, set
1299 * uxCoreAffinityMask to 0x03.
1303 * // The function that creates task.
1304 * void vAFunction( void )
1306 * TaskHandle_t xHandle;
1307 * UBaseType_t uxCoreAffinityMask;
1309 * // Create a task, storing the handle.
1310 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &( xHandle ) );
1312 * // Define the core affinity mask such that this task can only run
1313 * // on core 0 and core 2.
1314 * uxCoreAffinityMask = ( ( 1 << 0 ) | ( 1 << 2 ) );
1316 * //Set the core affinity mask for the task.
1317 * vTaskCoreAffinitySet( xHandle, uxCoreAffinityMask );
1320 void vTaskCoreAffinitySet( const TaskHandle_t xTask,
1321 UBaseType_t uxCoreAffinityMask );
1324 #if ( ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
1327 * @brief Gets the core affinity mask for a task.
1329 * configUSE_CORE_AFFINITY must be defined as 1 for this function to be
1332 * @param xTask The handle of the task to get the core affinity mask for.
1333 * Passing NULL will get the core affinity mask for the calling task.
1335 * @return The core affinity mask which is a bitwise value that indicates
1336 * the cores on which a task can run. Cores are numbered from 0 to
1337 * configNUMBER_OF_CORES - 1. For example, if a task can run on core 0 and core 1,
1338 * the core affinity mask is 0x03.
1342 * // Task handle of the networking task - it is populated elsewhere.
1343 * TaskHandle_t xNetworkingTaskHandle;
1345 * void vAFunction( void )
1347 * TaskHandle_t xHandle;
1348 * UBaseType_t uxNetworkingCoreAffinityMask;
1350 * // Create a task, storing the handle.
1351 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &( xHandle ) );
1353 * //Get the core affinity mask for the networking task.
1354 * uxNetworkingCoreAffinityMask = vTaskCoreAffinityGet( xNetworkingTaskHandle );
1356 * // Here is a hypothetical scenario, just for the example. Assume that we
1357 * // have 2 cores - Core 0 and core 1. We want to pin the application task to
1358 * // the core different than the networking task to ensure that the
1359 * // application task does not interfere with networking.
1360 * if( ( uxNetworkingCoreAffinityMask & ( 1 << 0 ) ) != 0 )
1362 * // The networking task can run on core 0, pin our task to core 1.
1363 * vTaskCoreAffinitySet( xHandle, ( 1 << 1 ) );
1367 * // Otherwise, pin our task to core 0.
1368 * vTaskCoreAffinitySet( xHandle, ( 1 << 0 ) );
1372 UBaseType_t vTaskCoreAffinityGet( ConstTaskHandle_t xTask );
1375 #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
1378 * @brief Disables preemption for a task.
1380 * @param xTask The handle of the task to disable preemption. Passing NULL
1381 * disables preemption for the calling task.
1385 * void vTaskCode( void *pvParameters )
1387 * // Silence warnings about unused parameters.
1388 * ( void ) pvParameters;
1392 * // ... Perform some function here.
1394 * // Disable preemption for this task.
1395 * vTaskPreemptionDisable( NULL );
1397 * // The task will not be preempted when it is executing in this portion ...
1399 * // ... until the preemption is enabled again.
1400 * vTaskPreemptionEnable( NULL );
1402 * // The task can be preempted when it is executing in this portion.
1406 void vTaskPreemptionDisable( const TaskHandle_t xTask );
1409 #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
1412 * @brief Enables preemption for a task.
1414 * @param xTask The handle of the task to enable preemption. Passing NULL
1415 * enables preemption for the calling task.
1419 * void vTaskCode( void *pvParameters )
1421 * // Silence warnings about unused parameters.
1422 * ( void ) pvParameters;
1426 * // ... Perform some function here.
1428 * // Disable preemption for this task.
1429 * vTaskPreemptionDisable( NULL );
1431 * // The task will not be preempted when it is executing in this portion ...
1433 * // ... until the preemption is enabled again.
1434 * vTaskPreemptionEnable( NULL );
1436 * // The task can be preempted when it is executing in this portion.
1440 void vTaskPreemptionEnable( const TaskHandle_t xTask );
1443 /*-----------------------------------------------------------
1445 *----------------------------------------------------------*/
1450 * void vTaskStartScheduler( void );
1453 * Starts the real time kernel tick processing. After calling the kernel
1454 * has control over which tasks are executed and when.
1456 * See the demo application file main.c for an example of creating
1457 * tasks and starting the kernel.
1461 * void vAFunction( void )
1463 * // Create at least one task before starting the kernel.
1464 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
1466 * // Start the real time kernel with preemption.
1467 * vTaskStartScheduler ();
1469 * // Will not get here unless a task calls vTaskEndScheduler ()
1473 * \defgroup vTaskStartScheduler vTaskStartScheduler
1474 * \ingroup SchedulerControl
1476 void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;
1481 * void vTaskEndScheduler( void );
1484 * NOTE: At the time of writing only the x86 real mode port, which runs on a PC
1485 * in place of DOS, implements this function.
1487 * Stops the real time kernel tick. All created tasks will be automatically
1488 * deleted and multitasking (either preemptive or cooperative) will
1489 * stop. Execution then resumes from the point where vTaskStartScheduler ()
1490 * was called, as if vTaskStartScheduler () had just returned.
1492 * See the demo application file main. c in the demo/PC directory for an
1493 * example that uses vTaskEndScheduler ().
1495 * vTaskEndScheduler () requires an exit function to be defined within the
1496 * portable layer (see vPortEndScheduler () in port. c for the PC port). This
1497 * performs hardware specific operations such as stopping the kernel tick.
1499 * vTaskEndScheduler () will cause all of the resources allocated by the
1500 * kernel to be freed - but will not free resources allocated by application
1505 * void vTaskCode( void * pvParameters )
1509 * // Task code goes here.
1511 * // At some point we want to end the real time kernel processing
1513 * vTaskEndScheduler ();
1517 * void vAFunction( void )
1519 * // Create at least one task before starting the kernel.
1520 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
1522 * // Start the real time kernel with preemption.
1523 * vTaskStartScheduler ();
1525 * // Will only get here when the vTaskCode () task has called
1526 * // vTaskEndScheduler (). When we get here we are back to single task
1531 * \defgroup vTaskEndScheduler vTaskEndScheduler
1532 * \ingroup SchedulerControl
1534 void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;
1539 * void vTaskSuspendAll( void );
1542 * Suspends the scheduler without disabling interrupts. Context switches will
1543 * not occur while the scheduler is suspended.
1545 * After calling vTaskSuspendAll () the calling task will continue to execute
1546 * without risk of being swapped out until a call to xTaskResumeAll () has been
1549 * API functions that have the potential to cause a context switch (for example,
1550 * xTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler
1555 * void vTask1( void * pvParameters )
1559 * // Task code goes here.
1563 * // At some point the task wants to perform a long operation during
1564 * // which it does not want to get swapped out. It cannot use
1565 * // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
1566 * // operation may cause interrupts to be missed - including the
1569 * // Prevent the real time kernel swapping out the task.
1570 * vTaskSuspendAll ();
1572 * // Perform the operation here. There is no need to use critical
1573 * // sections as we have all the microcontroller processing time.
1574 * // During this time interrupts will still operate and the kernel
1575 * // tick count will be maintained.
1579 * // The operation is complete. Restart the kernel.
1580 * xTaskResumeAll ();
1584 * \defgroup vTaskSuspendAll vTaskSuspendAll
1585 * \ingroup SchedulerControl
1587 void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;
1592 * BaseType_t xTaskResumeAll( void );
1595 * Resumes scheduler activity after it was suspended by a call to
1596 * vTaskSuspendAll().
1598 * xTaskResumeAll() only resumes the scheduler. It does not unsuspend tasks
1599 * that were previously suspended by a call to vTaskSuspend().
1601 * @return If resuming the scheduler caused a context switch then pdTRUE is
1602 * returned, otherwise pdFALSE is returned.
1606 * void vTask1( void * pvParameters )
1610 * // Task code goes here.
1614 * // At some point the task wants to perform a long operation during
1615 * // which it does not want to get swapped out. It cannot use
1616 * // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
1617 * // operation may cause interrupts to be missed - including the
1620 * // Prevent the real time kernel swapping out the task.
1621 * vTaskSuspendAll ();
1623 * // Perform the operation here. There is no need to use critical
1624 * // sections as we have all the microcontroller processing time.
1625 * // During this time interrupts will still operate and the real
1626 * // time kernel tick count will be maintained.
1630 * // The operation is complete. Restart the kernel. We want to force
1631 * // a context switch - but there is no point if resuming the scheduler
1632 * // caused a context switch already.
1633 * if( !xTaskResumeAll () )
1640 * \defgroup xTaskResumeAll xTaskResumeAll
1641 * \ingroup SchedulerControl
1643 BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION;
1645 /*-----------------------------------------------------------
1647 *----------------------------------------------------------*/
1652 * TickType_t xTaskGetTickCount( void );
1655 * @return The count of ticks since vTaskStartScheduler was called.
1657 * \defgroup xTaskGetTickCount xTaskGetTickCount
1658 * \ingroup TaskUtils
1660 TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;
1665 * TickType_t xTaskGetTickCountFromISR( void );
1668 * @return The count of ticks since vTaskStartScheduler was called.
1670 * This is a version of xTaskGetTickCount() that is safe to be called from an
1671 * ISR - provided that TickType_t is the natural word size of the
1672 * microcontroller being used or interrupt nesting is either not supported or
1675 * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR
1676 * \ingroup TaskUtils
1678 TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION;
1683 * uint16_t uxTaskGetNumberOfTasks( void );
1686 * @return The number of tasks that the real time kernel is currently managing.
1687 * This includes all ready, blocked and suspended tasks. A task that
1688 * has been deleted but not yet freed by the idle task will also be
1689 * included in the count.
1691 * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks
1692 * \ingroup TaskUtils
1694 UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;
1699 * char *pcTaskGetName( TaskHandle_t xTaskToQuery );
1702 * @return The text (human readable) name of the task referenced by the handle
1703 * xTaskToQuery. A task can query its own name by either passing in its own
1704 * handle, or by setting xTaskToQuery to NULL.
1706 * \defgroup pcTaskGetName pcTaskGetName
1707 * \ingroup TaskUtils
1709 char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1714 * TaskHandle_t xTaskGetHandle( const char *pcNameToQuery );
1717 * NOTE: This function takes a relatively long time to complete and should be
1720 * @return The handle of the task that has the human readable name pcNameToQuery.
1721 * NULL is returned if no matching name is found. INCLUDE_xTaskGetHandle
1722 * must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available.
1724 * \defgroup pcTaskGetHandle pcTaskGetHandle
1725 * \ingroup TaskUtils
1727 TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1732 * BaseType_t xTaskGetStaticBuffers( TaskHandle_t xTask,
1733 * StackType_t ** ppuxStackBuffer,
1734 * StaticTask_t ** ppxTaskBuffer );
1737 * Retrieve pointers to a statically created task's data structure
1738 * buffer and stack buffer. These are the same buffers that are supplied
1739 * at the time of creation.
1741 * @param xTask The task for which to retrieve the buffers.
1743 * @param ppuxStackBuffer Used to return a pointer to the task's stack buffer.
1745 * @param ppxTaskBuffer Used to return a pointer to the task's data structure
1748 * @return pdTRUE if buffers were retrieved, pdFALSE otherwise.
1750 * \defgroup xTaskGetStaticBuffers xTaskGetStaticBuffers
1751 * \ingroup TaskUtils
1753 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1754 BaseType_t xTaskGetStaticBuffers( TaskHandle_t xTask,
1755 StackType_t ** ppuxStackBuffer,
1756 StaticTask_t ** ppxTaskBuffer ) PRIVILEGED_FUNCTION;
1757 #endif /* configSUPPORT_STATIC_ALLOCATION */
1762 * UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );
1765 * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for
1766 * this function to be available.
1768 * Returns the high water mark of the stack associated with xTask. That is,
1769 * the minimum free stack space there has been (in words, so on a 32 bit machine
1770 * a value of 1 means 4 bytes) since the task started. The smaller the returned
1771 * number the closer the task has come to overflowing its stack.
1773 * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
1774 * same except for their return type. Using configSTACK_DEPTH_TYPE allows the
1775 * user to determine the return type. It gets around the problem of the value
1776 * overflowing on 8-bit types without breaking backward compatibility for
1777 * applications that expect an 8-bit return type.
1779 * @param xTask Handle of the task associated with the stack to be checked.
1780 * Set xTask to NULL to check the stack of the calling task.
1782 * @return The smallest amount of free stack space there has been (in words, so
1783 * actual spaces on the stack rather than bytes) since the task referenced by
1784 * xTask was created.
1786 UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1791 * configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask );
1794 * INCLUDE_uxTaskGetStackHighWaterMark2 must be set to 1 in FreeRTOSConfig.h for
1795 * this function to be available.
1797 * Returns the high water mark of the stack associated with xTask. That is,
1798 * the minimum free stack space there has been (in words, so on a 32 bit machine
1799 * a value of 1 means 4 bytes) since the task started. The smaller the returned
1800 * number the closer the task has come to overflowing its stack.
1802 * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
1803 * same except for their return type. Using configSTACK_DEPTH_TYPE allows the
1804 * user to determine the return type. It gets around the problem of the value
1805 * overflowing on 8-bit types without breaking backward compatibility for
1806 * applications that expect an 8-bit return type.
1808 * @param xTask Handle of the task associated with the stack to be checked.
1809 * Set xTask to NULL to check the stack of the calling task.
1811 * @return The smallest amount of free stack space there has been (in words, so
1812 * actual spaces on the stack rather than bytes) since the task referenced by
1813 * xTask was created.
1815 configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1817 /* When using trace macros it is sometimes necessary to include task.h before
1818 * FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,
1819 * so the following two prototypes will cause a compilation error. This can be
1820 * fixed by simply guarding against the inclusion of these two prototypes unless
1821 * they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration
1823 #ifdef configUSE_APPLICATION_TASK_TAG
1824 #if configUSE_APPLICATION_TASK_TAG == 1
1829 * void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );
1832 * Sets pxHookFunction to be the task hook function used by the task xTask.
1833 * Passing xTask as NULL has the effect of setting the calling tasks hook
1836 void vTaskSetApplicationTaskTag( TaskHandle_t xTask,
1837 TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION;
1842 * void xTaskGetApplicationTaskTag( TaskHandle_t xTask );
1845 * Returns the pxHookFunction value assigned to the task xTask. Do not
1846 * call from an interrupt service routine - call
1847 * xTaskGetApplicationTaskTagFromISR() instead.
1849 TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1854 * void xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );
1857 * Returns the pxHookFunction value assigned to the task xTask. Can
1858 * be called from an interrupt service routine.
1860 TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1861 #endif /* configUSE_APPLICATION_TASK_TAG ==1 */
1862 #endif /* ifdef configUSE_APPLICATION_TASK_TAG */
1864 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
1866 /* Each task contains an array of pointers that is dimensioned by the
1867 * configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. The
1868 * kernel does not use the pointers itself, so the application writer can use
1869 * the pointers for any purpose they wish. The following two functions are
1870 * used to set and query a pointer respectively. */
1871 void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet,
1873 void * pvValue ) PRIVILEGED_FUNCTION;
1874 void * pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery,
1875 BaseType_t xIndex ) PRIVILEGED_FUNCTION;
1879 #if ( configCHECK_FOR_STACK_OVERFLOW > 0 )
1884 * void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName);
1887 * The application stack overflow hook is called when a stack overflow is detected for a task.
1889 * Details on stack overflow detection can be found here: https://www.FreeRTOS.org/Stacks-and-stack-overflow-checking.html
1891 * @param xTask the task that just exceeded its stack boundaries.
1892 * @param pcTaskName A character string containing the name of the offending task.
1894 void vApplicationStackOverflowHook( TaskHandle_t xTask,
1895 char * pcTaskName );
1899 #if ( configUSE_IDLE_HOOK == 1 )
1904 * void vApplicationIdleHook( void );
1907 * The application idle hook is called by the idle task.
1908 * This allows the application designer to add background functionality without
1909 * the overhead of a separate task.
1910 * NOTE: vApplicationIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES, CALL A FUNCTION THAT MIGHT BLOCK.
1912 void vApplicationIdleHook( void );
1917 #if ( configUSE_TICK_HOOK != 0 )
1922 * void vApplicationTickHook( void );
1925 * This hook function is called in the system tick handler after any OS work is completed.
1927 void vApplicationTickHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */
1931 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1936 * void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )
1939 * 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
1940 * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION
1942 * @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer
1943 * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task
1944 * @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
1946 void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
1947 StackType_t ** ppxIdleTaskStackBuffer,
1948 uint32_t * pulIdleTaskStackSize ); /*lint !e526 Symbol not defined as it is an application callback. */
1954 * BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );
1957 * Calls the hook function associated with xTask. Passing xTask as NULL has
1958 * the effect of calling the Running tasks (the calling task) hook function.
1960 * pvParameter is passed to the hook function for the task to interpret as it
1961 * wants. The return value is the value returned by the task hook function
1962 * registered by the user.
1964 BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask,
1965 void * pvParameter ) PRIVILEGED_FUNCTION;
1968 * xTaskGetIdleTaskHandle() is only available if
1969 * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.
1971 * Simply returns the handle of the idle task. It is not valid to call
1972 * xTaskGetIdleTaskHandle() before the scheduler has been started.
1974 TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
1977 * configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for
1978 * uxTaskGetSystemState() to be available.
1980 * uxTaskGetSystemState() populates an TaskStatus_t structure for each task in
1981 * the system. TaskStatus_t structures contain, among other things, members
1982 * for the task handle, task name, task priority, task state, and total amount
1983 * of run time consumed by the task. See the TaskStatus_t structure
1984 * definition in this file for the full member list.
1986 * NOTE: This function is intended for debugging use only as its use results in
1987 * the scheduler remaining suspended for an extended period.
1989 * @param pxTaskStatusArray A pointer to an array of TaskStatus_t structures.
1990 * The array must contain at least one TaskStatus_t structure for each task
1991 * that is under the control of the RTOS. The number of tasks under the control
1992 * of the RTOS can be determined using the uxTaskGetNumberOfTasks() API function.
1994 * @param uxArraySize The size of the array pointed to by the pxTaskStatusArray
1995 * parameter. The size is specified as the number of indexes in the array, or
1996 * the number of TaskStatus_t structures contained in the array, not by the
1997 * number of bytes in the array.
1999 * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in
2000 * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the
2001 * total run time (as defined by the run time stats clock, see
2002 * https://www.FreeRTOS.org/rtos-run-time-stats.html) since the target booted.
2003 * pulTotalRunTime can be set to NULL to omit the total run time information.
2005 * @return The number of TaskStatus_t structures that were populated by
2006 * uxTaskGetSystemState(). This should equal the number returned by the
2007 * uxTaskGetNumberOfTasks() API function, but will be zero if the value passed
2008 * in the uxArraySize parameter was too small.
2012 * // This example demonstrates how a human readable table of run time stats
2013 * // information is generated from raw data provided by uxTaskGetSystemState().
2014 * // The human readable table is written to pcWriteBuffer
2015 * void vTaskGetRunTimeStats( char *pcWriteBuffer )
2017 * TaskStatus_t *pxTaskStatusArray;
2018 * volatile UBaseType_t uxArraySize, x;
2019 * configRUN_TIME_COUNTER_TYPE ulTotalRunTime, ulStatsAsPercentage;
2021 * // Make sure the write buffer does not contain a string.
2022 * pcWriteBuffer = 0x00;
2024 * // Take a snapshot of the number of tasks in case it changes while this
2025 * // function is executing.
2026 * uxArraySize = uxTaskGetNumberOfTasks();
2028 * // Allocate a TaskStatus_t structure for each task. An array could be
2029 * // allocated statically at compile time.
2030 * pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
2032 * if( pxTaskStatusArray != NULL )
2034 * // Generate raw status information about each task.
2035 * uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );
2037 * // For percentage calculations.
2038 * ulTotalRunTime /= 100UL;
2040 * // Avoid divide by zero errors.
2041 * if( ulTotalRunTime > 0 )
2043 * // For each populated position in the pxTaskStatusArray array,
2044 * // format the raw data as human readable ASCII data
2045 * for( x = 0; x < uxArraySize; x++ )
2047 * // What percentage of the total run time has the task used?
2048 * // This will always be rounded down to the nearest integer.
2049 * // ulTotalRunTimeDiv100 has already been divided by 100.
2050 * ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;
2052 * if( ulStatsAsPercentage > 0UL )
2054 * sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
2058 * // If the percentage is zero here then the task has
2059 * // consumed less than 1% of the total run time.
2060 * sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );
2063 * pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );
2067 * // The array is no longer needed, free the memory it consumes.
2068 * vPortFree( pxTaskStatusArray );
2073 UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray,
2074 const UBaseType_t uxArraySize,
2075 configRUN_TIME_COUNTER_TYPE * const pulTotalRunTime ) PRIVILEGED_FUNCTION;
2080 * void vTaskListTasks( char *pcWriteBuffer, size_t uxBufferLength );
2083 * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must
2084 * both be defined as 1 for this function to be available. See the
2085 * configuration section of the FreeRTOS.org website for more information.
2087 * NOTE 1: This function will disable interrupts for its duration. It is
2088 * not intended for normal application runtime use but as a debug aid.
2090 * Lists all the current tasks, along with their current state and stack
2091 * usage high water mark.
2093 * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or
2098 * This function is provided for convenience only, and is used by many of the
2099 * demo applications. Do not consider it to be part of the scheduler.
2101 * vTaskListTasks() calls uxTaskGetSystemState(), then formats part of the
2102 * uxTaskGetSystemState() output into a human readable table that displays task:
2103 * names, states, priority, stack usage and task number.
2104 * Stack usage specified as the number of unused StackType_t words stack can hold
2105 * on top of stack - not the number of bytes.
2107 * vTaskListTasks() has a dependency on the snprintf() C library function that might
2108 * bloat the code size, use a lot of stack, and provide different results on
2109 * different platforms. An alternative, tiny, third party, and limited
2110 * functionality implementation of snprintf() is provided in many of the
2111 * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
2112 * printf-stdarg.c does not provide a full snprintf() implementation!).
2114 * It is recommended that production systems call uxTaskGetSystemState()
2115 * directly to get access to raw stats data, rather than indirectly through a
2116 * call to vTaskListTasks().
2118 * @param pcWriteBuffer A buffer into which the above mentioned details
2119 * will be written, in ASCII form. This buffer is assumed to be large
2120 * enough to contain the generated report. Approximately 40 bytes per
2121 * task should be sufficient.
2123 * @param uxBufferLength Length of the pcWriteBuffer.
2125 * \defgroup vTaskListTasks vTaskListTasks
2126 * \ingroup TaskUtils
2128 void vTaskListTasks( char * pcWriteBuffer,
2129 size_t uxBufferLength ) PRIVILEGED_FUNCTION;
2134 * void vTaskList( char *pcWriteBuffer );
2137 * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must
2138 * both be defined as 1 for this function to be available. See the
2139 * configuration section of the FreeRTOS.org website for more information.
2141 * WARN: This function assumes that the pcWriteBuffer is of length
2142 * configSTATS_BUFFER_MAX_LENGTH. This function is there only for
2143 * backward compatibility. New applications are recommended to
2144 * use vTaskListTasks and supply the length of the pcWriteBuffer explicitly.
2146 * NOTE 1: This function will disable interrupts for its duration. It is
2147 * not intended for normal application runtime use but as a debug aid.
2149 * Lists all the current tasks, along with their current state and stack
2150 * usage high water mark.
2152 * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or
2157 * This function is provided for convenience only, and is used by many of the
2158 * demo applications. Do not consider it to be part of the scheduler.
2160 * vTaskList() calls uxTaskGetSystemState(), then formats part of the
2161 * uxTaskGetSystemState() output into a human readable table that displays task:
2162 * names, states, priority, stack usage and task number.
2163 * Stack usage specified as the number of unused StackType_t words stack can hold
2164 * on top of stack - not the number of bytes.
2166 * vTaskList() has a dependency on the snprintf() C library function that might
2167 * bloat the code size, use a lot of stack, and provide different results on
2168 * different platforms. An alternative, tiny, third party, and limited
2169 * functionality implementation of snprintf() is provided in many of the
2170 * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
2171 * printf-stdarg.c does not provide a full snprintf() implementation!).
2173 * It is recommended that production systems call uxTaskGetSystemState()
2174 * directly to get access to raw stats data, rather than indirectly through a
2175 * call to vTaskList().
2177 * @param pcWriteBuffer A buffer into which the above mentioned details
2178 * will be written, in ASCII form. This buffer is assumed to be large
2179 * enough to contain the generated report. Approximately 40 bytes per
2180 * task should be sufficient.
2182 * \defgroup vTaskList vTaskList
2183 * \ingroup TaskUtils
2185 #define vTaskList( pcWriteBuffer ) vTaskListTasks( pcWriteBuffer, configSTATS_BUFFER_MAX_LENGTH )
2190 * void vTaskGetRunTimeStatistics( char *pcWriteBuffer, size_t uxBufferLength );
2193 * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
2194 * must both be defined as 1 for this function to be available. The application
2195 * must also then provide definitions for
2196 * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
2197 * to configure a peripheral timer/counter and return the timers current count
2198 * value respectively. The counter should be at least 10 times the frequency of
2201 * NOTE 1: This function will disable interrupts for its duration. It is
2202 * not intended for normal application runtime use but as a debug aid.
2204 * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
2205 * accumulated execution time being stored for each task. The resolution
2206 * of the accumulated time value depends on the frequency of the timer
2207 * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
2208 * Calling vTaskGetRunTimeStatistics() writes the total execution time of each
2209 * task into a buffer, both as an absolute count value and as a percentage
2210 * of the total system execution time.
2214 * This function is provided for convenience only, and is used by many of the
2215 * demo applications. Do not consider it to be part of the scheduler.
2217 * vTaskGetRunTimeStatistics() calls uxTaskGetSystemState(), then formats part of
2218 * the uxTaskGetSystemState() output into a human readable table that displays the
2219 * amount of time each task has spent in the Running state in both absolute and
2222 * vTaskGetRunTimeStatistics() has a dependency on the snprintf() C library function
2223 * that might bloat the code size, use a lot of stack, and provide different
2224 * results on different platforms. An alternative, tiny, third party, and
2225 * limited functionality implementation of snprintf() is provided in many of the
2226 * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
2227 * printf-stdarg.c does not provide a full snprintf() implementation!).
2229 * It is recommended that production systems call uxTaskGetSystemState() directly
2230 * to get access to raw stats data, rather than indirectly through a call to
2231 * vTaskGetRunTimeStatistics().
2233 * @param pcWriteBuffer A buffer into which the execution times will be
2234 * written, in ASCII form. This buffer is assumed to be large enough to
2235 * contain the generated report. Approximately 40 bytes per task should
2238 * @param uxBufferLength Length of the pcWriteBuffer.
2240 * \defgroup vTaskGetRunTimeStatistics vTaskGetRunTimeStatistics
2241 * \ingroup TaskUtils
2243 void vTaskGetRunTimeStatistics( char * pcWriteBuffer,
2244 size_t uxBufferLength ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
2249 * void vTaskGetRunTimeStats( char *pcWriteBuffer );
2252 * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
2253 * must both be defined as 1 for this function to be available. The application
2254 * must also then provide definitions for
2255 * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
2256 * to configure a peripheral timer/counter and return the timers current count
2257 * value respectively. The counter should be at least 10 times the frequency of
2260 * WARN: This function assumes that the pcWriteBuffer is of length
2261 * configSTATS_BUFFER_MAX_LENGTH. This function is there only for
2262 * backward compatiblity. New applications are recommended to use
2263 * vTaskGetRunTimeStatistics and supply the length of the pcWriteBuffer
2266 * NOTE 1: This function will disable interrupts for its duration. It is
2267 * not intended for normal application runtime use but as a debug aid.
2269 * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
2270 * accumulated execution time being stored for each task. The resolution
2271 * of the accumulated time value depends on the frequency of the timer
2272 * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
2273 * Calling vTaskGetRunTimeStats() writes the total execution time of each
2274 * task into a buffer, both as an absolute count value and as a percentage
2275 * of the total system execution time.
2279 * This function is provided for convenience only, and is used by many of the
2280 * demo applications. Do not consider it to be part of the scheduler.
2282 * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the
2283 * uxTaskGetSystemState() output into a human readable table that displays the
2284 * amount of time each task has spent in the Running state in both absolute and
2287 * vTaskGetRunTimeStats() has a dependency on the snprintf() C library function
2288 * that might bloat the code size, use a lot of stack, and provide different
2289 * results on different platforms. An alternative, tiny, third party, and
2290 * limited functionality implementation of snprintf() is provided in many of the
2291 * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
2292 * printf-stdarg.c does not provide a full snprintf() implementation!).
2294 * It is recommended that production systems call uxTaskGetSystemState() directly
2295 * to get access to raw stats data, rather than indirectly through a call to
2296 * vTaskGetRunTimeStats().
2298 * @param pcWriteBuffer A buffer into which the execution times will be
2299 * written, in ASCII form. This buffer is assumed to be large enough to
2300 * contain the generated report. Approximately 40 bytes per task should
2303 * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats
2304 * \ingroup TaskUtils
2306 #define vTaskGetRunTimeStats( pcWriteBuffer ) vTaskGetRunTimeStatistics( pcWriteBuffer, configSTATS_BUFFER_MAX_LENGTH )
2311 * configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimeCounter( const TaskHandle_t xTask );
2312 * configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimePercent( const TaskHandle_t xTask );
2315 * configGENERATE_RUN_TIME_STATS must be defined as 1 for these functions to be
2316 * available. The application must also then provide definitions for
2317 * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
2318 * portGET_RUN_TIME_COUNTER_VALUE() to configure a peripheral timer/counter and
2319 * return the timers current count value respectively. The counter should be
2320 * at least 10 times the frequency of the tick count.
2322 * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
2323 * accumulated execution time being stored for each task. The resolution
2324 * of the accumulated time value depends on the frequency of the timer
2325 * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
2326 * While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total
2327 * execution time of each task into a buffer, ulTaskGetRunTimeCounter()
2328 * returns the total execution time of just one task and
2329 * ulTaskGetRunTimePercent() returns the percentage of the CPU time used by
2332 * @return The total run time of the given task or the percentage of the total
2333 * run time consumed by the given task. This is the amount of time the task
2334 * has actually been executing. The unit of time is dependent on the frequency
2335 * configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
2336 * portGET_RUN_TIME_COUNTER_VALUE() macros.
2338 * \defgroup ulTaskGetRunTimeCounter ulTaskGetRunTimeCounter
2339 * \ingroup TaskUtils
2341 configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimeCounter( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
2342 configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimePercent( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
2347 * configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimeCounter( void );
2348 * configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void );
2351 * configGENERATE_RUN_TIME_STATS must be defined as 1 for these functions to be
2352 * available. The application must also then provide definitions for
2353 * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
2354 * portGET_RUN_TIME_COUNTER_VALUE() to configure a peripheral timer/counter and
2355 * return the timers current count value respectively. The counter should be
2356 * at least 10 times the frequency of the tick count.
2358 * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
2359 * accumulated execution time being stored for each task. The resolution
2360 * of the accumulated time value depends on the frequency of the timer
2361 * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
2362 * While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total
2363 * execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter()
2364 * returns the total execution time of just the idle task and
2365 * ulTaskGetIdleRunTimePercent() returns the percentage of the CPU time used by
2366 * just the idle task.
2368 * Note the amount of idle time is only a good measure of the slack time in a
2369 * system if there are no other tasks executing at the idle priority, tickless
2370 * idle is not used, and configIDLE_SHOULD_YIELD is set to 0.
2372 * @return The total run time of the idle task or the percentage of the total
2373 * run time consumed by the idle task. This is the amount of time the
2374 * idle task has actually been executing. The unit of time is dependent on the
2375 * frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
2376 * portGET_RUN_TIME_COUNTER_VALUE() macros.
2378 * \defgroup ulTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter
2379 * \ingroup TaskUtils
2381 configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION;
2382 configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void ) PRIVILEGED_FUNCTION;
2387 * BaseType_t xTaskNotifyIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction );
2388 * BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );
2391 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2393 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2394 * functions to be available.
2396 * Sends a direct to task notification to a task, with an optional value and
2399 * Each task has a private array of "notification values" (or 'notifications'),
2400 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2401 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2402 * array, and (for backward compatibility) defaults to 1 if left undefined.
2403 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2405 * Events can be sent to a task using an intermediary object. Examples of such
2406 * objects are queues, semaphores, mutexes and event groups. Task notifications
2407 * are a method of sending an event directly to a task without the need for such
2408 * an intermediary object.
2410 * A notification sent to a task can optionally perform an action, such as
2411 * update, overwrite or increment one of the task's notification values. In
2412 * that way task notifications can be used to send data to a task, or be used as
2413 * light weight and fast binary or counting semaphores.
2415 * A task can use xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() to
2416 * [optionally] block to wait for a notification to be pending. The task does
2417 * not consume any CPU time while it is in the Blocked state.
2419 * A notification sent to a task will remain pending until it is cleared by the
2420 * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
2421 * un-indexed equivalents). If the task was already in the Blocked state to
2422 * wait for a notification when the notification arrives then the task will
2423 * automatically be removed from the Blocked state (unblocked) and the
2424 * notification cleared.
2426 * **NOTE** Each notification within the array operates independently - a task
2427 * can only block on one notification within the array at a time and will not be
2428 * unblocked by a notification sent to any other array index.
2430 * Backward compatibility information:
2431 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2432 * all task notification API functions operated on that value. Replacing the
2433 * single notification value with an array of notification values necessitated a
2434 * new set of API functions that could address specific notifications within the
2435 * array. xTaskNotify() is the original API function, and remains backward
2436 * compatible by always operating on the notification value at index 0 in the
2437 * array. Calling xTaskNotify() is equivalent to calling xTaskNotifyIndexed()
2438 * with the uxIndexToNotify parameter set to 0.
2440 * @param xTaskToNotify The handle of the task being notified. The handle to a
2441 * task can be returned from the xTaskCreate() API function used to create the
2442 * task, and the handle of the currently running task can be obtained by calling
2443 * xTaskGetCurrentTaskHandle().
2445 * @param uxIndexToNotify The index within the target task's array of
2446 * notification values to which the notification is to be sent. uxIndexToNotify
2447 * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotify() does
2448 * not have this parameter and always sends notifications to index 0.
2450 * @param ulValue Data that can be sent with the notification. How the data is
2451 * used depends on the value of the eAction parameter.
2453 * @param eAction Specifies how the notification updates the task's notification
2454 * value, if at all. Valid values for eAction are as follows:
2457 * The target notification value is bitwise ORed with ulValue.
2458 * xTaskNotifyIndexed() always returns pdPASS in this case.
2461 * The target notification value is incremented. ulValue is not used and
2462 * xTaskNotifyIndexed() always returns pdPASS in this case.
2464 * eSetValueWithOverwrite -
2465 * The target notification value is set to the value of ulValue, even if the
2466 * task being notified had not yet processed the previous notification at the
2467 * same array index (the task already had a notification pending at that index).
2468 * xTaskNotifyIndexed() always returns pdPASS in this case.
2470 * eSetValueWithoutOverwrite -
2471 * If the task being notified did not already have a notification pending at the
2472 * same array index then the target notification value is set to ulValue and
2473 * xTaskNotifyIndexed() will return pdPASS. If the task being notified already
2474 * had a notification pending at the same array index then no action is
2475 * performed and pdFAIL is returned.
2478 * The task receives a notification at the specified array index without the
2479 * notification value at that index being updated. ulValue is not used and
2480 * xTaskNotifyIndexed() always returns pdPASS in this case.
2482 * pulPreviousNotificationValue -
2483 * Can be used to pass out the subject task's notification value before any
2484 * bits are modified by the notify function.
2486 * @return Dependent on the value of eAction. See the description of the
2487 * eAction parameter.
2489 * \defgroup xTaskNotifyIndexed xTaskNotifyIndexed
2490 * \ingroup TaskNotifications
2492 BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify,
2493 UBaseType_t uxIndexToNotify,
2495 eNotifyAction eAction,
2496 uint32_t * pulPreviousNotificationValue ) PRIVILEGED_FUNCTION;
2497 #define xTaskNotify( xTaskToNotify, ulValue, eAction ) \
2498 xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL )
2499 #define xTaskNotifyIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction ) \
2500 xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL )
2505 * BaseType_t xTaskNotifyAndQueryIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue );
2506 * BaseType_t xTaskNotifyAndQuery( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue );
2509 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2511 * xTaskNotifyAndQueryIndexed() performs the same operation as
2512 * xTaskNotifyIndexed() with the addition that it also returns the subject
2513 * task's prior notification value (the notification value at the time the
2514 * function is called rather than when the function returns) in the additional
2515 * pulPreviousNotifyValue parameter.
2517 * xTaskNotifyAndQuery() performs the same operation as xTaskNotify() with the
2518 * addition that it also returns the subject task's prior notification value
2519 * (the notification value as it was at the time the function is called, rather
2520 * than when the function returns) in the additional pulPreviousNotifyValue
2523 * \defgroup xTaskNotifyAndQueryIndexed xTaskNotifyAndQueryIndexed
2524 * \ingroup TaskNotifications
2526 #define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) \
2527 xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
2528 #define xTaskNotifyAndQueryIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotifyValue ) \
2529 xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
2534 * BaseType_t xTaskNotifyIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );
2535 * BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );
2538 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2540 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2541 * functions to be available.
2543 * A version of xTaskNotifyIndexed() that can be used from an interrupt service
2546 * Each task has a private array of "notification values" (or 'notifications'),
2547 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2548 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2549 * array, and (for backward compatibility) defaults to 1 if left undefined.
2550 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2552 * Events can be sent to a task using an intermediary object. Examples of such
2553 * objects are queues, semaphores, mutexes and event groups. Task notifications
2554 * are a method of sending an event directly to a task without the need for such
2555 * an intermediary object.
2557 * A notification sent to a task can optionally perform an action, such as
2558 * update, overwrite or increment one of the task's notification values. In
2559 * that way task notifications can be used to send data to a task, or be used as
2560 * light weight and fast binary or counting semaphores.
2562 * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a
2563 * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block
2564 * to wait for a notification value to have a non-zero value. The task does
2565 * not consume any CPU time while it is in the Blocked state.
2567 * A notification sent to a task will remain pending until it is cleared by the
2568 * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
2569 * un-indexed equivalents). If the task was already in the Blocked state to
2570 * wait for a notification when the notification arrives then the task will
2571 * automatically be removed from the Blocked state (unblocked) and the
2572 * notification cleared.
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.
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. xTaskNotifyFromISR() is the original API function, and remains
2584 * backward compatible by always operating on the notification value at index 0
2585 * within the array. Calling xTaskNotifyFromISR() is equivalent to calling
2586 * xTaskNotifyIndexedFromISR() with the uxIndexToNotify parameter set to 0.
2588 * @param uxIndexToNotify The index within the target task's array of
2589 * notification values to which the notification is to be sent. uxIndexToNotify
2590 * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyFromISR()
2591 * does not have this parameter and always sends notifications to index 0.
2593 * @param xTaskToNotify The handle of the task being notified. The handle to a
2594 * task can be returned from the xTaskCreate() API function used to create the
2595 * task, and the handle of the currently running task can be obtained by calling
2596 * xTaskGetCurrentTaskHandle().
2598 * @param ulValue Data that can be sent with the notification. How the data is
2599 * used depends on the value of the eAction parameter.
2601 * @param eAction Specifies how the notification updates the task's notification
2602 * value, if at all. Valid values for eAction are as follows:
2605 * The task's notification value is bitwise ORed with ulValue. xTaskNotify()
2606 * always returns pdPASS in this case.
2609 * The task's notification value is incremented. ulValue is not used and
2610 * xTaskNotify() always returns pdPASS in this case.
2612 * eSetValueWithOverwrite -
2613 * The task's notification value is set to the value of ulValue, even if the
2614 * task being notified had not yet processed the previous notification (the
2615 * task already had a notification pending). xTaskNotify() always returns
2616 * pdPASS in this case.
2618 * eSetValueWithoutOverwrite -
2619 * If the task being notified did not already have a notification pending then
2620 * the task's notification value is set to ulValue and xTaskNotify() will
2621 * return pdPASS. If the task being notified already had a notification
2622 * pending then no action is performed and pdFAIL is returned.
2625 * The task receives a notification without its notification value being
2626 * updated. ulValue is not used and xTaskNotify() always returns pdPASS in
2629 * @param pxHigherPriorityTaskWoken xTaskNotifyFromISR() will set
2630 * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
2631 * task to which the notification was sent to leave the Blocked state, and the
2632 * unblocked task has a priority higher than the currently running task. If
2633 * xTaskNotifyFromISR() sets this value to pdTRUE then a context switch should
2634 * be requested before the interrupt is exited. How a context switch is
2635 * requested from an ISR is dependent on the port - see the documentation page
2636 * for the port in use.
2638 * @return Dependent on the value of eAction. See the description of the
2639 * eAction parameter.
2641 * \defgroup xTaskNotifyIndexedFromISR xTaskNotifyIndexedFromISR
2642 * \ingroup TaskNotifications
2644 BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify,
2645 UBaseType_t uxIndexToNotify,
2647 eNotifyAction eAction,
2648 uint32_t * pulPreviousNotificationValue,
2649 BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
2650 #define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \
2651 xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
2652 #define xTaskNotifyIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \
2653 xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
2658 * BaseType_t xTaskNotifyAndQueryIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken );
2659 * BaseType_t xTaskNotifyAndQueryFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken );
2662 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2664 * xTaskNotifyAndQueryIndexedFromISR() performs the same operation as
2665 * xTaskNotifyIndexedFromISR() with the addition that it also returns the
2666 * subject task's prior notification value (the notification value at the time
2667 * the function is called rather than at the time the function returns) in the
2668 * additional pulPreviousNotifyValue parameter.
2670 * xTaskNotifyAndQueryFromISR() performs the same operation as
2671 * xTaskNotifyFromISR() with the addition that it also returns the subject
2672 * task's prior notification value (the notification value at the time the
2673 * function is called rather than at the time the function returns) in the
2674 * additional pulPreviousNotifyValue parameter.
2676 * \defgroup xTaskNotifyAndQueryIndexedFromISR xTaskNotifyAndQueryIndexedFromISR
2677 * \ingroup TaskNotifications
2679 #define xTaskNotifyAndQueryIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \
2680 xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
2681 #define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \
2682 xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
2687 * BaseType_t xTaskNotifyWaitIndexed( UBaseType_t uxIndexToWaitOn, uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
2689 * BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
2692 * Waits for a direct to task notification to be pending at a given index within
2693 * an array of direct to task notifications.
2695 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2697 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
2698 * function to be available.
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.
2706 * Events can be sent to a task using an intermediary object. Examples of such
2707 * objects are queues, semaphores, mutexes and event groups. Task notifications
2708 * are a method of sending an event directly to a task without the need for such
2709 * an intermediary object.
2711 * A notification sent to a task can optionally perform an action, such as
2712 * update, overwrite or increment one of the task's notification values. In
2713 * that way task notifications can be used to send data to a task, or be used as
2714 * light weight and fast binary or counting semaphores.
2716 * A notification sent to a task will remain pending until it is cleared by the
2717 * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
2718 * un-indexed equivalents). If the task was already in the Blocked state to
2719 * wait for a notification when the notification arrives then the task will
2720 * automatically be removed from the Blocked state (unblocked) and the
2721 * notification cleared.
2723 * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a
2724 * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block
2725 * to wait for a notification value to have a non-zero value. The task does
2726 * not consume any CPU time while it is in the Blocked state.
2728 * **NOTE** Each notification within the array operates independently - a task
2729 * can only block on one notification within the array at a time and will not be
2730 * unblocked by a notification sent to any other array index.
2732 * Backward compatibility information:
2733 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2734 * all task notification API functions operated on that value. Replacing the
2735 * single notification value with an array of notification values necessitated a
2736 * new set of API functions that could address specific notifications within the
2737 * array. xTaskNotifyWait() is the original API function, and remains backward
2738 * compatible by always operating on the notification value at index 0 in the
2739 * array. Calling xTaskNotifyWait() is equivalent to calling
2740 * xTaskNotifyWaitIndexed() with the uxIndexToWaitOn parameter set to 0.
2742 * @param uxIndexToWaitOn The index within the calling task's array of
2743 * notification values on which the calling task will wait for a notification to
2744 * be received. uxIndexToWaitOn must be less than
2745 * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyWait() does
2746 * not have this parameter and always waits for notifications on index 0.
2748 * @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value
2749 * will be cleared in the calling task's notification value before the task
2750 * checks to see if any notifications are pending, and optionally blocks if no
2751 * notifications are pending. Setting ulBitsToClearOnEntry to ULONG_MAX (if
2752 * limits.h is included) or 0xffffffffUL (if limits.h is not included) will have
2753 * the effect of resetting the task's notification value to 0. Setting
2754 * ulBitsToClearOnEntry to 0 will leave the task's notification value unchanged.
2756 * @param ulBitsToClearOnExit If a notification is pending or received before
2757 * the calling task exits the xTaskNotifyWait() function then the task's
2758 * notification value (see the xTaskNotify() API function) is passed out using
2759 * the pulNotificationValue parameter. Then any bits that are set in
2760 * ulBitsToClearOnExit will be cleared in the task's notification value (note
2761 * *pulNotificationValue is set before any bits are cleared). Setting
2762 * ulBitsToClearOnExit to ULONG_MAX (if limits.h is included) or 0xffffffffUL
2763 * (if limits.h is not included) will have the effect of resetting the task's
2764 * notification value to 0 before the function exits. Setting
2765 * ulBitsToClearOnExit to 0 will leave the task's notification value unchanged
2766 * when the function exits (in which case the value passed out in
2767 * pulNotificationValue will match the task's notification value).
2769 * @param pulNotificationValue Used to pass the task's notification value out
2770 * of the function. Note the value passed out will not be effected by the
2771 * clearing of any bits caused by ulBitsToClearOnExit being non-zero.
2773 * @param xTicksToWait The maximum amount of time that the task should wait in
2774 * the Blocked state for a notification to be received, should a notification
2775 * not already be pending when xTaskNotifyWait() was called. The task
2776 * will not consume any processing time while it is in the Blocked state. This
2777 * is specified in kernel ticks, the macro pdMS_TO_TICKS( value_in_ms ) can be
2778 * used to convert a time specified in milliseconds to a time specified in
2781 * @return If a notification was received (including notifications that were
2782 * already pending when xTaskNotifyWait was called) then pdPASS is
2783 * returned. Otherwise pdFAIL is returned.
2785 * \defgroup xTaskNotifyWaitIndexed xTaskNotifyWaitIndexed
2786 * \ingroup TaskNotifications
2788 BaseType_t xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn,
2789 uint32_t ulBitsToClearOnEntry,
2790 uint32_t ulBitsToClearOnExit,
2791 uint32_t * pulNotificationValue,
2792 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2793 #define xTaskNotifyWait( ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \
2794 xTaskGenericNotifyWait( tskDEFAULT_INDEX_TO_NOTIFY, ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) )
2795 #define xTaskNotifyWaitIndexed( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \
2796 xTaskGenericNotifyWait( ( uxIndexToWaitOn ), ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) )
2801 * BaseType_t xTaskNotifyGiveIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify );
2802 * BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );
2805 * Sends a direct to task notification to a particular index in the target
2806 * task's notification array in a manner similar to giving a counting semaphore.
2808 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
2810 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2811 * macros to be available.
2813 * Each task has a private array of "notification values" (or 'notifications'),
2814 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2815 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2816 * array, and (for backward compatibility) defaults to 1 if left undefined.
2817 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2819 * Events can be sent to a task using an intermediary object. Examples of such
2820 * objects are queues, semaphores, mutexes and event groups. Task notifications
2821 * are a method of sending an event directly to a task without the need for such
2822 * an intermediary object.
2824 * A notification sent to a task can optionally perform an action, such as
2825 * update, overwrite or increment one of the task's notification values. In
2826 * that way task notifications can be used to send data to a task, or be used as
2827 * light weight and fast binary or counting semaphores.
2829 * xTaskNotifyGiveIndexed() is a helper macro intended for use when task
2830 * notifications are used as light weight and faster binary or counting
2831 * semaphore equivalents. Actual FreeRTOS semaphores are given using the
2832 * xSemaphoreGive() API function, the equivalent action that instead uses a task
2833 * notification is xTaskNotifyGiveIndexed().
2835 * When task notifications are being used as a binary or counting semaphore
2836 * equivalent then the task being notified should wait for the notification
2837 * using the ulTaskNotifyTakeIndexed() API function rather than the
2838 * xTaskNotifyWaitIndexed() API function.
2840 * **NOTE** Each notification within the array operates independently - a task
2841 * can only block on one notification within the array at a time and will not be
2842 * unblocked by a notification sent to any other array index.
2844 * Backward compatibility information:
2845 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2846 * all task notification API functions operated on that value. Replacing the
2847 * single notification value with an array of notification values necessitated a
2848 * new set of API functions that could address specific notifications within the
2849 * array. xTaskNotifyGive() is the original API function, and remains backward
2850 * compatible by always operating on the notification value at index 0 in the
2851 * array. Calling xTaskNotifyGive() is equivalent to calling
2852 * xTaskNotifyGiveIndexed() with the uxIndexToNotify parameter set to 0.
2854 * @param xTaskToNotify The handle of the task being notified. The handle to a
2855 * task can be returned from the xTaskCreate() API function used to create the
2856 * task, and the handle of the currently running task can be obtained by calling
2857 * xTaskGetCurrentTaskHandle().
2859 * @param uxIndexToNotify The index within the target task's array of
2860 * notification values to which the notification is to be sent. uxIndexToNotify
2861 * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyGive()
2862 * does not have this parameter and always sends notifications to index 0.
2864 * @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the
2865 * eAction parameter set to eIncrement - so pdPASS is always returned.
2867 * \defgroup xTaskNotifyGiveIndexed xTaskNotifyGiveIndexed
2868 * \ingroup TaskNotifications
2870 #define xTaskNotifyGive( xTaskToNotify ) \
2871 xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( 0 ), eIncrement, NULL )
2872 #define xTaskNotifyGiveIndexed( xTaskToNotify, uxIndexToNotify ) \
2873 xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( 0 ), eIncrement, NULL )
2878 * void vTaskNotifyGiveIndexedFromISR( TaskHandle_t xTaskHandle, UBaseType_t uxIndexToNotify, BaseType_t *pxHigherPriorityTaskWoken );
2879 * void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );
2882 * A version of xTaskNotifyGiveIndexed() that can be called from an interrupt
2883 * service routine (ISR).
2885 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
2887 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro
2890 * Each task has a private array of "notification values" (or 'notifications'),
2891 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2892 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2893 * array, and (for backward compatibility) defaults to 1 if left undefined.
2894 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2896 * Events can be sent to a task using an intermediary object. Examples of such
2897 * objects are queues, semaphores, mutexes and event groups. Task notifications
2898 * are a method of sending an event directly to a task without the need for such
2899 * an intermediary object.
2901 * A notification sent to a task can optionally perform an action, such as
2902 * update, overwrite or increment one of the task's notification values. In
2903 * that way task notifications can be used to send data to a task, or be used as
2904 * light weight and fast binary or counting semaphores.
2906 * vTaskNotifyGiveIndexedFromISR() is intended for use when task notifications
2907 * are used as light weight and faster binary or counting semaphore equivalents.
2908 * Actual FreeRTOS semaphores are given from an ISR using the
2909 * xSemaphoreGiveFromISR() API function, the equivalent action that instead uses
2910 * a task notification is vTaskNotifyGiveIndexedFromISR().
2912 * When task notifications are being used as a binary or counting semaphore
2913 * equivalent then the task being notified should wait for the notification
2914 * using the ulTaskNotifyTakeIndexed() API function rather than the
2915 * xTaskNotifyWaitIndexed() API function.
2917 * **NOTE** Each notification within the array operates independently - a task
2918 * can only block on one notification within the array at a time and will not be
2919 * unblocked by a notification sent to any other array index.
2921 * Backward compatibility information:
2922 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2923 * all task notification API functions operated on that value. Replacing the
2924 * single notification value with an array of notification values necessitated a
2925 * new set of API functions that could address specific notifications within the
2926 * array. xTaskNotifyFromISR() is the original API function, and remains
2927 * backward compatible by always operating on the notification value at index 0
2928 * within the array. Calling xTaskNotifyGiveFromISR() is equivalent to calling
2929 * xTaskNotifyGiveIndexedFromISR() with the uxIndexToNotify parameter set to 0.
2931 * @param xTaskToNotify The handle of the task being notified. The handle to a
2932 * task can be returned from the xTaskCreate() API function used to create the
2933 * task, and the handle of the currently running task can be obtained by calling
2934 * xTaskGetCurrentTaskHandle().
2936 * @param uxIndexToNotify The index within the target task's array of
2937 * notification values to which the notification is to be sent. uxIndexToNotify
2938 * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
2939 * xTaskNotifyGiveFromISR() does not have this parameter and always sends
2940 * notifications to index 0.
2942 * @param pxHigherPriorityTaskWoken vTaskNotifyGiveFromISR() will set
2943 * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
2944 * task to which the notification was sent to leave the Blocked state, and the
2945 * unblocked task has a priority higher than the currently running task. If
2946 * vTaskNotifyGiveFromISR() sets this value to pdTRUE then a context switch
2947 * should be requested before the interrupt is exited. How a context switch is
2948 * requested from an ISR is dependent on the port - see the documentation page
2949 * for the port in use.
2951 * \defgroup vTaskNotifyGiveIndexedFromISR vTaskNotifyGiveIndexedFromISR
2952 * \ingroup TaskNotifications
2954 void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify,
2955 UBaseType_t uxIndexToNotify,
2956 BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
2957 #define vTaskNotifyGiveFromISR( xTaskToNotify, pxHigherPriorityTaskWoken ) \
2958 vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( pxHigherPriorityTaskWoken ) )
2959 #define vTaskNotifyGiveIndexedFromISR( xTaskToNotify, uxIndexToNotify, pxHigherPriorityTaskWoken ) \
2960 vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( pxHigherPriorityTaskWoken ) )
2965 * uint32_t ulTaskNotifyTakeIndexed( UBaseType_t uxIndexToWaitOn, BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
2967 * uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
2970 * Waits for a direct to task notification on a particular index in the calling
2971 * task's notification array in a manner similar to taking a counting semaphore.
2973 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2975 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
2976 * function to be available.
2978 * Each task has a private array of "notification values" (or 'notifications'),
2979 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2980 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2981 * array, and (for backward compatibility) defaults to 1 if left undefined.
2982 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2984 * Events can be sent to a task using an intermediary object. Examples of such
2985 * objects are queues, semaphores, mutexes and event groups. Task notifications
2986 * are a method of sending an event directly to a task without the need for such
2987 * an intermediary object.
2989 * A notification sent to a task can optionally perform an action, such as
2990 * update, overwrite or increment one of the task's notification values. In
2991 * that way task notifications can be used to send data to a task, or be used as
2992 * light weight and fast binary or counting semaphores.
2994 * ulTaskNotifyTakeIndexed() is intended for use when a task notification is
2995 * used as a faster and lighter weight binary or counting semaphore alternative.
2996 * Actual FreeRTOS semaphores are taken using the xSemaphoreTake() API function,
2997 * the equivalent action that instead uses a task notification is
2998 * ulTaskNotifyTakeIndexed().
3000 * When a task is using its notification value as a binary or counting semaphore
3001 * other tasks should send notifications to it using the xTaskNotifyGiveIndexed()
3002 * macro, or xTaskNotifyIndex() function with the eAction parameter set to
3005 * ulTaskNotifyTakeIndexed() can either clear the task's notification value at
3006 * the array index specified by the uxIndexToWaitOn parameter to zero on exit,
3007 * in which case the notification value acts like a binary semaphore, or
3008 * decrement the notification value on exit, in which case the notification
3009 * value acts like a counting semaphore.
3011 * A task can use ulTaskNotifyTakeIndexed() to [optionally] block to wait for
3012 * a notification. The task does not consume any CPU time while it is in the
3015 * Where as xTaskNotifyWaitIndexed() will return when a notification is pending,
3016 * ulTaskNotifyTakeIndexed() will return when the task's notification value is
3019 * **NOTE** Each notification within the array operates independently - a task
3020 * can only block on one notification within the array at a time and will not be
3021 * unblocked by a notification sent to any other array index.
3023 * Backward compatibility information:
3024 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
3025 * all task notification API functions operated on that value. Replacing the
3026 * single notification value with an array of notification values necessitated a
3027 * new set of API functions that could address specific notifications within the
3028 * array. ulTaskNotifyTake() is the original API function, and remains backward
3029 * compatible by always operating on the notification value at index 0 in the
3030 * array. Calling ulTaskNotifyTake() is equivalent to calling
3031 * ulTaskNotifyTakeIndexed() with the uxIndexToWaitOn parameter set to 0.
3033 * @param uxIndexToWaitOn The index within the calling task's array of
3034 * notification values on which the calling task will wait for a notification to
3035 * be non-zero. uxIndexToWaitOn must be less than
3036 * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyTake() does
3037 * not have this parameter and always waits for notifications on index 0.
3039 * @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's
3040 * notification value is decremented when the function exits. In this way the
3041 * notification value acts like a counting semaphore. If xClearCountOnExit is
3042 * not pdFALSE then the task's notification value is cleared to zero when the
3043 * function exits. In this way the notification value acts like a binary
3046 * @param xTicksToWait The maximum amount of time that the task should wait in
3047 * the Blocked state for the task's notification value to be greater than zero,
3048 * should the count not already be greater than zero when
3049 * ulTaskNotifyTake() was called. The task will not consume any processing
3050 * time while it is in the Blocked state. This is specified in kernel ticks,
3051 * the macro pdMS_TO_TICKS( value_in_ms ) can be used to convert a time
3052 * specified in milliseconds to a time specified in ticks.
3054 * @return The task's notification count before it is either cleared to zero or
3055 * decremented (see the xClearCountOnExit parameter).
3057 * \defgroup ulTaskNotifyTakeIndexed ulTaskNotifyTakeIndexed
3058 * \ingroup TaskNotifications
3060 uint32_t ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn,
3061 BaseType_t xClearCountOnExit,
3062 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
3063 #define ulTaskNotifyTake( xClearCountOnExit, xTicksToWait ) \
3064 ulTaskGenericNotifyTake( ( tskDEFAULT_INDEX_TO_NOTIFY ), ( xClearCountOnExit ), ( xTicksToWait ) )
3065 #define ulTaskNotifyTakeIndexed( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait ) \
3066 ulTaskGenericNotifyTake( ( uxIndexToWaitOn ), ( xClearCountOnExit ), ( xTicksToWait ) )
3071 * BaseType_t xTaskNotifyStateClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToCLear );
3073 * BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
3076 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
3078 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
3079 * functions to be available.
3081 * Each task has a private array of "notification values" (or 'notifications'),
3082 * each of which is a 32-bit unsigned integer (uint32_t). The constant
3083 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
3084 * array, and (for backward compatibility) defaults to 1 if left undefined.
3085 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
3087 * If a notification is sent to an index within the array of notifications then
3088 * the notification at that index is said to be 'pending' until it is read or
3089 * explicitly cleared by the receiving task. xTaskNotifyStateClearIndexed()
3090 * is the function that clears a pending notification without reading the
3091 * notification value. The notification value at the same array index is not
3092 * altered. Set xTask to NULL to clear the notification state of the calling
3095 * Backward compatibility information:
3096 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
3097 * all task notification API functions operated on that value. Replacing the
3098 * single notification value with an array of notification values necessitated a
3099 * new set of API functions that could address specific notifications within the
3100 * array. xTaskNotifyStateClear() is the original API function, and remains
3101 * backward compatible by always operating on the notification value at index 0
3102 * within the array. Calling xTaskNotifyStateClear() is equivalent to calling
3103 * xTaskNotifyStateClearIndexed() with the uxIndexToNotify parameter set to 0.
3105 * @param xTask The handle of the RTOS task that will have a notification state
3106 * cleared. Set xTask to NULL to clear a notification state in the calling
3107 * task. To obtain a task's handle create the task using xTaskCreate() and
3108 * make use of the pxCreatedTask parameter, or create the task using
3109 * xTaskCreateStatic() and store the returned value, or use the task's name in
3110 * a call to xTaskGetHandle().
3112 * @param uxIndexToClear The index within the target task's array of
3113 * notification values to act upon. For example, setting uxIndexToClear to 1
3114 * will clear the state of the notification at index 1 within the array.
3115 * uxIndexToClear must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
3116 * ulTaskNotifyStateClear() does not have this parameter and always acts on the
3117 * notification at index 0.
3119 * @return pdTRUE if the task's notification state was set to
3120 * eNotWaitingNotification, otherwise pdFALSE.
3122 * \defgroup xTaskNotifyStateClearIndexed xTaskNotifyStateClearIndexed
3123 * \ingroup TaskNotifications
3125 BaseType_t xTaskGenericNotifyStateClear( TaskHandle_t xTask,
3126 UBaseType_t uxIndexToClear ) PRIVILEGED_FUNCTION;
3127 #define xTaskNotifyStateClear( xTask ) \
3128 xTaskGenericNotifyStateClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ) )
3129 #define xTaskNotifyStateClearIndexed( xTask, uxIndexToClear ) \
3130 xTaskGenericNotifyStateClear( ( xTask ), ( uxIndexToClear ) )
3135 * uint32_t ulTaskNotifyValueClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear );
3137 * uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear );
3140 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
3142 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
3143 * functions to be available.
3145 * Each task has a private array of "notification values" (or 'notifications'),
3146 * each of which is a 32-bit unsigned integer (uint32_t). The constant
3147 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
3148 * array, and (for backward compatibility) defaults to 1 if left undefined.
3149 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
3151 * ulTaskNotifyValueClearIndexed() clears the bits specified by the
3152 * ulBitsToClear bit mask in the notification value at array index uxIndexToClear
3153 * of the task referenced by xTask.
3155 * Backward compatibility information:
3156 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
3157 * all task notification API functions operated on that value. Replacing the
3158 * single notification value with an array of notification values necessitated a
3159 * new set of API functions that could address specific notifications within the
3160 * array. ulTaskNotifyValueClear() is the original API function, and remains
3161 * backward compatible by always operating on the notification value at index 0
3162 * within the array. Calling ulTaskNotifyValueClear() is equivalent to calling
3163 * ulTaskNotifyValueClearIndexed() with the uxIndexToClear parameter set to 0.
3165 * @param xTask The handle of the RTOS task that will have bits in one of its
3166 * notification values cleared. Set xTask to NULL to clear bits in a
3167 * notification value of the calling task. To obtain a task's handle create the
3168 * task using xTaskCreate() and make use of the pxCreatedTask parameter, or
3169 * create the task using xTaskCreateStatic() and store the returned value, or
3170 * use the task's name in a call to xTaskGetHandle().
3172 * @param uxIndexToClear The index within the target task's array of
3173 * notification values in which to clear the bits. uxIndexToClear
3174 * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
3175 * ulTaskNotifyValueClear() does not have this parameter and always clears bits
3176 * in the notification value at index 0.
3178 * @param ulBitsToClear Bit mask of the bits to clear in the notification value of
3179 * xTask. Set a bit to 1 to clear the corresponding bits in the task's notification
3180 * value. Set ulBitsToClear to 0xffffffff (UINT_MAX on 32-bit architectures) to clear
3181 * the notification value to 0. Set ulBitsToClear to 0 to query the task's
3182 * notification value without clearing any bits.
3185 * @return The value of the target task's notification value before the bits
3186 * specified by ulBitsToClear were cleared.
3187 * \defgroup ulTaskNotifyValueClear ulTaskNotifyValueClear
3188 * \ingroup TaskNotifications
3190 uint32_t ulTaskGenericNotifyValueClear( TaskHandle_t xTask,
3191 UBaseType_t uxIndexToClear,
3192 uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
3193 #define ulTaskNotifyValueClear( xTask, ulBitsToClear ) \
3194 ulTaskGenericNotifyValueClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulBitsToClear ) )
3195 #define ulTaskNotifyValueClearIndexed( xTask, uxIndexToClear, ulBitsToClear ) \
3196 ulTaskGenericNotifyValueClear( ( xTask ), ( uxIndexToClear ), ( ulBitsToClear ) )
3201 * void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut );
3204 * Capture the current time for future use with xTaskCheckForTimeOut().
3206 * @param pxTimeOut Pointer to a timeout object into which the current time
3207 * is to be captured. The captured time includes the tick count and the number
3208 * of times the tick count has overflowed since the system first booted.
3209 * \defgroup vTaskSetTimeOutState vTaskSetTimeOutState
3212 void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
3217 * BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait );
3220 * Determines if pxTicksToWait ticks has passed since a time was captured
3221 * using a call to vTaskSetTimeOutState(). The captured time includes the tick
3222 * count and the number of times the tick count has overflowed.
3224 * @param pxTimeOut The time status as captured previously using
3225 * vTaskSetTimeOutState. If the timeout has not yet occurred, it is updated
3226 * to reflect the current time status.
3227 * @param pxTicksToWait The number of ticks to check for timeout i.e. if
3228 * pxTicksToWait ticks have passed since pxTimeOut was last updated (either by
3229 * vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred.
3230 * If the timeout has not occurred, pxTicksToWait is updated to reflect the
3231 * number of remaining ticks.
3233 * @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is
3234 * returned and pxTicksToWait is updated to reflect the number of remaining
3237 * @see https://www.FreeRTOS.org/xTaskCheckForTimeOut.html
3241 * // Driver library function used to receive uxWantedBytes from an Rx buffer
3242 * // that is filled by a UART interrupt. If there are not enough bytes in the
3243 * // Rx buffer then the task enters the Blocked state until it is notified that
3244 * // more data has been placed into the buffer. If there is still not enough
3245 * // data then the task re-enters the Blocked state, and xTaskCheckForTimeOut()
3246 * // is used to re-calculate the Block time to ensure the total amount of time
3247 * // spent in the Blocked state does not exceed MAX_TIME_TO_WAIT. This
3248 * // continues until either the buffer contains at least uxWantedBytes bytes,
3249 * // or the total amount of time spent in the Blocked state reaches
3250 * // MAX_TIME_TO_WAIT - at which point the task reads however many bytes are
3251 * // available up to a maximum of uxWantedBytes.
3253 * size_t xUART_Receive( uint8_t *pucBuffer, size_t uxWantedBytes )
3255 * size_t uxReceived = 0;
3256 * TickType_t xTicksToWait = MAX_TIME_TO_WAIT;
3257 * TimeOut_t xTimeOut;
3259 * // Initialize xTimeOut. This records the time at which this function
3261 * vTaskSetTimeOutState( &xTimeOut );
3263 * // Loop until the buffer contains the wanted number of bytes, or a
3264 * // timeout occurs.
3265 * while( UART_bytes_in_rx_buffer( pxUARTInstance ) < uxWantedBytes )
3267 * // The buffer didn't contain enough data so this task is going to
3268 * // enter the Blocked state. Adjusting xTicksToWait to account for
3269 * // any time that has been spent in the Blocked state within this
3270 * // function so far to ensure the total amount of time spent in the
3271 * // Blocked state does not exceed MAX_TIME_TO_WAIT.
3272 * if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) != pdFALSE )
3274 * //Timed out before the wanted number of bytes were available,
3279 * // Wait for a maximum of xTicksToWait ticks to be notified that the
3280 * // receive interrupt has placed more data into the buffer.
3281 * ulTaskNotifyTake( pdTRUE, xTicksToWait );
3284 * // Attempt to read uxWantedBytes from the receive buffer into pucBuffer.
3285 * // The actual number of bytes read (which might be less than
3286 * // uxWantedBytes) is returned.
3287 * uxReceived = UART_read_from_receive_buffer( pxUARTInstance,
3291 * return uxReceived;
3294 * \defgroup xTaskCheckForTimeOut xTaskCheckForTimeOut
3297 BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut,
3298 TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;
3303 * BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp );
3306 * This function corrects the tick count value after the application code has held
3307 * interrupts disabled for an extended period resulting in tick interrupts having
3310 * This function is similar to vTaskStepTick(), however, unlike
3311 * vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a
3312 * time at which a task should be removed from the blocked state. That means
3313 * tasks may have to be removed from the blocked state as the tick count is
3316 * @param xTicksToCatchUp The number of tick interrupts that have been missed due to
3317 * interrupts being disabled. Its value is not computed automatically, so must be
3318 * computed by the application writer.
3320 * @return pdTRUE if moving the tick count forward resulted in a task leaving the
3321 * blocked state and a context switch being performed. Otherwise pdFALSE.
3323 * \defgroup xTaskCatchUpTicks xTaskCatchUpTicks
3326 BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION;
3329 /*-----------------------------------------------------------
3330 * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
3331 *----------------------------------------------------------*/
3333 #if ( configNUMBER_OF_CORES == 1 )
3334 #define taskYIELD_WITHIN_API() portYIELD_WITHIN_API()
3335 #else /* #if ( configNUMBER_OF_CORES == 1 ) */
3336 #define taskYIELD_WITHIN_API() vTaskYieldWithinAPI()
3337 #endif /* #if ( configNUMBER_OF_CORES == 1 ) */
3340 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
3341 * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
3342 * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
3344 * Called from the real time kernel tick (either preemptive or cooperative),
3345 * this increments the tick count and checks if any tasks that are blocked
3346 * for a finite period required removing from a blocked list and placing on
3347 * a ready list. If a non-zero value is returned then a context switch is
3348 * required because either:
3349 * + A task was removed from a blocked list because its timeout had expired,
3351 * + Time slicing is in use and there is a task of equal priority to the
3352 * currently running task.
3354 BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;
3357 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
3358 * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
3360 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
3362 * Removes the calling task from the ready list and places it both
3363 * on the list of tasks waiting for a particular event, and the
3364 * list of delayed tasks. The task will be removed from both lists
3365 * and replaced on the ready list should either the event occur (and
3366 * there be no higher priority tasks waiting on the same event) or
3367 * the delay period expires.
3369 * The 'unordered' version replaces the event list item value with the
3370 * xItemValue value, and inserts the list item at the end of the list.
3372 * The 'ordered' version uses the existing event list item value (which is the
3373 * owning task's priority) to insert the list item into the event list in task
3376 * @param pxEventList The list containing tasks that are blocked waiting
3377 * for the event to occur.
3379 * @param xItemValue The item value to use for the event list item when the
3380 * event list is not ordered by task priority.
3382 * @param xTicksToWait The maximum amount of time that the task should wait
3383 * for the event to occur. This is specified in kernel ticks, the constant
3384 * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time
3387 void vTaskPlaceOnEventList( List_t * const pxEventList,
3388 const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
3389 void vTaskPlaceOnUnorderedEventList( List_t * pxEventList,
3390 const TickType_t xItemValue,
3391 const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
3394 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
3395 * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
3397 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
3399 * This function performs nearly the same function as vTaskPlaceOnEventList().
3400 * The difference being that this function does not permit tasks to block
3401 * indefinitely, whereas vTaskPlaceOnEventList() does.
3404 void vTaskPlaceOnEventListRestricted( List_t * const pxEventList,
3405 TickType_t xTicksToWait,
3406 const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;
3409 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
3410 * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
3412 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
3414 * Removes a task from both the specified event list and the list of blocked
3415 * tasks, and places it on a ready queue.
3417 * xTaskRemoveFromEventList()/vTaskRemoveFromUnorderedEventList() will be called
3418 * if either an event occurs to unblock a task, or the block timeout period
3421 * xTaskRemoveFromEventList() is used when the event list is in task priority
3422 * order. It removes the list item from the head of the event list as that will
3423 * have the highest priority owning task of all the tasks on the event list.
3424 * vTaskRemoveFromUnorderedEventList() is used when the event list is not
3425 * ordered and the event list items hold something other than the owning tasks
3426 * priority. In this case the event list item value is updated to the value
3427 * passed in the xItemValue parameter.
3429 * @return pdTRUE if the task being removed has a higher priority than the task
3430 * making the call, otherwise pdFALSE.
3432 BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION;
3433 void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem,
3434 const TickType_t xItemValue ) PRIVILEGED_FUNCTION;
3437 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
3438 * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
3439 * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
3441 * Sets the pointer to the current TCB to the TCB of the highest priority task
3442 * that is ready to run.
3444 #if ( configNUMBER_OF_CORES == 1 )
3445 portDONT_DISCARD void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;
3447 portDONT_DISCARD void vTaskSwitchContext( BaseType_t xCoreID ) PRIVILEGED_FUNCTION;
3451 * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY
3452 * THE EVENT BITS MODULE.
3454 TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION;
3457 * Return the handle of the calling task.
3459 TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;
3462 * Return the handle of the task running on specified core.
3464 TaskHandle_t xTaskGetCurrentTaskHandleCPU( BaseType_t xCoreID ) PRIVILEGED_FUNCTION;
3467 * Shortcut used by the queue implementation to prevent unnecessary call to
3470 void vTaskMissedYield( void ) PRIVILEGED_FUNCTION;
3473 * Returns the scheduler state as taskSCHEDULER_RUNNING,
3474 * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.
3476 BaseType_t xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION;
3479 * Raises the priority of the mutex holder to that of the calling task should
3480 * the mutex holder have a priority less than the calling task.
3482 BaseType_t xTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
3485 * Set the priority of a task back to its proper priority in the case that it
3486 * inherited a higher priority while it was holding a semaphore.
3488 BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
3491 * If a higher priority task attempting to obtain a mutex caused a lower
3492 * priority task to inherit the higher priority task's priority - but the higher
3493 * priority task then timed out without obtaining the mutex, then the lower
3494 * priority task will disinherit the priority again - but only down as far as
3495 * the highest priority task that is still waiting for the mutex (if there were
3496 * more than one task waiting for the mutex).
3498 void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder,
3499 UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION;
3502 * Get the uxTaskNumber assigned to the task referenced by the xTask parameter.
3504 UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
3507 * Set the uxTaskNumber of the task referenced by the xTask parameter to
3510 void vTaskSetTaskNumber( TaskHandle_t xTask,
3511 const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION;
3514 * Only available when configUSE_TICKLESS_IDLE is set to 1.
3515 * If tickless mode is being used, or a low power mode is implemented, then
3516 * the tick interrupt will not execute during idle periods. When this is the
3517 * case, the tick count value maintained by the scheduler needs to be kept up
3518 * to date with the actual execution time by being skipped forward by a time
3519 * equal to the idle period.
3521 void vTaskStepTick( TickType_t xTicksToJump ) PRIVILEGED_FUNCTION;
3524 * Only available when configUSE_TICKLESS_IDLE is set to 1.
3525 * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port
3526 * specific sleep function to determine if it is ok to proceed with the sleep,
3527 * and if it is ok to proceed, if it is ok to sleep indefinitely.
3529 * This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only
3530 * called with the scheduler suspended, not from within a critical section. It
3531 * is therefore possible for an interrupt to request a context switch between
3532 * portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being
3533 * entered. eTaskConfirmSleepModeStatus() should be called from a short
3534 * critical section between the timer being stopped and the sleep mode being
3535 * entered to ensure it is ok to proceed into the sleep mode.
3537 eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;
3540 * For internal use only. Increment the mutex held count when a mutex is
3541 * taken and return the handle of the task that has taken the mutex.
3543 TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;
3546 * For internal use only. Same as vTaskSetTimeOutState(), but without a critical
3549 void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
3552 * For internal use only. Same as portYIELD_WITHIN_API() in single core FreeRTOS.
3553 * For SMP this is not defined by the port.
3555 void vTaskYieldWithinAPI( void );
3558 * This function is only intended for use when implementing a port of the scheduler
3559 * and is only available when portCRITICAL_NESTING_IN_TCB is set to 1 or configNUMBER_OF_CORES
3560 * is greater than 1. This function can be used in the implementation of portENTER_CRITICAL
3561 * if port wants to maintain critical nesting count in TCB in single core FreeRTOS.
3562 * It should be used in the implementation of portENTER_CRITICAL if port is running a
3563 * multiple core FreeRTOS.
3565 void vTaskEnterCritical( void );
3568 * This function is only intended for use when implementing a port of the scheduler
3569 * and is only available when portCRITICAL_NESTING_IN_TCB is set to 1 or configNUMBER_OF_CORES
3570 * is greater than 1. This function can be used in the implementation of portEXIT_CRITICAL
3571 * if port wants to maintain critical nesting count in TCB in single core FreeRTOS.
3572 * It should be used in the implementation of portEXIT_CRITICAL if port is running a
3573 * multiple core FreeRTOS.
3575 void vTaskExitCritical( void );
3578 * This function is only intended for use when implementing a port of the scheduler
3579 * and is only available when configNUMBER_OF_CORES is greater than 1. This function
3580 * should be used in the implementation of portENTER_CRITICAL_FROM_ISR if port is
3581 * running a multiple core FreeRTOS.
3583 UBaseType_t vTaskEnterCriticalFromISR( void );
3586 * This function is only intended for use when implementing a port of the scheduler
3587 * and is only available when configNUMBER_OF_CORES is greater than 1. This function
3588 * should be used in the implementation of portEXIT_CRITICAL_FROM_ISR if port is
3589 * running a multiple core FreeRTOS.
3591 void vTaskExitCriticalFromISR( UBaseType_t uxSavedInterruptStatus );
3593 #if ( portUSING_MPU_WRAPPERS == 1 )
3596 * For internal use only. Get MPU settings associated with a task.
3598 xMPU_SETTINGS * xTaskGetMPUSettings( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
3600 #endif /* portUSING_MPU_WRAPPERS */
3603 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) && ( configENABLE_ACCESS_CONTROL_LIST == 1 ) )
3606 * For internal use only. Grant/Revoke a task's access to a kernel object.
3608 void vGrantAccessToKernelObject( TaskHandle_t xExternalTaskHandle,
3609 int32_t lExternalKernelObjectHandle ) PRIVILEGED_FUNCTION;
3610 void vRevokeAccessToKernelObject( TaskHandle_t xExternalTaskHandle,
3611 int32_t lExternalKernelObjectHandle ) PRIVILEGED_FUNCTION;
3614 * For internal use only. Grant/Revoke a task's access to a kernel object.
3616 void vPortGrantAccessToKernelObject( TaskHandle_t xInternalTaskHandle,
3617 int32_t lInternalIndexOfKernelObject ) PRIVILEGED_FUNCTION;
3618 void vPortRevokeAccessToKernelObject( TaskHandle_t xInternalTaskHandle,
3619 int32_t lInternalIndexOfKernelObject ) PRIVILEGED_FUNCTION;
3621 #endif /* #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) && ( configENABLE_ACCESS_CONTROL_LIST == 1 ) ) */
3628 #endif /* INC_TASK_H */