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 "V11.1.0+"
57 #define tskKERNEL_VERSION_MAJOR 11
58 #define tskKERNEL_VERSION_MINOR 1
59 #define tskKERNEL_VERSION_BUILD 0
61 /* MPU region parameters passed in ulParameters
62 * of MemoryRegion_t struct. */
63 #define tskMPU_REGION_READ_ONLY ( 1U << 0U )
64 #define tskMPU_REGION_READ_WRITE ( 1U << 1U )
65 #define tskMPU_REGION_EXECUTE_NEVER ( 1U << 2U )
66 #define tskMPU_REGION_NORMAL_MEMORY ( 1U << 3U )
67 #define tskMPU_REGION_DEVICE_MEMORY ( 1U << 4U )
68 #if defined( portARMV8M_MINOR_VERSION ) && ( portARMV8M_MINOR_VERSION >= 1 )
69 #define tskMPU_REGION_PRIVILEGED_EXECUTE_NEVER ( 1U << 5U )
70 #endif /* portARMV8M_MINOR_VERSION >= 1 */
72 /* MPU region permissions stored in MPU settings to
73 * authorize access requests. */
74 #define tskMPU_READ_PERMISSION ( 1U << 0U )
75 #define tskMPU_WRITE_PERMISSION ( 1U << 1U )
77 /* The direct to task notification feature used to have only a single notification
78 * per task. Now there is an array of notifications per task that is dimensioned by
79 * configTASK_NOTIFICATION_ARRAY_ENTRIES. For backward compatibility, any use of the
80 * original direct to task notification defaults to using the first index in the
82 #define tskDEFAULT_INDEX_TO_NOTIFY ( 0 )
87 * Type by which tasks are referenced. For example, a call to xTaskCreate
88 * returns (via a pointer parameter) an TaskHandle_t variable that can then
89 * be used as a parameter to vTaskDelete to delete the task.
91 * \defgroup TaskHandle_t TaskHandle_t
94 struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */
95 typedef struct tskTaskControlBlock * TaskHandle_t;
96 typedef const struct tskTaskControlBlock * ConstTaskHandle_t;
99 * Defines the prototype to which the application task hook function must
102 typedef BaseType_t (* TaskHookFunction_t)( void * arg );
104 /* Task states returned by eTaskGetState. */
107 eRunning = 0, /* A task is querying the state of itself, so must be running. */
108 eReady, /* The task being queried is in a ready or pending ready list. */
109 eBlocked, /* The task being queried is in the Blocked state. */
110 eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */
111 eDeleted, /* The task being queried has been deleted, but its TCB has not yet been freed. */
112 eInvalid /* Used as an 'invalid state' value. */
115 /* Actions that can be performed when vTaskNotify() is called. */
118 eNoAction = 0, /* Notify the task without updating its notify value. */
119 eSetBits, /* Set bits in the task's notification value. */
120 eIncrement, /* Increment the task's notification value. */
121 eSetValueWithOverwrite, /* Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */
122 eSetValueWithoutOverwrite /* Set the task's notification value if the previous value has been read by the task. */
126 * Used internally only.
128 typedef struct xTIME_OUT
130 BaseType_t xOverflowCount;
131 TickType_t xTimeOnEntering;
135 * Defines the memory ranges allocated to the task when an MPU is used.
137 typedef struct xMEMORY_REGION
139 void * pvBaseAddress;
140 uint32_t ulLengthInBytes;
141 uint32_t ulParameters;
145 * Parameters required to create an MPU protected task.
147 typedef struct xTASK_PARAMETERS
149 TaskFunction_t pvTaskCode;
151 configSTACK_DEPTH_TYPE usStackDepth;
153 UBaseType_t uxPriority;
154 StackType_t * puxStackBuffer;
155 MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ];
156 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
157 StaticTask_t * const pxTaskBuffer;
161 /* Used with the uxTaskGetSystemState() function to return the state of each task
163 typedef struct xTASK_STATUS
165 TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */
166 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! */
167 UBaseType_t xTaskNumber; /* A number unique to the task. Note that this is not the task number that may be modified using vTaskSetTaskNumber() and uxTaskGetTaskNumber(), but a separate TCB-specific and unique identifier automatically assigned on task generation. */
168 eTaskState eCurrentState; /* The state in which the task existed when the structure was populated. */
169 UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */
170 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. */
171 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. */
172 StackType_t * pxStackBase; /* Points to the lowest address of the task's stack area. */
173 #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )
174 StackType_t * pxTopOfStack; /* Points to the top address of the task's stack area. */
175 StackType_t * pxEndOfStack; /* Points to the end address of the task's stack area. */
177 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. */
178 #if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
179 UBaseType_t uxCoreAffinityMask; /* The core affinity mask for the task */
183 /* Possible return values for eTaskConfirmSleepModeStatus(). */
186 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. */
187 eStandardSleep /* Enter a sleep mode that will not last any longer than the expected idle time. */
188 #if ( INCLUDE_vTaskSuspend == 1 )
190 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. */
191 #endif /* INCLUDE_vTaskSuspend */
195 * Defines the priority used by the idle task. This must not be modified.
199 #define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U )
202 * Defines affinity to all available cores.
206 #define tskNO_AFFINITY ( ( UBaseType_t ) -1 )
211 * Macro for forcing a context switch.
213 * \defgroup taskYIELD taskYIELD
214 * \ingroup SchedulerControl
216 #define taskYIELD() portYIELD()
221 * Macro to mark the start of a critical code region. Preemptive context
222 * switches cannot occur when in a critical region.
224 * NOTE: This may alter the stack (depending on the portable implementation)
225 * so must be used with care!
227 * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL
228 * \ingroup SchedulerControl
230 #define taskENTER_CRITICAL() portENTER_CRITICAL()
231 #if ( configNUMBER_OF_CORES == 1 )
232 #define taskENTER_CRITICAL_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()
234 #define taskENTER_CRITICAL_FROM_ISR() portENTER_CRITICAL_FROM_ISR()
240 * Macro to mark the end of a critical code region. Preemptive context
241 * switches cannot occur when in a critical region.
243 * NOTE: This may alter the stack (depending on the portable implementation)
244 * so must be used with care!
246 * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL
247 * \ingroup SchedulerControl
249 #define taskEXIT_CRITICAL() portEXIT_CRITICAL()
250 #if ( configNUMBER_OF_CORES == 1 )
251 #define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x )
253 #define taskEXIT_CRITICAL_FROM_ISR( x ) portEXIT_CRITICAL_FROM_ISR( x )
259 * Macro to disable all maskable interrupts.
261 * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS
262 * \ingroup SchedulerControl
264 #define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS()
269 * Macro to enable microcontroller interrupts.
271 * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS
272 * \ingroup SchedulerControl
274 #define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS()
276 /* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is
277 * 0 to generate more optimal code when configASSERT() is defined as the constant
278 * is used in assert() statements. */
279 #define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 )
280 #define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 )
281 #define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 )
283 /* Checks if core ID is valid. */
284 #define taskVALID_CORE_ID( xCoreID ) ( ( ( ( ( BaseType_t ) 0 <= ( xCoreID ) ) && ( ( xCoreID ) < ( BaseType_t ) configNUMBER_OF_CORES ) ) ) ? ( pdTRUE ) : ( pdFALSE ) )
286 /*-----------------------------------------------------------
288 *----------------------------------------------------------*/
293 * BaseType_t xTaskCreate(
294 * TaskFunction_t pxTaskCode,
295 * const char * const pcName,
296 * const configSTACK_DEPTH_TYPE uxStackDepth,
297 * void *pvParameters,
298 * UBaseType_t uxPriority,
299 * TaskHandle_t *pxCreatedTask
303 * Create a new task and add it to the list of tasks that are ready to run.
305 * Internally, within the FreeRTOS implementation, tasks use two blocks of
306 * memory. The first block is used to hold the task's data structures. The
307 * second block is used by the task as its stack. If a task is created using
308 * xTaskCreate() then both blocks of memory are automatically dynamically
309 * allocated inside the xTaskCreate() function. (see
310 * https://www.FreeRTOS.org/a00111.html). If a task is created using
311 * xTaskCreateStatic() then the application writer must provide the required
312 * memory. xTaskCreateStatic() therefore allows a task to be created without
313 * using any dynamic memory allocation.
315 * See xTaskCreateStatic() for a version that does not use any dynamic memory
318 * xTaskCreate() can only be used to create a task that has unrestricted
319 * access to the entire microcontroller memory map. Systems that include MPU
320 * support can alternatively create an MPU constrained task using
321 * xTaskCreateRestricted().
323 * @param pxTaskCode Pointer to the task entry function. Tasks
324 * must be implemented to never return (i.e. continuous loop).
326 * @param pcName A descriptive name for the task. This is mainly used to
327 * facilitate debugging. Max length defined by configMAX_TASK_NAME_LEN - default
330 * @param uxStackDepth The size of the task stack specified as the number of
331 * variables the stack can hold - not the number of bytes. For example, if
332 * the stack is 16 bits wide and uxStackDepth is defined as 100, 200 bytes
333 * will be allocated for stack storage.
335 * @param pvParameters Pointer that will be used as the parameter for the task
338 * @param uxPriority The priority at which the task should run. Systems that
339 * include MPU support can optionally create tasks in a privileged (system)
340 * mode by setting bit portPRIVILEGE_BIT of the priority parameter. For
341 * example, to create a privileged task at priority 2 the uxPriority parameter
342 * should be set to ( 2 | portPRIVILEGE_BIT ).
344 * @param pxCreatedTask Used to pass back a handle by which the created task
347 * @return pdPASS if the task was successfully created and added to a ready
348 * list, otherwise an error code defined in the file projdefs.h
352 * // Task to be created.
353 * void vTaskCode( void * pvParameters )
357 * // Task code goes here.
361 * // Function that creates a task.
362 * void vOtherFunction( void )
364 * static uint8_t ucParameterToPass;
365 * TaskHandle_t xHandle = NULL;
367 * // Create the task, storing the handle. Note that the passed parameter ucParameterToPass
368 * // must exist for the lifetime of the task, so in this case is declared static. If it was just an
369 * // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time
370 * // the new task attempts to access it.
371 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
372 * configASSERT( xHandle );
374 * // Use the handle to delete the task.
375 * if( xHandle != NULL )
377 * vTaskDelete( xHandle );
381 * \defgroup xTaskCreate xTaskCreate
384 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
385 BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
386 const char * const pcName,
387 const configSTACK_DEPTH_TYPE uxStackDepth,
388 void * const pvParameters,
389 UBaseType_t uxPriority,
390 TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
393 #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
394 BaseType_t xTaskCreateAffinitySet( TaskFunction_t pxTaskCode,
395 const char * const pcName,
396 const configSTACK_DEPTH_TYPE uxStackDepth,
397 void * const pvParameters,
398 UBaseType_t uxPriority,
399 UBaseType_t uxCoreAffinityMask,
400 TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
406 * TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
407 * const char * const pcName,
408 * const configSTACK_DEPTH_TYPE uxStackDepth,
409 * void *pvParameters,
410 * UBaseType_t uxPriority,
411 * StackType_t *puxStackBuffer,
412 * StaticTask_t *pxTaskBuffer );
415 * Create a new task and add it to the list of tasks that are ready to run.
417 * Internally, within the FreeRTOS implementation, tasks use two blocks of
418 * memory. The first block is used to hold the task's data structures. The
419 * second block is used by the task as its stack. If a task is created using
420 * xTaskCreate() then both blocks of memory are automatically dynamically
421 * allocated inside the xTaskCreate() function. (see
422 * https://www.FreeRTOS.org/a00111.html). If a task is created using
423 * xTaskCreateStatic() then the application writer must provide the required
424 * memory. xTaskCreateStatic() therefore allows a task to be created without
425 * using any dynamic memory allocation.
427 * @param pxTaskCode Pointer to the task entry function. Tasks
428 * must be implemented to never return (i.e. continuous loop).
430 * @param pcName A descriptive name for the task. This is mainly used to
431 * facilitate debugging. The maximum length of the string is defined by
432 * configMAX_TASK_NAME_LEN in FreeRTOSConfig.h.
434 * @param uxStackDepth The size of the task stack specified as the number of
435 * variables the stack can hold - not the number of bytes. For example, if
436 * the stack is 32-bits wide and uxStackDepth is defined as 100 then 400 bytes
437 * will be allocated for stack storage.
439 * @param pvParameters Pointer that will be used as the parameter for the task
442 * @param uxPriority The priority at which the task will run.
444 * @param puxStackBuffer Must point to a StackType_t array that has at least
445 * uxStackDepth indexes - the array will then be used as the task's stack,
446 * removing the need for the stack to be allocated dynamically.
448 * @param pxTaskBuffer Must point to a variable of type StaticTask_t, which will
449 * then be used to hold the task's data structures, removing the need for the
450 * memory to be allocated dynamically.
452 * @return If neither puxStackBuffer nor pxTaskBuffer are NULL, then the task
453 * will be created and a handle to the created task is returned. If either
454 * puxStackBuffer or pxTaskBuffer are NULL then the task will not be created and
460 * // Dimensions of the buffer that the task being created will use as its stack.
461 * // NOTE: This is the number of words the stack will hold, not the number of
462 * // bytes. For example, if each stack item is 32-bits, and this is set to 100,
463 * // then 400 bytes (100 * 32-bits) will be allocated.
464 #define STACK_SIZE 200
466 * // Structure that will hold the TCB of the task being created.
467 * StaticTask_t xTaskBuffer;
469 * // Buffer that the task being created will use as its stack. Note this is
470 * // an array of StackType_t variables. The size of StackType_t is dependent on
472 * StackType_t xStack[ STACK_SIZE ];
474 * // Function that implements the task being created.
475 * void vTaskCode( void * pvParameters )
477 * // The parameter value is expected to be 1 as 1 is passed in the
478 * // pvParameters value in the call to xTaskCreateStatic().
479 * configASSERT( ( uint32_t ) pvParameters == 1U );
483 * // Task code goes here.
487 * // Function that creates a task.
488 * void vOtherFunction( void )
490 * TaskHandle_t xHandle = NULL;
492 * // Create the task without using any dynamic memory allocation.
493 * xHandle = xTaskCreateStatic(
494 * vTaskCode, // Function that implements the task.
495 * "NAME", // Text name for the task.
496 * STACK_SIZE, // Stack size in words, not bytes.
497 * ( void * ) 1, // Parameter passed into the task.
498 * tskIDLE_PRIORITY,// Priority at which the task is created.
499 * xStack, // Array to use as the task's stack.
500 * &xTaskBuffer ); // Variable to hold the task's data structure.
502 * // puxStackBuffer and pxTaskBuffer were not NULL, so the task will have
503 * // been created, and xHandle will be the task's handle. Use the handle
504 * // to suspend the task.
505 * vTaskSuspend( xHandle );
508 * \defgroup xTaskCreateStatic xTaskCreateStatic
511 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
512 TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
513 const char * const pcName,
514 const configSTACK_DEPTH_TYPE uxStackDepth,
515 void * const pvParameters,
516 UBaseType_t uxPriority,
517 StackType_t * const puxStackBuffer,
518 StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION;
519 #endif /* configSUPPORT_STATIC_ALLOCATION */
521 #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
522 TaskHandle_t xTaskCreateStaticAffinitySet( TaskFunction_t pxTaskCode,
523 const char * const pcName,
524 const configSTACK_DEPTH_TYPE uxStackDepth,
525 void * const pvParameters,
526 UBaseType_t uxPriority,
527 StackType_t * const puxStackBuffer,
528 StaticTask_t * const pxTaskBuffer,
529 UBaseType_t uxCoreAffinityMask ) PRIVILEGED_FUNCTION;
535 * BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
538 * Only available when configSUPPORT_DYNAMIC_ALLOCATION is set to 1.
540 * xTaskCreateRestricted() should only be used in systems that include an MPU
543 * Create a new task and add it to the list of tasks that are ready to run.
544 * The function parameters define the memory regions and associated access
545 * permissions allocated to the task.
547 * See xTaskCreateRestrictedStatic() for a version that does not use any
548 * dynamic memory allocation.
550 * @param pxTaskDefinition Pointer to a structure that contains a member
551 * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
552 * documentation) plus an optional stack buffer and the memory region
555 * @param pxCreatedTask Used to pass back a handle by which the created task
558 * @return pdPASS if the task was successfully created and added to a ready
559 * list, otherwise an error code defined in the file projdefs.h
563 * // Create an TaskParameters_t structure that defines the task to be created.
564 * static const TaskParameters_t xCheckTaskParameters =
566 * vATask, // pvTaskCode - the function that implements the task.
567 * "ATask", // pcName - just a text name for the task to assist debugging.
568 * 100, // uxStackDepth - the stack size DEFINED IN WORDS.
569 * NULL, // pvParameters - passed into the task function as the function parameters.
570 * ( 1U | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
571 * cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
573 * // xRegions - Allocate up to three separate memory regions for access by
574 * // the task, with appropriate access permissions. Different processors have
575 * // different memory alignment requirements - refer to the FreeRTOS documentation
576 * // for full information.
578 * // Base address Length Parameters
579 * { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },
580 * { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },
581 * { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }
587 * TaskHandle_t xHandle;
589 * // Create a task from the const structure defined above. The task handle
590 * // is requested (the second parameter is not NULL) but in this case just for
591 * // demonstration purposes as its not actually used.
592 * xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
594 * // Start the scheduler.
595 * vTaskStartScheduler();
597 * // Will only get here if there was insufficient memory to create the idle
598 * // and/or timer task.
602 * \defgroup xTaskCreateRestricted xTaskCreateRestricted
605 #if ( portUSING_MPU_WRAPPERS == 1 )
606 BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition,
607 TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
610 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
611 BaseType_t xTaskCreateRestrictedAffinitySet( const TaskParameters_t * const pxTaskDefinition,
612 UBaseType_t uxCoreAffinityMask,
613 TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
619 * BaseType_t xTaskCreateRestrictedStatic( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
622 * Only available when configSUPPORT_STATIC_ALLOCATION is set to 1.
624 * xTaskCreateRestrictedStatic() should only be used in systems that include an
625 * MPU implementation.
627 * Internally, within the FreeRTOS implementation, tasks use two blocks of
628 * memory. The first block is used to hold the task's data structures. The
629 * second block is used by the task as its stack. If a task is created using
630 * xTaskCreateRestricted() then the stack is provided by the application writer,
631 * and the memory used to hold the task's data structure is automatically
632 * dynamically allocated inside the xTaskCreateRestricted() function. If a task
633 * is created using xTaskCreateRestrictedStatic() then the application writer
634 * must provide the memory used to hold the task's data structures too.
635 * xTaskCreateRestrictedStatic() therefore allows a memory protected task to be
636 * created without using any dynamic memory allocation.
638 * @param pxTaskDefinition Pointer to a structure that contains a member
639 * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
640 * documentation) plus an optional stack buffer and the memory region
641 * definitions. If configSUPPORT_STATIC_ALLOCATION is set to 1 the structure
642 * contains an additional member, which is used to point to a variable of type
643 * StaticTask_t - which is then used to hold the task's data structure.
645 * @param pxCreatedTask Used to pass back a handle by which the created task
648 * @return pdPASS if the task was successfully created and added to a ready
649 * list, otherwise an error code defined in the file projdefs.h
653 * // Create an TaskParameters_t structure that defines the task to be created.
654 * // The StaticTask_t variable is only included in the structure when
655 * // configSUPPORT_STATIC_ALLOCATION is set to 1. The PRIVILEGED_DATA macro can
656 * // be used to force the variable into the RTOS kernel's privileged data area.
657 * static PRIVILEGED_DATA StaticTask_t xTaskBuffer;
658 * static const TaskParameters_t xCheckTaskParameters =
660 * vATask, // pvTaskCode - the function that implements the task.
661 * "ATask", // pcName - just a text name for the task to assist debugging.
662 * 100, // uxStackDepth - the stack size DEFINED IN WORDS.
663 * NULL, // pvParameters - passed into the task function as the function parameters.
664 * ( 1U | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
665 * cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
667 * // xRegions - Allocate up to three separate memory regions for access by
668 * // the task, with appropriate access permissions. Different processors have
669 * // different memory alignment requirements - refer to the FreeRTOS documentation
670 * // for full information.
672 * // Base address Length Parameters
673 * { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },
674 * { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },
675 * { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }
678 * &xTaskBuffer; // Holds the task's data structure.
683 * TaskHandle_t xHandle;
685 * // Create a task from the const structure defined above. The task handle
686 * // is requested (the second parameter is not NULL) but in this case just for
687 * // demonstration purposes as its not actually used.
688 * xTaskCreateRestrictedStatic( &xRegTest1Parameters, &xHandle );
690 * // Start the scheduler.
691 * vTaskStartScheduler();
693 * // Will only get here if there was insufficient memory to create the idle
694 * // and/or timer task.
698 * \defgroup xTaskCreateRestrictedStatic xTaskCreateRestrictedStatic
701 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
702 BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition,
703 TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
706 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
707 BaseType_t xTaskCreateRestrictedStaticAffinitySet( const TaskParameters_t * const pxTaskDefinition,
708 UBaseType_t uxCoreAffinityMask,
709 TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
715 * void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions );
718 * Memory regions are assigned to a restricted task when the task is created by
719 * a call to xTaskCreateRestricted(). These regions can be redefined using
720 * vTaskAllocateMPURegions().
722 * @param xTaskToModify The handle of the task being updated.
724 * @param[in] pxRegions A pointer to a MemoryRegion_t structure that contains the
725 * new memory region definitions.
729 * // Define an array of MemoryRegion_t structures that configures an MPU region
730 * // allowing read/write access for 1024 bytes starting at the beginning of the
731 * // ucOneKByte array. The other two of the maximum 3 definable regions are
732 * // unused so set to zero.
733 * static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =
735 * // Base address Length Parameters
736 * { ucOneKByte, 1024, portMPU_REGION_READ_WRITE },
741 * void vATask( void *pvParameters )
743 * // This task was created such that it has access to certain regions of
744 * // memory as defined by the MPU configuration. At some point it is
745 * // desired that these MPU regions are replaced with that defined in the
746 * // xAltRegions const struct above. Use a call to vTaskAllocateMPURegions()
747 * // for this purpose. NULL is used as the task handle to indicate that this
748 * // function should modify the MPU regions of the calling task.
749 * vTaskAllocateMPURegions( NULL, xAltRegions );
751 * // Now the task can continue its function, but from this point on can only
752 * // access its stack and the ucOneKByte array (unless any other statically
753 * // defined or shared regions have been declared elsewhere).
756 * \defgroup vTaskAllocateMPURegions vTaskAllocateMPURegions
759 #if ( portUSING_MPU_WRAPPERS == 1 )
760 void vTaskAllocateMPURegions( TaskHandle_t xTaskToModify,
761 const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION;
767 * void vTaskDelete( TaskHandle_t xTaskToDelete );
770 * INCLUDE_vTaskDelete must be defined as 1 for this function to be available.
771 * See the configuration section for more information.
773 * Remove a task from the RTOS real time kernel's management. The task being
774 * deleted will be removed from all ready, blocked, suspended and event lists.
776 * NOTE: The idle task is responsible for freeing the kernel allocated
777 * memory from tasks that have been deleted. It is therefore important that
778 * the idle task is not starved of microcontroller processing time if your
779 * application makes any calls to vTaskDelete (). Memory allocated by the
780 * task code is not automatically freed, and should be freed before the task
783 * See the demo application file death.c for sample code that utilises
786 * @param xTaskToDelete The handle of the task to be deleted. Passing NULL will
787 * cause the calling task to be deleted.
791 * void vOtherFunction( void )
793 * TaskHandle_t xHandle;
795 * // Create the task, storing the handle.
796 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
798 * // Use the handle to delete the task.
799 * vTaskDelete( xHandle );
802 * \defgroup vTaskDelete vTaskDelete
805 void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
807 /*-----------------------------------------------------------
809 *----------------------------------------------------------*/
814 * void vTaskDelay( const TickType_t xTicksToDelay );
817 * Delay a task for a given number of ticks. The actual time that the
818 * task remains blocked depends on the tick rate. The constant
819 * portTICK_PERIOD_MS can be used to calculate real time from the tick
820 * rate - with the resolution of one tick period.
822 * INCLUDE_vTaskDelay must be defined as 1 for this function to be available.
823 * See the configuration section for more information.
826 * vTaskDelay() specifies a time at which the task wishes to unblock relative to
827 * the time at which vTaskDelay() is called. For example, specifying a block
828 * period of 100 ticks will cause the task to unblock 100 ticks after
829 * vTaskDelay() is called. vTaskDelay() does not therefore provide a good method
830 * of controlling the frequency of a periodic task as the path taken through the
831 * code, as well as other task and interrupt activity, will affect the frequency
832 * at which vTaskDelay() gets called and therefore the time at which the task
833 * next executes. See xTaskDelayUntil() for an alternative API function designed
834 * to facilitate fixed frequency execution. It does this by specifying an
835 * absolute time (rather than a relative time) at which the calling task should
838 * @param xTicksToDelay The amount of time, in tick periods, that
839 * the calling task should block.
843 * void vTaskFunction( void * pvParameters )
845 * // Block for 500ms.
846 * const TickType_t xDelay = 500 / portTICK_PERIOD_MS;
850 * // Simply toggle the LED every 500ms, blocking between each toggle.
852 * vTaskDelay( xDelay );
856 * \defgroup vTaskDelay vTaskDelay
859 void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
864 * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
867 * INCLUDE_xTaskDelayUntil must be defined as 1 for this function to be available.
868 * See the configuration section for more information.
870 * Delay a task until a specified time. This function can be used by periodic
871 * tasks to ensure a constant execution frequency.
873 * This function differs from vTaskDelay () in one important aspect: vTaskDelay () will
874 * cause a task to block for the specified number of ticks from the time vTaskDelay () is
875 * called. It is therefore difficult to use vTaskDelay () by itself to generate a fixed
876 * execution frequency as the time between a task starting to execute and that task
877 * calling vTaskDelay () may not be fixed [the task may take a different path though the
878 * code between calls, or may get interrupted or preempted a different number of times
879 * each time it executes].
881 * Whereas vTaskDelay () specifies a wake time relative to the time at which the function
882 * is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to
885 * The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a
886 * time specified in milliseconds with a resolution of one tick period.
888 * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the
889 * task was last unblocked. The variable must be initialised with the current time
890 * prior to its first use (see the example below). Following this the variable is
891 * automatically updated within xTaskDelayUntil ().
893 * @param xTimeIncrement The cycle time period. The task will be unblocked at
894 * time *pxPreviousWakeTime + xTimeIncrement. Calling xTaskDelayUntil with the
895 * same xTimeIncrement parameter value will cause the task to execute with
896 * a fixed interface period.
898 * @return Value which can be used to check whether the task was actually delayed.
899 * Will be pdTRUE if the task way delayed and pdFALSE otherwise. A task will not
900 * be delayed if the next expected wake time is in the past.
904 * // Perform an action every 10 ticks.
905 * void vTaskFunction( void * pvParameters )
907 * TickType_t xLastWakeTime;
908 * const TickType_t xFrequency = 10;
909 * BaseType_t xWasDelayed;
911 * // Initialise the xLastWakeTime variable with the current time.
912 * xLastWakeTime = xTaskGetTickCount ();
915 * // Wait for the next cycle.
916 * xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency );
918 * // Perform action here. xWasDelayed value can be used to determine
919 * // whether a deadline was missed if the code here took too long.
923 * \defgroup xTaskDelayUntil xTaskDelayUntil
926 BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
927 const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
930 * vTaskDelayUntil() is the older version of xTaskDelayUntil() and does not
933 #define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ) \
935 ( void ) xTaskDelayUntil( ( pxPreviousWakeTime ), ( xTimeIncrement ) ); \
942 * BaseType_t xTaskAbortDelay( TaskHandle_t xTask );
945 * INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this
946 * function to be available.
948 * A task will enter the Blocked state when it is waiting for an event. The
949 * event it is waiting for can be a temporal event (waiting for a time), such
950 * as when vTaskDelay() is called, or an event on an object, such as when
951 * xQueueReceive() or ulTaskNotifyTake() is called. If the handle of a task
952 * that is in the Blocked state is used in a call to xTaskAbortDelay() then the
953 * task will leave the Blocked state, and return from whichever function call
954 * placed the task into the Blocked state.
956 * There is no 'FromISR' version of this function as an interrupt would need to
957 * know which object a task was blocked on in order to know which actions to
958 * take. For example, if the task was blocked on a queue the interrupt handler
959 * would then need to know if the queue was locked.
961 * @param xTask The handle of the task to remove from the Blocked state.
963 * @return If the task referenced by xTask was not in the Blocked state then
964 * pdFAIL is returned. Otherwise pdPASS is returned.
966 * \defgroup xTaskAbortDelay xTaskAbortDelay
969 #if ( INCLUDE_xTaskAbortDelay == 1 )
970 BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
976 * UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask );
979 * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available.
980 * See the configuration section for more information.
982 * Obtain the priority of any task.
984 * @param xTask Handle of the task to be queried. Passing a NULL
985 * handle results in the priority of the calling task being returned.
987 * @return The priority of xTask.
991 * void vAFunction( void )
993 * TaskHandle_t xHandle;
995 * // Create a task, storing the handle.
996 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1000 * // Use the handle to obtain the priority of the created task.
1001 * // It was created with tskIDLE_PRIORITY, but may have changed
1003 * if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
1005 * // The task has changed it's priority.
1010 * // Is our priority higher than the created task?
1011 * if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
1013 * // Our priority (obtained using NULL handle) is higher.
1017 * \defgroup uxTaskPriorityGet uxTaskPriorityGet
1020 UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1025 * UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask );
1028 * A version of uxTaskPriorityGet() that can be used from an ISR.
1030 UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1035 * UBaseType_t uxTaskBasePriorityGet( const TaskHandle_t xTask );
1038 * INCLUDE_uxTaskPriorityGet and configUSE_MUTEXES must be defined as 1 for this
1039 * function to be available. See the configuration section for more information.
1041 * Obtain the base priority of any task.
1043 * @param xTask Handle of the task to be queried. Passing a NULL
1044 * handle results in the base priority of the calling task being returned.
1046 * @return The base priority of xTask.
1048 * \defgroup uxTaskPriorityGet uxTaskBasePriorityGet
1051 UBaseType_t uxTaskBasePriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1056 * UBaseType_t uxTaskBasePriorityGetFromISR( const TaskHandle_t xTask );
1059 * A version of uxTaskBasePriorityGet() that can be used from an ISR.
1061 UBaseType_t uxTaskBasePriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1066 * eTaskState eTaskGetState( TaskHandle_t xTask );
1069 * INCLUDE_eTaskGetState must be defined as 1 for this function to be available.
1070 * See the configuration section for more information.
1072 * Obtain the state of any task. States are encoded by the eTaskState
1075 * @param xTask Handle of the task to be queried.
1077 * @return The state of xTask at the time the function was called. Note the
1078 * state of the task might change between the function being called, and the
1079 * functions return value being tested by the calling task.
1081 #if ( ( INCLUDE_eTaskGetState == 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_xTaskAbortDelay == 1 ) )
1082 eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1088 * void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState );
1091 * configUSE_TRACE_FACILITY must be defined as 1 for this function to be
1092 * available. See the configuration section for more information.
1094 * Populates a TaskStatus_t structure with information about a task.
1096 * @param xTask Handle of the task being queried. If xTask is NULL then
1097 * information will be returned about the calling task.
1099 * @param pxTaskStatus A pointer to the TaskStatus_t structure that will be
1100 * filled with information about the task referenced by the handle passed using
1101 * the xTask parameter.
1103 * @param xGetFreeStackSpace The TaskStatus_t structure contains a member to report
1104 * the stack high water mark of the task being queried. Calculating the stack
1105 * high water mark takes a relatively long time, and can make the system
1106 * temporarily unresponsive - so the xGetFreeStackSpace parameter is provided to
1107 * allow the high water mark checking to be skipped. The high watermark value
1108 * will only be written to the TaskStatus_t structure if xGetFreeStackSpace is
1109 * not set to pdFALSE;
1111 * @param eState The TaskStatus_t structure contains a member to report the
1112 * state of the task being queried. Obtaining the task state is not as fast as
1113 * a simple assignment - so the eState parameter is provided to allow the state
1114 * information to be omitted from the TaskStatus_t structure. To obtain state
1115 * information then set eState to eInvalid - otherwise the value passed in
1116 * eState will be reported as the task state in the TaskStatus_t structure.
1120 * void vAFunction( void )
1122 * TaskHandle_t xHandle;
1123 * TaskStatus_t xTaskDetails;
1125 * // Obtain the handle of a task from its name.
1126 * xHandle = xTaskGetHandle( "Task_Name" );
1128 * // Check the handle is not NULL.
1129 * configASSERT( xHandle );
1131 * // Use the handle to obtain further information about the task.
1132 * vTaskGetInfo( xHandle,
1134 * pdTRUE, // Include the high water mark in xTaskDetails.
1135 * eInvalid ); // Include the task state in xTaskDetails.
1138 * \defgroup vTaskGetInfo vTaskGetInfo
1141 #if ( configUSE_TRACE_FACILITY == 1 )
1142 void vTaskGetInfo( TaskHandle_t xTask,
1143 TaskStatus_t * pxTaskStatus,
1144 BaseType_t xGetFreeStackSpace,
1145 eTaskState eState ) PRIVILEGED_FUNCTION;
1151 * void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );
1154 * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.
1155 * See the configuration section for more information.
1157 * Set the priority of any task.
1159 * A context switch will occur before the function returns if the priority
1160 * being set is higher than the currently executing task.
1162 * @param xTask Handle to the task for which the priority is being set.
1163 * Passing a NULL handle results in the priority of the calling task being set.
1165 * @param uxNewPriority The priority to which the task will be set.
1169 * void vAFunction( void )
1171 * TaskHandle_t xHandle;
1173 * // Create a task, storing the handle.
1174 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1178 * // Use the handle to raise the priority of the created task.
1179 * vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
1183 * // Use a NULL handle to raise our priority to the same value.
1184 * vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
1187 * \defgroup vTaskPrioritySet vTaskPrioritySet
1190 void vTaskPrioritySet( TaskHandle_t xTask,
1191 UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
1196 * void vTaskSuspend( TaskHandle_t xTaskToSuspend );
1199 * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
1200 * See the configuration section for more information.
1202 * Suspend any task. When suspended a task will never get any microcontroller
1203 * processing time, no matter what its priority.
1205 * Calls to vTaskSuspend are not accumulative -
1206 * i.e. calling vTaskSuspend () twice on the same task still only requires one
1207 * call to vTaskResume () to ready the suspended task.
1209 * @param xTaskToSuspend Handle to the task being suspended. Passing a NULL
1210 * handle will cause the calling task to be suspended.
1214 * void vAFunction( void )
1216 * TaskHandle_t xHandle;
1218 * // Create a task, storing the handle.
1219 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1223 * // Use the handle to suspend the created task.
1224 * vTaskSuspend( xHandle );
1228 * // The created task will not run during this period, unless
1229 * // another task calls vTaskResume( xHandle ).
1234 * // Suspend ourselves.
1235 * vTaskSuspend( NULL );
1237 * // We cannot get here unless another task calls vTaskResume
1238 * // with our handle as the parameter.
1241 * \defgroup vTaskSuspend vTaskSuspend
1244 void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION;
1249 * void vTaskResume( TaskHandle_t xTaskToResume );
1252 * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
1253 * See the configuration section for more information.
1255 * Resumes a suspended task.
1257 * A task that has been suspended by one or more calls to vTaskSuspend ()
1258 * will be made available for running again by a single call to
1261 * @param xTaskToResume Handle to the task being readied.
1265 * void vAFunction( void )
1267 * TaskHandle_t xHandle;
1269 * // Create a task, storing the handle.
1270 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1274 * // Use the handle to suspend the created task.
1275 * vTaskSuspend( xHandle );
1279 * // The created task will not run during this period, unless
1280 * // another task calls vTaskResume( xHandle ).
1285 * // Resume the suspended task ourselves.
1286 * vTaskResume( xHandle );
1288 * // The created task will once again get microcontroller processing
1289 * // time in accordance with its priority within the system.
1292 * \defgroup vTaskResume vTaskResume
1295 void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
1300 * void xTaskResumeFromISR( TaskHandle_t xTaskToResume );
1303 * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be
1304 * available. See the configuration section for more information.
1306 * An implementation of vTaskResume() that can be called from within an ISR.
1308 * A task that has been suspended by one or more calls to vTaskSuspend ()
1309 * will be made available for running again by a single call to
1310 * xTaskResumeFromISR ().
1312 * xTaskResumeFromISR() should not be used to synchronise a task with an
1313 * interrupt if there is a chance that the interrupt could arrive prior to the
1314 * task being suspended - as this can lead to interrupts being missed. Use of a
1315 * semaphore as a synchronisation mechanism would avoid this eventuality.
1317 * @param xTaskToResume Handle to the task being readied.
1319 * @return pdTRUE if resuming the task should result in a context switch,
1320 * otherwise pdFALSE. This is used by the ISR to determine if a context switch
1321 * may be required following the ISR.
1323 * \defgroup vTaskResumeFromISR vTaskResumeFromISR
1326 BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
1328 #if ( configUSE_CORE_AFFINITY == 1 )
1331 * @brief Sets the core affinity mask for a task.
1333 * It sets the cores on which a task can run. configUSE_CORE_AFFINITY must
1334 * be defined as 1 for this function to be available.
1336 * @param xTask The handle of the task to set the core affinity mask for.
1337 * Passing NULL will set the core affinity mask for the calling task.
1339 * @param uxCoreAffinityMask A bitwise value that indicates the cores on
1340 * which the task can run. Cores are numbered from 0 to configNUMBER_OF_CORES - 1.
1341 * For example, to ensure that a task can run on core 0 and core 1, set
1342 * uxCoreAffinityMask to 0x03.
1346 * // The function that creates task.
1347 * void vAFunction( void )
1349 * TaskHandle_t xHandle;
1350 * UBaseType_t uxCoreAffinityMask;
1352 * // Create a task, storing the handle.
1353 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &( xHandle ) );
1355 * // Define the core affinity mask such that this task can only run
1356 * // on core 0 and core 2.
1357 * uxCoreAffinityMask = ( ( 1 << 0 ) | ( 1 << 2 ) );
1359 * //Set the core affinity mask for the task.
1360 * vTaskCoreAffinitySet( xHandle, uxCoreAffinityMask );
1363 void vTaskCoreAffinitySet( const TaskHandle_t xTask,
1364 UBaseType_t uxCoreAffinityMask );
1367 #if ( ( configNUMBER_OF_CORES > 1 ) && ( configUSE_CORE_AFFINITY == 1 ) )
1370 * @brief Gets the core affinity mask for a task.
1372 * configUSE_CORE_AFFINITY must be defined as 1 for this function to be
1375 * @param xTask The handle of the task to get the core affinity mask for.
1376 * Passing NULL will get the core affinity mask for the calling task.
1378 * @return The core affinity mask which is a bitwise value that indicates
1379 * the cores on which a task can run. Cores are numbered from 0 to
1380 * configNUMBER_OF_CORES - 1. For example, if a task can run on core 0 and core 1,
1381 * the core affinity mask is 0x03.
1385 * // Task handle of the networking task - it is populated elsewhere.
1386 * TaskHandle_t xNetworkingTaskHandle;
1388 * void vAFunction( void )
1390 * TaskHandle_t xHandle;
1391 * UBaseType_t uxNetworkingCoreAffinityMask;
1393 * // Create a task, storing the handle.
1394 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &( xHandle ) );
1396 * //Get the core affinity mask for the networking task.
1397 * uxNetworkingCoreAffinityMask = vTaskCoreAffinityGet( xNetworkingTaskHandle );
1399 * // Here is a hypothetical scenario, just for the example. Assume that we
1400 * // have 2 cores - Core 0 and core 1. We want to pin the application task to
1401 * // the core different than the networking task to ensure that the
1402 * // application task does not interfere with networking.
1403 * if( ( uxNetworkingCoreAffinityMask & ( 1 << 0 ) ) != 0 )
1405 * // The networking task can run on core 0, pin our task to core 1.
1406 * vTaskCoreAffinitySet( xHandle, ( 1 << 1 ) );
1410 * // Otherwise, pin our task to core 0.
1411 * vTaskCoreAffinitySet( xHandle, ( 1 << 0 ) );
1415 UBaseType_t vTaskCoreAffinityGet( ConstTaskHandle_t xTask );
1418 #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
1421 * @brief Disables preemption for a task.
1423 * @param xTask The handle of the task to disable preemption. Passing NULL
1424 * disables preemption for the calling task.
1428 * void vTaskCode( void *pvParameters )
1430 * // Silence warnings about unused parameters.
1431 * ( void ) pvParameters;
1435 * // ... Perform some function here.
1437 * // Disable preemption for this task.
1438 * vTaskPreemptionDisable( NULL );
1440 * // The task will not be preempted when it is executing in this portion ...
1442 * // ... until the preemption is enabled again.
1443 * vTaskPreemptionEnable( NULL );
1445 * // The task can be preempted when it is executing in this portion.
1449 void vTaskPreemptionDisable( const TaskHandle_t xTask );
1452 #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
1455 * @brief Enables preemption for a task.
1457 * @param xTask The handle of the task to enable preemption. Passing NULL
1458 * enables preemption for the calling task.
1462 * void vTaskCode( void *pvParameters )
1464 * // Silence warnings about unused parameters.
1465 * ( void ) pvParameters;
1469 * // ... Perform some function here.
1471 * // Disable preemption for this task.
1472 * vTaskPreemptionDisable( NULL );
1474 * // The task will not be preempted when it is executing in this portion ...
1476 * // ... until the preemption is enabled again.
1477 * vTaskPreemptionEnable( NULL );
1479 * // The task can be preempted when it is executing in this portion.
1483 void vTaskPreemptionEnable( const TaskHandle_t xTask );
1486 /*-----------------------------------------------------------
1488 *----------------------------------------------------------*/
1493 * void vTaskStartScheduler( void );
1496 * Starts the real time kernel tick processing. After calling the kernel
1497 * has control over which tasks are executed and when.
1499 * See the demo application file main.c for an example of creating
1500 * tasks and starting the kernel.
1504 * void vAFunction( void )
1506 * // Create at least one task before starting the kernel.
1507 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
1509 * // Start the real time kernel with preemption.
1510 * vTaskStartScheduler ();
1512 * // Will not get here unless a task calls vTaskEndScheduler ()
1516 * \defgroup vTaskStartScheduler vTaskStartScheduler
1517 * \ingroup SchedulerControl
1519 void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;
1524 * void vTaskEndScheduler( void );
1527 * NOTE: At the time of writing only the x86 real mode port, which runs on a PC
1528 * in place of DOS, implements this function.
1530 * Stops the real time kernel tick. All created tasks will be automatically
1531 * deleted and multitasking (either preemptive or cooperative) will
1532 * stop. Execution then resumes from the point where vTaskStartScheduler ()
1533 * was called, as if vTaskStartScheduler () had just returned.
1535 * See the demo application file main. c in the demo/PC directory for an
1536 * example that uses vTaskEndScheduler ().
1538 * vTaskEndScheduler () requires an exit function to be defined within the
1539 * portable layer (see vPortEndScheduler () in port. c for the PC port). This
1540 * performs hardware specific operations such as stopping the kernel tick.
1542 * vTaskEndScheduler () will cause all of the resources allocated by the
1543 * kernel to be freed - but will not free resources allocated by application
1548 * void vTaskCode( void * pvParameters )
1552 * // Task code goes here.
1554 * // At some point we want to end the real time kernel processing
1556 * vTaskEndScheduler ();
1560 * void vAFunction( void )
1562 * // Create at least one task before starting the kernel.
1563 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
1565 * // Start the real time kernel with preemption.
1566 * vTaskStartScheduler ();
1568 * // Will only get here when the vTaskCode () task has called
1569 * // vTaskEndScheduler (). When we get here we are back to single task
1574 * \defgroup vTaskEndScheduler vTaskEndScheduler
1575 * \ingroup SchedulerControl
1577 void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;
1582 * void vTaskSuspendAll( void );
1585 * Suspends the scheduler without disabling interrupts. Context switches will
1586 * not occur while the scheduler is suspended.
1588 * After calling vTaskSuspendAll () the calling task will continue to execute
1589 * without risk of being swapped out until a call to xTaskResumeAll () has been
1592 * API functions that have the potential to cause a context switch (for example,
1593 * xTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler
1598 * void vTask1( void * pvParameters )
1602 * // Task code goes here.
1606 * // At some point the task wants to perform a long operation during
1607 * // which it does not want to get swapped out. It cannot use
1608 * // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
1609 * // operation may cause interrupts to be missed - including the
1612 * // Prevent the real time kernel swapping out the task.
1613 * vTaskSuspendAll ();
1615 * // Perform the operation here. There is no need to use critical
1616 * // sections as we have all the microcontroller processing time.
1617 * // During this time interrupts will still operate and the kernel
1618 * // tick count will be maintained.
1622 * // The operation is complete. Restart the kernel.
1623 * xTaskResumeAll ();
1627 * \defgroup vTaskSuspendAll vTaskSuspendAll
1628 * \ingroup SchedulerControl
1630 void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;
1635 * BaseType_t xTaskResumeAll( void );
1638 * Resumes scheduler activity after it was suspended by a call to
1639 * vTaskSuspendAll().
1641 * xTaskResumeAll() only resumes the scheduler. It does not unsuspend tasks
1642 * that were previously suspended by a call to vTaskSuspend().
1644 * @return If resuming the scheduler caused a context switch then pdTRUE is
1645 * returned, otherwise pdFALSE is returned.
1649 * void vTask1( void * pvParameters )
1653 * // Task code goes here.
1657 * // At some point the task wants to perform a long operation during
1658 * // which it does not want to get swapped out. It cannot use
1659 * // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
1660 * // operation may cause interrupts to be missed - including the
1663 * // Prevent the real time kernel swapping out the task.
1664 * vTaskSuspendAll ();
1666 * // Perform the operation here. There is no need to use critical
1667 * // sections as we have all the microcontroller processing time.
1668 * // During this time interrupts will still operate and the real
1669 * // time kernel tick count will be maintained.
1673 * // The operation is complete. Restart the kernel. We want to force
1674 * // a context switch - but there is no point if resuming the scheduler
1675 * // caused a context switch already.
1676 * if( !xTaskResumeAll () )
1683 * \defgroup xTaskResumeAll xTaskResumeAll
1684 * \ingroup SchedulerControl
1686 BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION;
1688 /*-----------------------------------------------------------
1690 *----------------------------------------------------------*/
1695 * TickType_t xTaskGetTickCount( void );
1698 * @return The count of ticks since vTaskStartScheduler was called.
1700 * \defgroup xTaskGetTickCount xTaskGetTickCount
1701 * \ingroup TaskUtils
1703 TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;
1708 * TickType_t xTaskGetTickCountFromISR( void );
1711 * @return The count of ticks since vTaskStartScheduler was called.
1713 * This is a version of xTaskGetTickCount() that is safe to be called from an
1714 * ISR - provided that TickType_t is the natural word size of the
1715 * microcontroller being used or interrupt nesting is either not supported or
1718 * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR
1719 * \ingroup TaskUtils
1721 TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION;
1726 * uint16_t uxTaskGetNumberOfTasks( void );
1729 * @return The number of tasks that the real time kernel is currently managing.
1730 * This includes all ready, blocked and suspended tasks. A task that
1731 * has been deleted but not yet freed by the idle task will also be
1732 * included in the count.
1734 * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks
1735 * \ingroup TaskUtils
1737 UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;
1742 * char *pcTaskGetName( TaskHandle_t xTaskToQuery );
1745 * @return The text (human readable) name of the task referenced by the handle
1746 * xTaskToQuery. A task can query its own name by either passing in its own
1747 * handle, or by setting xTaskToQuery to NULL.
1749 * \defgroup pcTaskGetName pcTaskGetName
1750 * \ingroup TaskUtils
1752 char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION;
1757 * TaskHandle_t xTaskGetHandle( const char *pcNameToQuery );
1760 * NOTE: This function takes a relatively long time to complete and should be
1763 * @return The handle of the task that has the human readable name pcNameToQuery.
1764 * NULL is returned if no matching name is found. INCLUDE_xTaskGetHandle
1765 * must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available.
1767 * \defgroup pcTaskGetHandle pcTaskGetHandle
1768 * \ingroup TaskUtils
1770 #if ( INCLUDE_xTaskGetHandle == 1 )
1771 TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION;
1777 * BaseType_t xTaskGetStaticBuffers( TaskHandle_t xTask,
1778 * StackType_t ** ppuxStackBuffer,
1779 * StaticTask_t ** ppxTaskBuffer );
1782 * Retrieve pointers to a statically created task's data structure
1783 * buffer and stack buffer. These are the same buffers that are supplied
1784 * at the time of creation.
1786 * @param xTask The task for which to retrieve the buffers.
1788 * @param ppuxStackBuffer Used to return a pointer to the task's stack buffer.
1790 * @param ppxTaskBuffer Used to return a pointer to the task's data structure
1793 * @return pdTRUE if buffers were retrieved, pdFALSE otherwise.
1795 * \defgroup xTaskGetStaticBuffers xTaskGetStaticBuffers
1796 * \ingroup TaskUtils
1798 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1799 BaseType_t xTaskGetStaticBuffers( TaskHandle_t xTask,
1800 StackType_t ** ppuxStackBuffer,
1801 StaticTask_t ** ppxTaskBuffer ) PRIVILEGED_FUNCTION;
1802 #endif /* configSUPPORT_STATIC_ALLOCATION */
1807 * UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );
1810 * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for
1811 * this function to be available.
1813 * Returns the high water mark of the stack associated with xTask. That is,
1814 * the minimum free stack space there has been (in words, so on a 32 bit machine
1815 * a value of 1 means 4 bytes) since the task started. The smaller the returned
1816 * number the closer the task has come to overflowing its stack.
1818 * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
1819 * same except for their return type. Using configSTACK_DEPTH_TYPE allows the
1820 * user to determine the return type. It gets around the problem of the value
1821 * overflowing on 8-bit types without breaking backward compatibility for
1822 * applications that expect an 8-bit return type.
1824 * @param xTask Handle of the task associated with the stack to be checked.
1825 * Set xTask to NULL to check the stack of the calling task.
1827 * @return The smallest amount of free stack space there has been (in words, so
1828 * actual spaces on the stack rather than bytes) since the task referenced by
1829 * xTask was created.
1831 #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
1832 UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1838 * configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask );
1841 * INCLUDE_uxTaskGetStackHighWaterMark2 must be set to 1 in FreeRTOSConfig.h for
1842 * this function to be available.
1844 * Returns the high water mark of the stack associated with xTask. That is,
1845 * the minimum free stack space there has been (in words, so on a 32 bit machine
1846 * a value of 1 means 4 bytes) since the task started. The smaller the returned
1847 * number the closer the task has come to overflowing its stack.
1849 * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
1850 * same except for their return type. Using configSTACK_DEPTH_TYPE allows the
1851 * user to determine the return type. It gets around the problem of the value
1852 * overflowing on 8-bit types without breaking backward compatibility for
1853 * applications that expect an 8-bit return type.
1855 * @param xTask Handle of the task associated with the stack to be checked.
1856 * Set xTask to NULL to check the stack of the calling task.
1858 * @return The smallest amount of free stack space there has been (in words, so
1859 * actual spaces on the stack rather than bytes) since the task referenced by
1860 * xTask was created.
1862 #if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 )
1863 configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1866 /* When using trace macros it is sometimes necessary to include task.h before
1867 * FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,
1868 * so the following two prototypes will cause a compilation error. This can be
1869 * fixed by simply guarding against the inclusion of these two prototypes unless
1870 * they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration
1872 #ifdef configUSE_APPLICATION_TASK_TAG
1873 #if configUSE_APPLICATION_TASK_TAG == 1
1878 * void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );
1881 * Sets pxHookFunction to be the task hook function used by the task xTask.
1882 * Passing xTask as NULL has the effect of setting the calling tasks hook
1885 void vTaskSetApplicationTaskTag( TaskHandle_t xTask,
1886 TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION;
1891 * void xTaskGetApplicationTaskTag( TaskHandle_t xTask );
1894 * Returns the pxHookFunction value assigned to the task xTask. Do not
1895 * call from an interrupt service routine - call
1896 * xTaskGetApplicationTaskTagFromISR() instead.
1898 TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1903 * void xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );
1906 * Returns the pxHookFunction value assigned to the task xTask. Can
1907 * be called from an interrupt service routine.
1909 TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1910 #endif /* configUSE_APPLICATION_TASK_TAG ==1 */
1911 #endif /* ifdef configUSE_APPLICATION_TASK_TAG */
1913 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
1915 /* Each task contains an array of pointers that is dimensioned by the
1916 * configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. The
1917 * kernel does not use the pointers itself, so the application writer can use
1918 * the pointers for any purpose they wish. The following two functions are
1919 * used to set and query a pointer respectively. */
1920 void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet,
1922 void * pvValue ) PRIVILEGED_FUNCTION;
1923 void * pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery,
1924 BaseType_t xIndex ) PRIVILEGED_FUNCTION;
1928 #if ( configCHECK_FOR_STACK_OVERFLOW > 0 )
1933 * void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName);
1936 * The application stack overflow hook is called when a stack overflow is detected for a task.
1938 * Details on stack overflow detection can be found here: https://www.FreeRTOS.org/Stacks-and-stack-overflow-checking.html
1940 * @param xTask the task that just exceeded its stack boundaries.
1941 * @param pcTaskName A character string containing the name of the offending task.
1943 /* MISRA Ref 8.6.1 [External linkage] */
1944 /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-86 */
1945 /* coverity[misra_c_2012_rule_8_6_violation] */
1946 void vApplicationStackOverflowHook( TaskHandle_t xTask,
1947 char * pcTaskName );
1951 #if ( configUSE_IDLE_HOOK == 1 )
1956 * void vApplicationIdleHook( void );
1959 * The application idle hook is called by the idle task.
1960 * This allows the application designer to add background functionality without
1961 * the overhead of a separate task.
1962 * NOTE: vApplicationIdleHook() MUST NOT, UNDER ANY CIRCUMSTANCES, CALL A FUNCTION THAT MIGHT BLOCK.
1964 /* MISRA Ref 8.6.1 [External linkage] */
1965 /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-86 */
1966 /* coverity[misra_c_2012_rule_8_6_violation] */
1967 void vApplicationIdleHook( void );
1972 #if ( configUSE_TICK_HOOK != 0 )
1977 * void vApplicationTickHook( void );
1980 * This hook function is called in the system tick handler after any OS work is completed.
1982 /* MISRA Ref 8.6.1 [External linkage] */
1983 /* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-86 */
1984 /* coverity[misra_c_2012_rule_8_6_violation] */
1985 void vApplicationTickHook( void );
1989 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1994 * void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, configSTACK_DEPTH_TYPE * puxIdleTaskStackSize )
1997 * 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
1998 * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION
2000 * @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer
2001 * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task
2002 * @param puxIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
2004 void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
2005 StackType_t ** ppxIdleTaskStackBuffer,
2006 configSTACK_DEPTH_TYPE * puxIdleTaskStackSize );
2011 * void vApplicationGetPassiveIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, configSTACK_DEPTH_TYPE * puxIdleTaskStackSize, BaseType_t xCoreID )
2014 * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Idle Tasks TCB. This function is required when
2015 * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION
2017 * In the FreeRTOS SMP, there are a total of configNUMBER_OF_CORES idle tasks:
2018 * 1. 1 Active idle task which does all the housekeeping.
2019 * 2. ( configNUMBER_OF_CORES - 1 ) Passive idle tasks which do nothing.
2020 * These idle tasks are created to ensure that each core has an idle task to run when
2021 * no other task is available to run.
2023 * The function vApplicationGetPassiveIdleTaskMemory is called with passive idle
2024 * task index 0, 1 ... ( configNUMBER_OF_CORES - 2 ) to get memory for passive idle
2027 * @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer
2028 * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task
2029 * @param puxIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
2030 * @param xPassiveIdleTaskIndex The passive idle task index of the idle task buffer
2032 #if ( configNUMBER_OF_CORES > 1 )
2033 void vApplicationGetPassiveIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
2034 StackType_t ** ppxIdleTaskStackBuffer,
2035 configSTACK_DEPTH_TYPE * puxIdleTaskStackSize,
2036 BaseType_t xPassiveIdleTaskIndex );
2037 #endif /* #if ( configNUMBER_OF_CORES > 1 ) */
2038 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
2043 * BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );
2046 * Calls the hook function associated with xTask. Passing xTask as NULL has
2047 * the effect of calling the Running tasks (the calling task) hook function.
2049 * pvParameter is passed to the hook function for the task to interpret as it
2050 * wants. The return value is the value returned by the task hook function
2051 * registered by the user.
2053 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
2054 BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask,
2055 void * pvParameter ) PRIVILEGED_FUNCTION;
2059 * xTaskGetIdleTaskHandle() is only available if
2060 * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.
2062 * In single-core FreeRTOS, this function simply returns the handle of the idle
2063 * task. It is not valid to call xTaskGetIdleTaskHandle() before the scheduler
2066 * In the FreeRTOS SMP, there are a total of configNUMBER_OF_CORES idle tasks:
2067 * 1. 1 Active idle task which does all the housekeeping.
2068 * 2. ( configNUMBER_OF_CORES - 1 ) Passive idle tasks which do nothing.
2069 * These idle tasks are created to ensure that each core has an idle task to run when
2070 * no other task is available to run. Call xTaskGetIdleTaskHandle() or
2071 * xTaskGetIdleTaskHandleForCore() with xCoreID set to 0 to get the Active
2072 * idle task handle. Call xTaskGetIdleTaskHandleForCore() with xCoreID set to
2073 * 1,2 ... ( configNUMBER_OF_CORES - 1 ) to get the Passive idle task handles.
2075 #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
2076 #if ( configNUMBER_OF_CORES == 1 )
2077 TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
2078 #endif /* #if ( configNUMBER_OF_CORES == 1 ) */
2080 TaskHandle_t xTaskGetIdleTaskHandleForCore( BaseType_t xCoreID ) PRIVILEGED_FUNCTION;
2081 #endif /* #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) */
2084 * configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for
2085 * uxTaskGetSystemState() to be available.
2087 * uxTaskGetSystemState() populates an TaskStatus_t structure for each task in
2088 * the system. TaskStatus_t structures contain, among other things, members
2089 * for the task handle, task name, task priority, task state, and total amount
2090 * of run time consumed by the task. See the TaskStatus_t structure
2091 * definition in this file for the full member list.
2093 * NOTE: This function is intended for debugging use only as its use results in
2094 * the scheduler remaining suspended for an extended period.
2096 * @param pxTaskStatusArray A pointer to an array of TaskStatus_t structures.
2097 * The array must contain at least one TaskStatus_t structure for each task
2098 * that is under the control of the RTOS. The number of tasks under the control
2099 * of the RTOS can be determined using the uxTaskGetNumberOfTasks() API function.
2101 * @param uxArraySize The size of the array pointed to by the pxTaskStatusArray
2102 * parameter. The size is specified as the number of indexes in the array, or
2103 * the number of TaskStatus_t structures contained in the array, not by the
2104 * number of bytes in the array.
2106 * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in
2107 * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the
2108 * total run time (as defined by the run time stats clock, see
2109 * https://www.FreeRTOS.org/rtos-run-time-stats.html) since the target booted.
2110 * pulTotalRunTime can be set to NULL to omit the total run time information.
2112 * @return The number of TaskStatus_t structures that were populated by
2113 * uxTaskGetSystemState(). This should equal the number returned by the
2114 * uxTaskGetNumberOfTasks() API function, but will be zero if the value passed
2115 * in the uxArraySize parameter was too small.
2119 * // This example demonstrates how a human readable table of run time stats
2120 * // information is generated from raw data provided by uxTaskGetSystemState().
2121 * // The human readable table is written to pcWriteBuffer
2122 * void vTaskGetRunTimeStats( char *pcWriteBuffer )
2124 * TaskStatus_t *pxTaskStatusArray;
2125 * volatile UBaseType_t uxArraySize, x;
2126 * configRUN_TIME_COUNTER_TYPE ulTotalRunTime, ulStatsAsPercentage;
2128 * // Make sure the write buffer does not contain a string.
2129 * pcWriteBuffer = 0x00;
2131 * // Take a snapshot of the number of tasks in case it changes while this
2132 * // function is executing.
2133 * uxArraySize = uxTaskGetNumberOfTasks();
2135 * // Allocate a TaskStatus_t structure for each task. An array could be
2136 * // allocated statically at compile time.
2137 * pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
2139 * if( pxTaskStatusArray != NULL )
2141 * // Generate raw status information about each task.
2142 * uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );
2144 * // For percentage calculations.
2145 * ulTotalRunTime /= 100U;
2147 * // Avoid divide by zero errors.
2148 * if( ulTotalRunTime > 0 )
2150 * // For each populated position in the pxTaskStatusArray array,
2151 * // format the raw data as human readable ASCII data
2152 * for( x = 0; x < uxArraySize; x++ )
2154 * // What percentage of the total run time has the task used?
2155 * // This will always be rounded down to the nearest integer.
2156 * // ulTotalRunTimeDiv100 has already been divided by 100.
2157 * ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;
2159 * if( ulStatsAsPercentage > 0U )
2161 * sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
2165 * // If the percentage is zero here then the task has
2166 * // consumed less than 1% of the total run time.
2167 * sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );
2170 * pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );
2174 * // The array is no longer needed, free the memory it consumes.
2175 * vPortFree( pxTaskStatusArray );
2180 #if ( configUSE_TRACE_FACILITY == 1 )
2181 UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray,
2182 const UBaseType_t uxArraySize,
2183 configRUN_TIME_COUNTER_TYPE * const pulTotalRunTime ) PRIVILEGED_FUNCTION;
2189 * void vTaskListTasks( char *pcWriteBuffer, size_t uxBufferLength );
2192 * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must
2193 * both be defined as 1 for this function to be available. See the
2194 * configuration section of the FreeRTOS.org website for more information.
2196 * NOTE 1: This function will disable interrupts for its duration. It is
2197 * not intended for normal application runtime use but as a debug aid.
2199 * Lists all the current tasks, along with their current state and stack
2200 * usage high water mark.
2202 * Tasks are reported as running ('X'), blocked ('B'), ready ('R'), deleted ('D')
2203 * or suspended ('S').
2207 * This function is provided for convenience only, and is used by many of the
2208 * demo applications. Do not consider it to be part of the scheduler.
2210 * vTaskListTasks() calls uxTaskGetSystemState(), then formats part of the
2211 * uxTaskGetSystemState() output into a human readable table that displays task
2212 * information in the following format:
2213 * Task Name, Task State, Task Priority, Task Stack High Watermak, Task Number.
2215 * The following is a sample output:
2221 * Stack usage specified as the number of unused StackType_t words stack can hold
2222 * on top of stack - not the number of bytes.
2224 * vTaskListTasks() has a dependency on the snprintf() C library function that might
2225 * bloat the code size, use a lot of stack, and provide different results on
2226 * different platforms. An alternative, tiny, third party, and limited
2227 * functionality implementation of snprintf() is provided in many of the
2228 * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
2229 * printf-stdarg.c does not provide a full snprintf() implementation!).
2231 * It is recommended that production systems call uxTaskGetSystemState()
2232 * directly to get access to raw stats data, rather than indirectly through a
2233 * call to vTaskListTasks().
2235 * @param pcWriteBuffer A buffer into which the above mentioned details
2236 * will be written, in ASCII form. This buffer is assumed to be large
2237 * enough to contain the generated report. Approximately 40 bytes per
2238 * task should be sufficient.
2240 * @param uxBufferLength Length of the pcWriteBuffer.
2242 * \defgroup vTaskListTasks vTaskListTasks
2243 * \ingroup TaskUtils
2245 #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) )
2246 void vTaskListTasks( char * pcWriteBuffer,
2247 size_t uxBufferLength ) PRIVILEGED_FUNCTION;
2253 * void vTaskList( char *pcWriteBuffer );
2256 * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must
2257 * both be defined as 1 for this function to be available. See the
2258 * configuration section of the FreeRTOS.org website for more information.
2260 * WARN: This function assumes that the pcWriteBuffer is of length
2261 * configSTATS_BUFFER_MAX_LENGTH. This function is there only for
2262 * backward compatibility. New applications are recommended to
2263 * use vTaskListTasks and supply the length of the pcWriteBuffer explicitly.
2265 * NOTE 1: This function will disable interrupts for its duration. It is
2266 * not intended for normal application runtime use but as a debug aid.
2268 * Lists all the current tasks, along with their current state and stack
2269 * usage high water mark.
2271 * Tasks are reported as running ('X'), blocked ('B'), ready ('R'), deleted ('D')
2272 * or suspended ('S').
2276 * This function is provided for convenience only, and is used by many of the
2277 * demo applications. Do not consider it to be part of the scheduler.
2279 * vTaskList() calls uxTaskGetSystemState(), then formats part of the
2280 * uxTaskGetSystemState() output into a human readable table that displays task
2281 * information in the following format:
2282 * Task Name, Task State, Task Priority, Task Stack High Watermak, Task Number.
2284 * The following is a sample output:
2290 * Stack usage specified as the number of unused StackType_t words stack can hold
2291 * on top of stack - not the number of bytes.
2293 * vTaskList() has a dependency on the snprintf() C library function that might
2294 * bloat the code size, use a lot of stack, and provide different results on
2295 * different platforms. An alternative, tiny, third party, and limited
2296 * functionality implementation of snprintf() is provided in many of the
2297 * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
2298 * printf-stdarg.c does not provide a full snprintf() implementation!).
2300 * It is recommended that production systems call uxTaskGetSystemState()
2301 * directly to get access to raw stats data, rather than indirectly through a
2302 * call to vTaskList().
2304 * @param pcWriteBuffer A buffer into which the above mentioned details
2305 * will be written, in ASCII form. This buffer is assumed to be large
2306 * enough to contain the generated report. Approximately 40 bytes per
2307 * task should be sufficient.
2309 * \defgroup vTaskList vTaskList
2310 * \ingroup TaskUtils
2312 #define vTaskList( pcWriteBuffer ) vTaskListTasks( ( pcWriteBuffer ), configSTATS_BUFFER_MAX_LENGTH )
2317 * void vTaskGetRunTimeStatistics( char *pcWriteBuffer, size_t uxBufferLength );
2320 * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
2321 * must both be defined as 1 for this function to be available. The application
2322 * must also then provide definitions for
2323 * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
2324 * to configure a peripheral timer/counter and return the timers current count
2325 * value respectively. The counter should be at least 10 times the frequency of
2328 * NOTE 1: This function will disable interrupts for its duration. It is
2329 * not intended for normal application runtime use but as a debug aid.
2331 * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
2332 * accumulated execution time being stored for each task. The resolution
2333 * of the accumulated time value depends on the frequency of the timer
2334 * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
2335 * Calling vTaskGetRunTimeStatistics() writes the total execution time of each
2336 * task into a buffer, both as an absolute count value and as a percentage
2337 * of the total system execution time.
2341 * This function is provided for convenience only, and is used by many of the
2342 * demo applications. Do not consider it to be part of the scheduler.
2344 * vTaskGetRunTimeStatistics() calls uxTaskGetSystemState(), then formats part of
2345 * the uxTaskGetSystemState() output into a human readable table that displays the
2346 * amount of time each task has spent in the Running state in both absolute and
2349 * vTaskGetRunTimeStatistics() has a dependency on the snprintf() C library function
2350 * that might bloat the code size, use a lot of stack, and provide different
2351 * results on different platforms. An alternative, tiny, third party, and
2352 * limited functionality implementation of snprintf() is provided in many of the
2353 * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
2354 * printf-stdarg.c does not provide a full snprintf() implementation!).
2356 * It is recommended that production systems call uxTaskGetSystemState() directly
2357 * to get access to raw stats data, rather than indirectly through a call to
2358 * vTaskGetRunTimeStatistics().
2360 * @param pcWriteBuffer A buffer into which the execution times will be
2361 * written, in ASCII form. This buffer is assumed to be large enough to
2362 * contain the generated report. Approximately 40 bytes per task should
2365 * @param uxBufferLength Length of the pcWriteBuffer.
2367 * \defgroup vTaskGetRunTimeStatistics vTaskGetRunTimeStatistics
2368 * \ingroup TaskUtils
2370 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configUSE_TRACE_FACILITY == 1 ) )
2371 void vTaskGetRunTimeStatistics( char * pcWriteBuffer,
2372 size_t uxBufferLength ) PRIVILEGED_FUNCTION;
2378 * void vTaskGetRunTimeStats( char *pcWriteBuffer );
2381 * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
2382 * must both be defined as 1 for this function to be available. The application
2383 * must also then provide definitions for
2384 * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
2385 * to configure a peripheral timer/counter and return the timers current count
2386 * value respectively. The counter should be at least 10 times the frequency of
2389 * WARN: This function assumes that the pcWriteBuffer is of length
2390 * configSTATS_BUFFER_MAX_LENGTH. This function is there only for
2391 * backward compatibility. New applications are recommended to use
2392 * vTaskGetRunTimeStatistics and supply the length of the pcWriteBuffer
2395 * NOTE 1: This function will disable interrupts for its duration. It is
2396 * not intended for normal application runtime use but as a debug aid.
2398 * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
2399 * accumulated execution time being stored for each task. The resolution
2400 * of the accumulated time value depends on the frequency of the timer
2401 * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
2402 * Calling vTaskGetRunTimeStats() writes the total execution time of each
2403 * task into a buffer, both as an absolute count value and as a percentage
2404 * of the total system execution time.
2408 * This function is provided for convenience only, and is used by many of the
2409 * demo applications. Do not consider it to be part of the scheduler.
2411 * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the
2412 * uxTaskGetSystemState() output into a human readable table that displays the
2413 * amount of time each task has spent in the Running state in both absolute and
2416 * vTaskGetRunTimeStats() has a dependency on the snprintf() C library function
2417 * that might bloat the code size, use a lot of stack, and provide different
2418 * results on different platforms. An alternative, tiny, third party, and
2419 * limited functionality implementation of snprintf() is provided in many of the
2420 * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
2421 * printf-stdarg.c does not provide a full snprintf() implementation!).
2423 * It is recommended that production systems call uxTaskGetSystemState() directly
2424 * to get access to raw stats data, rather than indirectly through a call to
2425 * vTaskGetRunTimeStats().
2427 * @param pcWriteBuffer A buffer into which the execution times will be
2428 * written, in ASCII form. This buffer is assumed to be large enough to
2429 * contain the generated report. Approximately 40 bytes per task should
2432 * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats
2433 * \ingroup TaskUtils
2435 #define vTaskGetRunTimeStats( pcWriteBuffer ) vTaskGetRunTimeStatistics( ( pcWriteBuffer ), configSTATS_BUFFER_MAX_LENGTH )
2440 * configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimeCounter( const TaskHandle_t xTask );
2441 * configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimePercent( const TaskHandle_t xTask );
2444 * configGENERATE_RUN_TIME_STATS must be defined as 1 for these functions to be
2445 * available. The application must also then provide definitions for
2446 * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
2447 * portGET_RUN_TIME_COUNTER_VALUE() to configure a peripheral timer/counter and
2448 * return the timers current count value respectively. The counter should be
2449 * at least 10 times the frequency of the tick count.
2451 * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
2452 * accumulated execution time being stored for each task. The resolution
2453 * of the accumulated time value depends on the frequency of the timer
2454 * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
2455 * While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total
2456 * execution time of each task into a buffer, ulTaskGetRunTimeCounter()
2457 * returns the total execution time of just one task and
2458 * ulTaskGetRunTimePercent() returns the percentage of the CPU time used by
2461 * @return The total run time of the given task or the percentage of the total
2462 * run time consumed by the given task. This is the amount of time the task
2463 * has actually been executing. The unit of time is dependent on the frequency
2464 * configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
2465 * portGET_RUN_TIME_COUNTER_VALUE() macros.
2467 * \defgroup ulTaskGetRunTimeCounter ulTaskGetRunTimeCounter
2468 * \ingroup TaskUtils
2470 #if ( configGENERATE_RUN_TIME_STATS == 1 )
2471 configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimeCounter( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
2472 configRUN_TIME_COUNTER_TYPE ulTaskGetRunTimePercent( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
2478 * configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimeCounter( void );
2479 * configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void );
2482 * configGENERATE_RUN_TIME_STATS must be defined as 1 for these functions to be
2483 * available. The application must also then provide definitions for
2484 * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
2485 * portGET_RUN_TIME_COUNTER_VALUE() to configure a peripheral timer/counter and
2486 * return the timers current count value respectively. The counter should be
2487 * at least 10 times the frequency of the tick count.
2489 * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
2490 * accumulated execution time being stored for each task. The resolution
2491 * of the accumulated time value depends on the frequency of the timer
2492 * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
2493 * While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total
2494 * execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter()
2495 * returns the total execution time of just the idle task and
2496 * ulTaskGetIdleRunTimePercent() returns the percentage of the CPU time used by
2497 * just the idle task.
2499 * Note the amount of idle time is only a good measure of the slack time in a
2500 * system if there are no other tasks executing at the idle priority, tickless
2501 * idle is not used, and configIDLE_SHOULD_YIELD is set to 0.
2503 * @return The total run time of the idle task or the percentage of the total
2504 * run time consumed by the idle task. This is the amount of time the
2505 * idle task has actually been executing. The unit of time is dependent on the
2506 * frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
2507 * portGET_RUN_TIME_COUNTER_VALUE() macros.
2509 * \defgroup ulTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter
2510 * \ingroup TaskUtils
2512 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
2513 configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION;
2514 configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void ) PRIVILEGED_FUNCTION;
2520 * BaseType_t xTaskNotifyIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction );
2521 * BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );
2524 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2526 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2527 * functions to be available.
2529 * Sends a direct to task notification to a task, with an optional value and
2532 * Each task has a private array of "notification values" (or 'notifications'),
2533 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2534 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2535 * array, and (for backward compatibility) defaults to 1 if left undefined.
2536 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2538 * Events can be sent to a task using an intermediary object. Examples of such
2539 * objects are queues, semaphores, mutexes and event groups. Task notifications
2540 * are a method of sending an event directly to a task without the need for such
2541 * an intermediary object.
2543 * A notification sent to a task can optionally perform an action, such as
2544 * update, overwrite or increment one of the task's notification values. In
2545 * that way task notifications can be used to send data to a task, or be used as
2546 * light weight and fast binary or counting semaphores.
2548 * A task can use xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() to
2549 * [optionally] block to wait for a notification to be pending. The task does
2550 * not consume any CPU time while it is in the Blocked state.
2552 * A notification sent to a task will remain pending until it is cleared by the
2553 * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
2554 * un-indexed equivalents). If the task was already in the Blocked state to
2555 * wait for a notification when the notification arrives then the task will
2556 * automatically be removed from the Blocked state (unblocked) and the
2557 * notification cleared.
2559 * **NOTE** Each notification within the array operates independently - a task
2560 * can only block on one notification within the array at a time and will not be
2561 * unblocked by a notification sent to any other array index.
2563 * Backward compatibility information:
2564 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2565 * all task notification API functions operated on that value. Replacing the
2566 * single notification value with an array of notification values necessitated a
2567 * new set of API functions that could address specific notifications within the
2568 * array. xTaskNotify() is the original API function, and remains backward
2569 * compatible by always operating on the notification value at index 0 in the
2570 * array. Calling xTaskNotify() is equivalent to calling xTaskNotifyIndexed()
2571 * with the uxIndexToNotify parameter set to 0.
2573 * @param xTaskToNotify The handle of the task being notified. The handle to a
2574 * task can be returned from the xTaskCreate() API function used to create the
2575 * task, and the handle of the currently running task can be obtained by calling
2576 * xTaskGetCurrentTaskHandle().
2578 * @param uxIndexToNotify The index within the target task's array of
2579 * notification values to which the notification is to be sent. uxIndexToNotify
2580 * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotify() does
2581 * not have this parameter and always sends notifications to index 0.
2583 * @param ulValue Data that can be sent with the notification. How the data is
2584 * used depends on the value of the eAction parameter.
2586 * @param eAction Specifies how the notification updates the task's notification
2587 * value, if at all. Valid values for eAction are as follows:
2590 * The target notification value is bitwise ORed with ulValue.
2591 * xTaskNotifyIndexed() always returns pdPASS in this case.
2594 * The target notification value is incremented. ulValue is not used and
2595 * xTaskNotifyIndexed() always returns pdPASS in this case.
2597 * eSetValueWithOverwrite -
2598 * The target notification value is set to the value of ulValue, even if the
2599 * task being notified had not yet processed the previous notification at the
2600 * same array index (the task already had a notification pending at that index).
2601 * xTaskNotifyIndexed() always returns pdPASS in this case.
2603 * eSetValueWithoutOverwrite -
2604 * If the task being notified did not already have a notification pending at the
2605 * same array index then the target notification value is set to ulValue and
2606 * xTaskNotifyIndexed() will return pdPASS. If the task being notified already
2607 * had a notification pending at the same array index then no action is
2608 * performed and pdFAIL is returned.
2611 * The task receives a notification at the specified array index without the
2612 * notification value at that index being updated. ulValue is not used and
2613 * xTaskNotifyIndexed() always returns pdPASS in this case.
2615 * pulPreviousNotificationValue -
2616 * Can be used to pass out the subject task's notification value before any
2617 * bits are modified by the notify function.
2619 * @return Dependent on the value of eAction. See the description of the
2620 * eAction parameter.
2622 * \defgroup xTaskNotifyIndexed xTaskNotifyIndexed
2623 * \ingroup TaskNotifications
2625 BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify,
2626 UBaseType_t uxIndexToNotify,
2628 eNotifyAction eAction,
2629 uint32_t * pulPreviousNotificationValue ) PRIVILEGED_FUNCTION;
2630 #define xTaskNotify( xTaskToNotify, ulValue, eAction ) \
2631 xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL )
2632 #define xTaskNotifyIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction ) \
2633 xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL )
2638 * BaseType_t xTaskNotifyAndQueryIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue );
2639 * BaseType_t xTaskNotifyAndQuery( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue );
2642 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2644 * xTaskNotifyAndQueryIndexed() performs the same operation as
2645 * xTaskNotifyIndexed() with the addition that it also returns the subject
2646 * task's prior notification value (the notification value at the time the
2647 * function is called rather than when the function returns) in the additional
2648 * pulPreviousNotifyValue parameter.
2650 * xTaskNotifyAndQuery() performs the same operation as xTaskNotify() with the
2651 * addition that it also returns the subject task's prior notification value
2652 * (the notification value as it was at the time the function is called, rather
2653 * than when the function returns) in the additional pulPreviousNotifyValue
2656 * \defgroup xTaskNotifyAndQueryIndexed xTaskNotifyAndQueryIndexed
2657 * \ingroup TaskNotifications
2659 #define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) \
2660 xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
2661 #define xTaskNotifyAndQueryIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotifyValue ) \
2662 xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
2667 * BaseType_t xTaskNotifyIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );
2668 * BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );
2671 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2673 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2674 * functions to be available.
2676 * A version of xTaskNotifyIndexed() that can be used from an interrupt service
2679 * Each task has a private array of "notification values" (or 'notifications'),
2680 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2681 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2682 * array, and (for backward compatibility) defaults to 1 if left undefined.
2683 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2685 * Events can be sent to a task using an intermediary object. Examples of such
2686 * objects are queues, semaphores, mutexes and event groups. Task notifications
2687 * are a method of sending an event directly to a task without the need for such
2688 * an intermediary object.
2690 * A notification sent to a task can optionally perform an action, such as
2691 * update, overwrite or increment one of the task's notification values. In
2692 * that way task notifications can be used to send data to a task, or be used as
2693 * light weight and fast binary or counting semaphores.
2695 * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a
2696 * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block
2697 * to wait for a notification value to have a non-zero value. The task does
2698 * not consume any CPU time while it is in the Blocked state.
2700 * A notification sent to a task will remain pending until it is cleared by the
2701 * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
2702 * un-indexed equivalents). If the task was already in the Blocked state to
2703 * wait for a notification when the notification arrives then the task will
2704 * automatically be removed from the Blocked state (unblocked) and the
2705 * notification cleared.
2707 * **NOTE** Each notification within the array operates independently - a task
2708 * can only block on one notification within the array at a time and will not be
2709 * unblocked by a notification sent to any other array index.
2711 * Backward compatibility information:
2712 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2713 * all task notification API functions operated on that value. Replacing the
2714 * single notification value with an array of notification values necessitated a
2715 * new set of API functions that could address specific notifications within the
2716 * array. xTaskNotifyFromISR() is the original API function, and remains
2717 * backward compatible by always operating on the notification value at index 0
2718 * within the array. Calling xTaskNotifyFromISR() is equivalent to calling
2719 * xTaskNotifyIndexedFromISR() with the uxIndexToNotify parameter set to 0.
2721 * @param uxIndexToNotify The index within the target task's array of
2722 * notification values to which the notification is to be sent. uxIndexToNotify
2723 * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyFromISR()
2724 * does not have this parameter and always sends notifications to index 0.
2726 * @param xTaskToNotify The handle of the task being notified. The handle to a
2727 * task can be returned from the xTaskCreate() API function used to create the
2728 * task, and the handle of the currently running task can be obtained by calling
2729 * xTaskGetCurrentTaskHandle().
2731 * @param ulValue Data that can be sent with the notification. How the data is
2732 * used depends on the value of the eAction parameter.
2734 * @param eAction Specifies how the notification updates the task's notification
2735 * value, if at all. Valid values for eAction are as follows:
2738 * The task's notification value is bitwise ORed with ulValue. xTaskNotify()
2739 * always returns pdPASS in this case.
2742 * The task's notification value is incremented. ulValue is not used and
2743 * xTaskNotify() always returns pdPASS in this case.
2745 * eSetValueWithOverwrite -
2746 * The task's notification value is set to the value of ulValue, even if the
2747 * task being notified had not yet processed the previous notification (the
2748 * task already had a notification pending). xTaskNotify() always returns
2749 * pdPASS in this case.
2751 * eSetValueWithoutOverwrite -
2752 * If the task being notified did not already have a notification pending then
2753 * the task's notification value is set to ulValue and xTaskNotify() will
2754 * return pdPASS. If the task being notified already had a notification
2755 * pending then no action is performed and pdFAIL is returned.
2758 * The task receives a notification without its notification value being
2759 * updated. ulValue is not used and xTaskNotify() always returns pdPASS in
2762 * @param pxHigherPriorityTaskWoken xTaskNotifyFromISR() will set
2763 * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
2764 * task to which the notification was sent to leave the Blocked state, and the
2765 * unblocked task has a priority higher than the currently running task. If
2766 * xTaskNotifyFromISR() sets this value to pdTRUE then a context switch should
2767 * be requested before the interrupt is exited. How a context switch is
2768 * requested from an ISR is dependent on the port - see the documentation page
2769 * for the port in use.
2771 * @return Dependent on the value of eAction. See the description of the
2772 * eAction parameter.
2774 * \defgroup xTaskNotifyIndexedFromISR xTaskNotifyIndexedFromISR
2775 * \ingroup TaskNotifications
2777 BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify,
2778 UBaseType_t uxIndexToNotify,
2780 eNotifyAction eAction,
2781 uint32_t * pulPreviousNotificationValue,
2782 BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
2783 #define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \
2784 xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
2785 #define xTaskNotifyIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \
2786 xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
2791 * BaseType_t xTaskNotifyAndQueryIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken );
2792 * BaseType_t xTaskNotifyAndQueryFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken );
2795 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2797 * xTaskNotifyAndQueryIndexedFromISR() performs the same operation as
2798 * xTaskNotifyIndexedFromISR() with the addition that it also returns the
2799 * subject task's prior notification value (the notification value at the time
2800 * the function is called rather than at the time the function returns) in the
2801 * additional pulPreviousNotifyValue parameter.
2803 * xTaskNotifyAndQueryFromISR() performs the same operation as
2804 * xTaskNotifyFromISR() with the addition that it also returns the subject
2805 * task's prior notification value (the notification value at the time the
2806 * function is called rather than at the time the function returns) in the
2807 * additional pulPreviousNotifyValue parameter.
2809 * \defgroup xTaskNotifyAndQueryIndexedFromISR xTaskNotifyAndQueryIndexedFromISR
2810 * \ingroup TaskNotifications
2812 #define xTaskNotifyAndQueryIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \
2813 xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
2814 #define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \
2815 xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
2820 * BaseType_t xTaskNotifyWaitIndexed( UBaseType_t uxIndexToWaitOn, uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
2822 * BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
2825 * Waits for a direct to task notification to be pending at a given index within
2826 * an array of direct to task notifications.
2828 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2830 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
2831 * function to be available.
2833 * Each task has a private array of "notification values" (or 'notifications'),
2834 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2835 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2836 * array, and (for backward compatibility) defaults to 1 if left undefined.
2837 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2839 * Events can be sent to a task using an intermediary object. Examples of such
2840 * objects are queues, semaphores, mutexes and event groups. Task notifications
2841 * are a method of sending an event directly to a task without the need for such
2842 * an intermediary object.
2844 * A notification sent to a task can optionally perform an action, such as
2845 * update, overwrite or increment one of the task's notification values. In
2846 * that way task notifications can be used to send data to a task, or be used as
2847 * light weight and fast binary or counting semaphores.
2849 * A notification sent to a task will remain pending until it is cleared by the
2850 * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
2851 * un-indexed equivalents). If the task was already in the Blocked state to
2852 * wait for a notification when the notification arrives then the task will
2853 * automatically be removed from the Blocked state (unblocked) and the
2854 * notification cleared.
2856 * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a
2857 * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block
2858 * to wait for a notification value to have a non-zero value. The task does
2859 * not consume any CPU time while it is in the Blocked state.
2861 * **NOTE** Each notification within the array operates independently - a task
2862 * can only block on one notification within the array at a time and will not be
2863 * unblocked by a notification sent to any other array index.
2865 * Backward compatibility information:
2866 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2867 * all task notification API functions operated on that value. Replacing the
2868 * single notification value with an array of notification values necessitated a
2869 * new set of API functions that could address specific notifications within the
2870 * array. xTaskNotifyWait() is the original API function, and remains backward
2871 * compatible by always operating on the notification value at index 0 in the
2872 * array. Calling xTaskNotifyWait() is equivalent to calling
2873 * xTaskNotifyWaitIndexed() with the uxIndexToWaitOn parameter set to 0.
2875 * @param uxIndexToWaitOn The index within the calling task's array of
2876 * notification values on which the calling task will wait for a notification to
2877 * be received. uxIndexToWaitOn must be less than
2878 * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyWait() does
2879 * not have this parameter and always waits for notifications on index 0.
2881 * @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value
2882 * will be cleared in the calling task's notification value before the task
2883 * checks to see if any notifications are pending, and optionally blocks if no
2884 * notifications are pending. Setting ulBitsToClearOnEntry to ULONG_MAX (if
2885 * limits.h is included) or 0xffffffffU (if limits.h is not included) will have
2886 * the effect of resetting the task's notification value to 0. Setting
2887 * ulBitsToClearOnEntry to 0 will leave the task's notification value unchanged.
2889 * @param ulBitsToClearOnExit If a notification is pending or received before
2890 * the calling task exits the xTaskNotifyWait() function then the task's
2891 * notification value (see the xTaskNotify() API function) is passed out using
2892 * the pulNotificationValue parameter. Then any bits that are set in
2893 * ulBitsToClearOnExit will be cleared in the task's notification value (note
2894 * *pulNotificationValue is set before any bits are cleared). Setting
2895 * ulBitsToClearOnExit to ULONG_MAX (if limits.h is included) or 0xffffffffUL
2896 * (if limits.h is not included) will have the effect of resetting the task's
2897 * notification value to 0 before the function exits. Setting
2898 * ulBitsToClearOnExit to 0 will leave the task's notification value unchanged
2899 * when the function exits (in which case the value passed out in
2900 * pulNotificationValue will match the task's notification value).
2902 * @param pulNotificationValue Used to pass the task's notification value out
2903 * of the function. Note the value passed out will not be effected by the
2904 * clearing of any bits caused by ulBitsToClearOnExit being non-zero.
2906 * @param xTicksToWait The maximum amount of time that the task should wait in
2907 * the Blocked state for a notification to be received, should a notification
2908 * not already be pending when xTaskNotifyWait() was called. The task
2909 * will not consume any processing time while it is in the Blocked state. This
2910 * is specified in kernel ticks, the macro pdMS_TO_TICKS( value_in_ms ) can be
2911 * used to convert a time specified in milliseconds to a time specified in
2914 * @return If a notification was received (including notifications that were
2915 * already pending when xTaskNotifyWait was called) then pdPASS is
2916 * returned. Otherwise pdFAIL is returned.
2918 * \defgroup xTaskNotifyWaitIndexed xTaskNotifyWaitIndexed
2919 * \ingroup TaskNotifications
2921 BaseType_t xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn,
2922 uint32_t ulBitsToClearOnEntry,
2923 uint32_t ulBitsToClearOnExit,
2924 uint32_t * pulNotificationValue,
2925 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2926 #define xTaskNotifyWait( ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \
2927 xTaskGenericNotifyWait( tskDEFAULT_INDEX_TO_NOTIFY, ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) )
2928 #define xTaskNotifyWaitIndexed( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \
2929 xTaskGenericNotifyWait( ( uxIndexToWaitOn ), ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) )
2934 * BaseType_t xTaskNotifyGiveIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify );
2935 * BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );
2938 * Sends a direct to task notification to a particular index in the target
2939 * task's notification array in a manner similar to giving a counting semaphore.
2941 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
2943 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2944 * macros to be available.
2946 * Each task has a private array of "notification values" (or 'notifications'),
2947 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2948 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2949 * array, and (for backward compatibility) defaults to 1 if left undefined.
2950 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2952 * Events can be sent to a task using an intermediary object. Examples of such
2953 * objects are queues, semaphores, mutexes and event groups. Task notifications
2954 * are a method of sending an event directly to a task without the need for such
2955 * an intermediary object.
2957 * A notification sent to a task can optionally perform an action, such as
2958 * update, overwrite or increment one of the task's notification values. In
2959 * that way task notifications can be used to send data to a task, or be used as
2960 * light weight and fast binary or counting semaphores.
2962 * xTaskNotifyGiveIndexed() is a helper macro intended for use when task
2963 * notifications are used as light weight and faster binary or counting
2964 * semaphore equivalents. Actual FreeRTOS semaphores are given using the
2965 * xSemaphoreGive() API function, the equivalent action that instead uses a task
2966 * notification is xTaskNotifyGiveIndexed().
2968 * When task notifications are being used as a binary or counting semaphore
2969 * equivalent then the task being notified should wait for the notification
2970 * using the ulTaskNotifyTakeIndexed() API function rather than the
2971 * xTaskNotifyWaitIndexed() API function.
2973 * **NOTE** Each notification within the array operates independently - a task
2974 * can only block on one notification within the array at a time and will not be
2975 * unblocked by a notification sent to any other array index.
2977 * Backward compatibility information:
2978 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2979 * all task notification API functions operated on that value. Replacing the
2980 * single notification value with an array of notification values necessitated a
2981 * new set of API functions that could address specific notifications within the
2982 * array. xTaskNotifyGive() is the original API function, and remains backward
2983 * compatible by always operating on the notification value at index 0 in the
2984 * array. Calling xTaskNotifyGive() is equivalent to calling
2985 * xTaskNotifyGiveIndexed() with the uxIndexToNotify parameter set to 0.
2987 * @param xTaskToNotify The handle of the task being notified. The handle to a
2988 * task can be returned from the xTaskCreate() API function used to create the
2989 * task, and the handle of the currently running task can be obtained by calling
2990 * xTaskGetCurrentTaskHandle().
2992 * @param uxIndexToNotify The index within the target task's array of
2993 * notification values to which the notification is to be sent. uxIndexToNotify
2994 * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyGive()
2995 * does not have this parameter and always sends notifications to index 0.
2997 * @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the
2998 * eAction parameter set to eIncrement - so pdPASS is always returned.
3000 * \defgroup xTaskNotifyGiveIndexed xTaskNotifyGiveIndexed
3001 * \ingroup TaskNotifications
3003 #define xTaskNotifyGive( xTaskToNotify ) \
3004 xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( 0 ), eIncrement, NULL )
3005 #define xTaskNotifyGiveIndexed( xTaskToNotify, uxIndexToNotify ) \
3006 xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( 0 ), eIncrement, NULL )
3011 * void vTaskNotifyGiveIndexedFromISR( TaskHandle_t xTaskHandle, UBaseType_t uxIndexToNotify, BaseType_t *pxHigherPriorityTaskWoken );
3012 * void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );
3015 * A version of xTaskNotifyGiveIndexed() that can be called from an interrupt
3016 * service routine (ISR).
3018 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
3020 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro
3023 * Each task has a private array of "notification values" (or 'notifications'),
3024 * each of which is a 32-bit unsigned integer (uint32_t). The constant
3025 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
3026 * array, and (for backward compatibility) defaults to 1 if left undefined.
3027 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
3029 * Events can be sent to a task using an intermediary object. Examples of such
3030 * objects are queues, semaphores, mutexes and event groups. Task notifications
3031 * are a method of sending an event directly to a task without the need for such
3032 * an intermediary object.
3034 * A notification sent to a task can optionally perform an action, such as
3035 * update, overwrite or increment one of the task's notification values. In
3036 * that way task notifications can be used to send data to a task, or be used as
3037 * light weight and fast binary or counting semaphores.
3039 * vTaskNotifyGiveIndexedFromISR() is intended for use when task notifications
3040 * are used as light weight and faster binary or counting semaphore equivalents.
3041 * Actual FreeRTOS semaphores are given from an ISR using the
3042 * xSemaphoreGiveFromISR() API function, the equivalent action that instead uses
3043 * a task notification is vTaskNotifyGiveIndexedFromISR().
3045 * When task notifications are being used as a binary or counting semaphore
3046 * equivalent then the task being notified should wait for the notification
3047 * using the ulTaskNotifyTakeIndexed() API function rather than the
3048 * xTaskNotifyWaitIndexed() API function.
3050 * **NOTE** Each notification within the array operates independently - a task
3051 * can only block on one notification within the array at a time and will not be
3052 * unblocked by a notification sent to any other array index.
3054 * Backward compatibility information:
3055 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
3056 * all task notification API functions operated on that value. Replacing the
3057 * single notification value with an array of notification values necessitated a
3058 * new set of API functions that could address specific notifications within the
3059 * array. xTaskNotifyFromISR() is the original API function, and remains
3060 * backward compatible by always operating on the notification value at index 0
3061 * within the array. Calling xTaskNotifyGiveFromISR() is equivalent to calling
3062 * xTaskNotifyGiveIndexedFromISR() with the uxIndexToNotify parameter set to 0.
3064 * @param xTaskToNotify The handle of the task being notified. The handle to a
3065 * task can be returned from the xTaskCreate() API function used to create the
3066 * task, and the handle of the currently running task can be obtained by calling
3067 * xTaskGetCurrentTaskHandle().
3069 * @param uxIndexToNotify The index within the target task's array of
3070 * notification values to which the notification is to be sent. uxIndexToNotify
3071 * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
3072 * xTaskNotifyGiveFromISR() does not have this parameter and always sends
3073 * notifications to index 0.
3075 * @param pxHigherPriorityTaskWoken vTaskNotifyGiveFromISR() will set
3076 * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
3077 * task to which the notification was sent to leave the Blocked state, and the
3078 * unblocked task has a priority higher than the currently running task. If
3079 * vTaskNotifyGiveFromISR() sets this value to pdTRUE then a context switch
3080 * should be requested before the interrupt is exited. How a context switch is
3081 * requested from an ISR is dependent on the port - see the documentation page
3082 * for the port in use.
3084 * \defgroup vTaskNotifyGiveIndexedFromISR vTaskNotifyGiveIndexedFromISR
3085 * \ingroup TaskNotifications
3087 void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify,
3088 UBaseType_t uxIndexToNotify,
3089 BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
3090 #define vTaskNotifyGiveFromISR( xTaskToNotify, pxHigherPriorityTaskWoken ) \
3091 vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( pxHigherPriorityTaskWoken ) )
3092 #define vTaskNotifyGiveIndexedFromISR( xTaskToNotify, uxIndexToNotify, pxHigherPriorityTaskWoken ) \
3093 vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( pxHigherPriorityTaskWoken ) )
3098 * uint32_t ulTaskNotifyTakeIndexed( UBaseType_t uxIndexToWaitOn, BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
3100 * uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
3103 * Waits for a direct to task notification on a particular index in the calling
3104 * task's notification array in a manner similar to taking a counting semaphore.
3106 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
3108 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
3109 * function to be available.
3111 * Each task has a private array of "notification values" (or 'notifications'),
3112 * each of which is a 32-bit unsigned integer (uint32_t). The constant
3113 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
3114 * array, and (for backward compatibility) defaults to 1 if left undefined.
3115 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
3117 * Events can be sent to a task using an intermediary object. Examples of such
3118 * objects are queues, semaphores, mutexes and event groups. Task notifications
3119 * are a method of sending an event directly to a task without the need for such
3120 * an intermediary object.
3122 * A notification sent to a task can optionally perform an action, such as
3123 * update, overwrite or increment one of the task's notification values. In
3124 * that way task notifications can be used to send data to a task, or be used as
3125 * light weight and fast binary or counting semaphores.
3127 * ulTaskNotifyTakeIndexed() is intended for use when a task notification is
3128 * used as a faster and lighter weight binary or counting semaphore alternative.
3129 * Actual FreeRTOS semaphores are taken using the xSemaphoreTake() API function,
3130 * the equivalent action that instead uses a task notification is
3131 * ulTaskNotifyTakeIndexed().
3133 * When a task is using its notification value as a binary or counting semaphore
3134 * other tasks should send notifications to it using the xTaskNotifyGiveIndexed()
3135 * macro, or xTaskNotifyIndex() function with the eAction parameter set to
3138 * ulTaskNotifyTakeIndexed() can either clear the task's notification value at
3139 * the array index specified by the uxIndexToWaitOn parameter to zero on exit,
3140 * in which case the notification value acts like a binary semaphore, or
3141 * decrement the notification value on exit, in which case the notification
3142 * value acts like a counting semaphore.
3144 * A task can use ulTaskNotifyTakeIndexed() to [optionally] block to wait for
3145 * a notification. The task does not consume any CPU time while it is in the
3148 * Where as xTaskNotifyWaitIndexed() will return when a notification is pending,
3149 * ulTaskNotifyTakeIndexed() will return when the task's notification value is
3152 * **NOTE** Each notification within the array operates independently - a task
3153 * can only block on one notification within the array at a time and will not be
3154 * unblocked by a notification sent to any other array index.
3156 * Backward compatibility information:
3157 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
3158 * all task notification API functions operated on that value. Replacing the
3159 * single notification value with an array of notification values necessitated a
3160 * new set of API functions that could address specific notifications within the
3161 * array. ulTaskNotifyTake() is the original API function, and remains backward
3162 * compatible by always operating on the notification value at index 0 in the
3163 * array. Calling ulTaskNotifyTake() is equivalent to calling
3164 * ulTaskNotifyTakeIndexed() with the uxIndexToWaitOn parameter set to 0.
3166 * @param uxIndexToWaitOn The index within the calling task's array of
3167 * notification values on which the calling task will wait for a notification to
3168 * be non-zero. uxIndexToWaitOn must be less than
3169 * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyTake() does
3170 * not have this parameter and always waits for notifications on index 0.
3172 * @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's
3173 * notification value is decremented when the function exits. In this way the
3174 * notification value acts like a counting semaphore. If xClearCountOnExit is
3175 * not pdFALSE then the task's notification value is cleared to zero when the
3176 * function exits. In this way the notification value acts like a binary
3179 * @param xTicksToWait The maximum amount of time that the task should wait in
3180 * the Blocked state for the task's notification value to be greater than zero,
3181 * should the count not already be greater than zero when
3182 * ulTaskNotifyTake() was called. The task will not consume any processing
3183 * time while it is in the Blocked state. This is specified in kernel ticks,
3184 * the macro pdMS_TO_TICKS( value_in_ms ) can be used to convert a time
3185 * specified in milliseconds to a time specified in ticks.
3187 * @return The task's notification count before it is either cleared to zero or
3188 * decremented (see the xClearCountOnExit parameter).
3190 * \defgroup ulTaskNotifyTakeIndexed ulTaskNotifyTakeIndexed
3191 * \ingroup TaskNotifications
3193 uint32_t ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn,
3194 BaseType_t xClearCountOnExit,
3195 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
3196 #define ulTaskNotifyTake( xClearCountOnExit, xTicksToWait ) \
3197 ulTaskGenericNotifyTake( ( tskDEFAULT_INDEX_TO_NOTIFY ), ( xClearCountOnExit ), ( xTicksToWait ) )
3198 #define ulTaskNotifyTakeIndexed( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait ) \
3199 ulTaskGenericNotifyTake( ( uxIndexToWaitOn ), ( xClearCountOnExit ), ( xTicksToWait ) )
3204 * BaseType_t xTaskNotifyStateClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToCLear );
3206 * BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
3209 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
3211 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
3212 * functions to be available.
3214 * Each task has a private array of "notification values" (or 'notifications'),
3215 * each of which is a 32-bit unsigned integer (uint32_t). The constant
3216 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
3217 * array, and (for backward compatibility) defaults to 1 if left undefined.
3218 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
3220 * If a notification is sent to an index within the array of notifications then
3221 * the notification at that index is said to be 'pending' until it is read or
3222 * explicitly cleared by the receiving task. xTaskNotifyStateClearIndexed()
3223 * is the function that clears a pending notification without reading the
3224 * notification value. The notification value at the same array index is not
3225 * altered. Set xTask to NULL to clear the notification state of the calling
3228 * Backward compatibility information:
3229 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
3230 * all task notification API functions operated on that value. Replacing the
3231 * single notification value with an array of notification values necessitated a
3232 * new set of API functions that could address specific notifications within the
3233 * array. xTaskNotifyStateClear() is the original API function, and remains
3234 * backward compatible by always operating on the notification value at index 0
3235 * within the array. Calling xTaskNotifyStateClear() is equivalent to calling
3236 * xTaskNotifyStateClearIndexed() with the uxIndexToNotify parameter set to 0.
3238 * @param xTask The handle of the RTOS task that will have a notification state
3239 * cleared. Set xTask to NULL to clear a notification state in the calling
3240 * task. To obtain a task's handle create the task using xTaskCreate() and
3241 * make use of the pxCreatedTask parameter, or create the task using
3242 * xTaskCreateStatic() and store the returned value, or use the task's name in
3243 * a call to xTaskGetHandle().
3245 * @param uxIndexToClear The index within the target task's array of
3246 * notification values to act upon. For example, setting uxIndexToClear to 1
3247 * will clear the state of the notification at index 1 within the array.
3248 * uxIndexToClear must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
3249 * ulTaskNotifyStateClear() does not have this parameter and always acts on the
3250 * notification at index 0.
3252 * @return pdTRUE if the task's notification state was set to
3253 * eNotWaitingNotification, otherwise pdFALSE.
3255 * \defgroup xTaskNotifyStateClearIndexed xTaskNotifyStateClearIndexed
3256 * \ingroup TaskNotifications
3258 BaseType_t xTaskGenericNotifyStateClear( TaskHandle_t xTask,
3259 UBaseType_t uxIndexToClear ) PRIVILEGED_FUNCTION;
3260 #define xTaskNotifyStateClear( xTask ) \
3261 xTaskGenericNotifyStateClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ) )
3262 #define xTaskNotifyStateClearIndexed( xTask, uxIndexToClear ) \
3263 xTaskGenericNotifyStateClear( ( xTask ), ( uxIndexToClear ) )
3268 * uint32_t ulTaskNotifyValueClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear );
3270 * uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear );
3273 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
3275 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
3276 * functions to be available.
3278 * Each task has a private array of "notification values" (or 'notifications'),
3279 * each of which is a 32-bit unsigned integer (uint32_t). The constant
3280 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
3281 * array, and (for backward compatibility) defaults to 1 if left undefined.
3282 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
3284 * ulTaskNotifyValueClearIndexed() clears the bits specified by the
3285 * ulBitsToClear bit mask in the notification value at array index uxIndexToClear
3286 * of the task referenced by xTask.
3288 * Backward compatibility information:
3289 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
3290 * all task notification API functions operated on that value. Replacing the
3291 * single notification value with an array of notification values necessitated a
3292 * new set of API functions that could address specific notifications within the
3293 * array. ulTaskNotifyValueClear() is the original API function, and remains
3294 * backward compatible by always operating on the notification value at index 0
3295 * within the array. Calling ulTaskNotifyValueClear() is equivalent to calling
3296 * ulTaskNotifyValueClearIndexed() with the uxIndexToClear parameter set to 0.
3298 * @param xTask The handle of the RTOS task that will have bits in one of its
3299 * notification values cleared. Set xTask to NULL to clear bits in a
3300 * notification value of the calling task. To obtain a task's handle create the
3301 * task using xTaskCreate() and make use of the pxCreatedTask parameter, or
3302 * create the task using xTaskCreateStatic() and store the returned value, or
3303 * use the task's name in a call to xTaskGetHandle().
3305 * @param uxIndexToClear The index within the target task's array of
3306 * notification values in which to clear the bits. uxIndexToClear
3307 * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
3308 * ulTaskNotifyValueClear() does not have this parameter and always clears bits
3309 * in the notification value at index 0.
3311 * @param ulBitsToClear Bit mask of the bits to clear in the notification value of
3312 * xTask. Set a bit to 1 to clear the corresponding bits in the task's notification
3313 * value. Set ulBitsToClear to 0xffffffff (UINT_MAX on 32-bit architectures) to clear
3314 * the notification value to 0. Set ulBitsToClear to 0 to query the task's
3315 * notification value without clearing any bits.
3318 * @return The value of the target task's notification value before the bits
3319 * specified by ulBitsToClear were cleared.
3320 * \defgroup ulTaskNotifyValueClear ulTaskNotifyValueClear
3321 * \ingroup TaskNotifications
3323 uint32_t ulTaskGenericNotifyValueClear( TaskHandle_t xTask,
3324 UBaseType_t uxIndexToClear,
3325 uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
3326 #define ulTaskNotifyValueClear( xTask, ulBitsToClear ) \
3327 ulTaskGenericNotifyValueClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulBitsToClear ) )
3328 #define ulTaskNotifyValueClearIndexed( xTask, uxIndexToClear, ulBitsToClear ) \
3329 ulTaskGenericNotifyValueClear( ( xTask ), ( uxIndexToClear ), ( ulBitsToClear ) )
3334 * void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut );
3337 * Capture the current time for future use with xTaskCheckForTimeOut().
3339 * @param pxTimeOut Pointer to a timeout object into which the current time
3340 * is to be captured. The captured time includes the tick count and the number
3341 * of times the tick count has overflowed since the system first booted.
3342 * \defgroup vTaskSetTimeOutState vTaskSetTimeOutState
3345 void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
3350 * BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait );
3353 * Determines if pxTicksToWait ticks has passed since a time was captured
3354 * using a call to vTaskSetTimeOutState(). The captured time includes the tick
3355 * count and the number of times the tick count has overflowed.
3357 * @param pxTimeOut The time status as captured previously using
3358 * vTaskSetTimeOutState. If the timeout has not yet occurred, it is updated
3359 * to reflect the current time status.
3360 * @param pxTicksToWait The number of ticks to check for timeout i.e. if
3361 * pxTicksToWait ticks have passed since pxTimeOut was last updated (either by
3362 * vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred.
3363 * If the timeout has not occurred, pxTicksToWait is updated to reflect the
3364 * number of remaining ticks.
3366 * @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is
3367 * returned and pxTicksToWait is updated to reflect the number of remaining
3370 * @see https://www.FreeRTOS.org/xTaskCheckForTimeOut.html
3374 * // Driver library function used to receive uxWantedBytes from an Rx buffer
3375 * // that is filled by a UART interrupt. If there are not enough bytes in the
3376 * // Rx buffer then the task enters the Blocked state until it is notified that
3377 * // more data has been placed into the buffer. If there is still not enough
3378 * // data then the task re-enters the Blocked state, and xTaskCheckForTimeOut()
3379 * // is used to re-calculate the Block time to ensure the total amount of time
3380 * // spent in the Blocked state does not exceed MAX_TIME_TO_WAIT. This
3381 * // continues until either the buffer contains at least uxWantedBytes bytes,
3382 * // or the total amount of time spent in the Blocked state reaches
3383 * // MAX_TIME_TO_WAIT - at which point the task reads however many bytes are
3384 * // available up to a maximum of uxWantedBytes.
3386 * size_t xUART_Receive( uint8_t *pucBuffer, size_t uxWantedBytes )
3388 * size_t uxReceived = 0;
3389 * TickType_t xTicksToWait = MAX_TIME_TO_WAIT;
3390 * TimeOut_t xTimeOut;
3392 * // Initialize xTimeOut. This records the time at which this function
3394 * vTaskSetTimeOutState( &xTimeOut );
3396 * // Loop until the buffer contains the wanted number of bytes, or a
3397 * // timeout occurs.
3398 * while( UART_bytes_in_rx_buffer( pxUARTInstance ) < uxWantedBytes )
3400 * // The buffer didn't contain enough data so this task is going to
3401 * // enter the Blocked state. Adjusting xTicksToWait to account for
3402 * // any time that has been spent in the Blocked state within this
3403 * // function so far to ensure the total amount of time spent in the
3404 * // Blocked state does not exceed MAX_TIME_TO_WAIT.
3405 * if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) != pdFALSE )
3407 * //Timed out before the wanted number of bytes were available,
3412 * // Wait for a maximum of xTicksToWait ticks to be notified that the
3413 * // receive interrupt has placed more data into the buffer.
3414 * ulTaskNotifyTake( pdTRUE, xTicksToWait );
3417 * // Attempt to read uxWantedBytes from the receive buffer into pucBuffer.
3418 * // The actual number of bytes read (which might be less than
3419 * // uxWantedBytes) is returned.
3420 * uxReceived = UART_read_from_receive_buffer( pxUARTInstance,
3424 * return uxReceived;
3427 * \defgroup xTaskCheckForTimeOut xTaskCheckForTimeOut
3430 BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut,
3431 TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;
3436 * BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp );
3439 * This function corrects the tick count value after the application code has held
3440 * interrupts disabled for an extended period resulting in tick interrupts having
3443 * This function is similar to vTaskStepTick(), however, unlike
3444 * vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a
3445 * time at which a task should be removed from the blocked state. That means
3446 * tasks may have to be removed from the blocked state as the tick count is
3449 * @param xTicksToCatchUp The number of tick interrupts that have been missed due to
3450 * interrupts being disabled. Its value is not computed automatically, so must be
3451 * computed by the application writer.
3453 * @return pdTRUE if moving the tick count forward resulted in a task leaving the
3454 * blocked state and a context switch being performed. Otherwise pdFALSE.
3456 * \defgroup xTaskCatchUpTicks xTaskCatchUpTicks
3459 BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION;
3464 * void vTaskResetState( void );
3467 * This function resets the internal state of the task. It must be called by the
3468 * application before restarting the scheduler.
3470 * \defgroup vTaskResetState vTaskResetState
3471 * \ingroup SchedulerControl
3473 void vTaskResetState( void ) PRIVILEGED_FUNCTION;
3476 /*-----------------------------------------------------------
3477 * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
3478 *----------------------------------------------------------*/
3480 #if ( configNUMBER_OF_CORES == 1 )
3481 #define taskYIELD_WITHIN_API() portYIELD_WITHIN_API()
3482 #else /* #if ( configNUMBER_OF_CORES == 1 ) */
3483 #define taskYIELD_WITHIN_API() vTaskYieldWithinAPI()
3484 #endif /* #if ( configNUMBER_OF_CORES == 1 ) */
3487 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
3488 * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
3489 * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
3491 * Called from the real time kernel tick (either preemptive or cooperative),
3492 * this increments the tick count and checks if any tasks that are blocked
3493 * for a finite period required removing from a blocked list and placing on
3494 * a ready list. If a non-zero value is returned then a context switch is
3495 * required because either:
3496 * + A task was removed from a blocked list because its timeout had expired,
3498 * + Time slicing is in use and there is a task of equal priority to the
3499 * currently running task.
3501 BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;
3504 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
3505 * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
3507 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
3509 * Removes the calling task from the ready list and places it both
3510 * on the list of tasks waiting for a particular event, and the
3511 * list of delayed tasks. The task will be removed from both lists
3512 * and replaced on the ready list should either the event occur (and
3513 * there be no higher priority tasks waiting on the same event) or
3514 * the delay period expires.
3516 * The 'unordered' version replaces the event list item value with the
3517 * xItemValue value, and inserts the list item at the end of the list.
3519 * The 'ordered' version uses the existing event list item value (which is the
3520 * owning task's priority) to insert the list item into the event list in task
3523 * @param pxEventList The list containing tasks that are blocked waiting
3524 * for the event to occur.
3526 * @param xItemValue The item value to use for the event list item when the
3527 * event list is not ordered by task priority.
3529 * @param xTicksToWait The maximum amount of time that the task should wait
3530 * for the event to occur. This is specified in kernel ticks, the constant
3531 * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time
3534 void vTaskPlaceOnEventList( List_t * const pxEventList,
3535 const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
3536 void vTaskPlaceOnUnorderedEventList( List_t * pxEventList,
3537 const TickType_t xItemValue,
3538 const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
3541 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
3542 * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
3544 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
3546 * This function performs nearly the same function as vTaskPlaceOnEventList().
3547 * The difference being that this function does not permit tasks to block
3548 * indefinitely, whereas vTaskPlaceOnEventList() does.
3551 void vTaskPlaceOnEventListRestricted( List_t * const pxEventList,
3552 TickType_t xTicksToWait,
3553 const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;
3556 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
3557 * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
3559 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
3561 * Removes a task from both the specified event list and the list of blocked
3562 * tasks, and places it on a ready queue.
3564 * xTaskRemoveFromEventList()/vTaskRemoveFromUnorderedEventList() will be called
3565 * if either an event occurs to unblock a task, or the block timeout period
3568 * xTaskRemoveFromEventList() is used when the event list is in task priority
3569 * order. It removes the list item from the head of the event list as that will
3570 * have the highest priority owning task of all the tasks on the event list.
3571 * vTaskRemoveFromUnorderedEventList() is used when the event list is not
3572 * ordered and the event list items hold something other than the owning tasks
3573 * priority. In this case the event list item value is updated to the value
3574 * passed in the xItemValue parameter.
3576 * @return pdTRUE if the task being removed has a higher priority than the task
3577 * making the call, otherwise pdFALSE.
3579 BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION;
3580 void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem,
3581 const TickType_t xItemValue ) PRIVILEGED_FUNCTION;
3584 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
3585 * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
3586 * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
3588 * Sets the pointer to the current TCB to the TCB of the highest priority task
3589 * that is ready to run.
3591 #if ( configNUMBER_OF_CORES == 1 )
3592 portDONT_DISCARD void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;
3594 portDONT_DISCARD void vTaskSwitchContext( BaseType_t xCoreID ) PRIVILEGED_FUNCTION;
3598 * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY
3599 * THE EVENT BITS MODULE.
3601 TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION;
3604 * Return the handle of the calling task.
3606 TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;
3609 * Return the handle of the task running on specified core.
3611 TaskHandle_t xTaskGetCurrentTaskHandleForCore( BaseType_t xCoreID ) PRIVILEGED_FUNCTION;
3614 * Shortcut used by the queue implementation to prevent unnecessary call to
3617 void vTaskMissedYield( void ) PRIVILEGED_FUNCTION;
3620 * Returns the scheduler state as taskSCHEDULER_RUNNING,
3621 * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.
3623 BaseType_t xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION;
3626 * Raises the priority of the mutex holder to that of the calling task should
3627 * the mutex holder have a priority less than the calling task.
3629 BaseType_t xTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
3632 * Set the priority of a task back to its proper priority in the case that it
3633 * inherited a higher priority while it was holding a semaphore.
3635 BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
3638 * If a higher priority task attempting to obtain a mutex caused a lower
3639 * priority task to inherit the higher priority task's priority - but the higher
3640 * priority task then timed out without obtaining the mutex, then the lower
3641 * priority task will disinherit the priority again - but only down as far as
3642 * the highest priority task that is still waiting for the mutex (if there were
3643 * more than one task waiting for the mutex).
3645 void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder,
3646 UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION;
3649 * Get the uxTaskNumber assigned to the task referenced by the xTask parameter.
3651 #if ( configUSE_TRACE_FACILITY == 1 )
3652 UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
3656 * Set the uxTaskNumber of the task referenced by the xTask parameter to
3659 #if ( configUSE_TRACE_FACILITY == 1 )
3660 void vTaskSetTaskNumber( TaskHandle_t xTask,
3661 const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION;
3665 * Only available when configUSE_TICKLESS_IDLE is set to 1.
3666 * If tickless mode is being used, or a low power mode is implemented, then
3667 * the tick interrupt will not execute during idle periods. When this is the
3668 * case, the tick count value maintained by the scheduler needs to be kept up
3669 * to date with the actual execution time by being skipped forward by a time
3670 * equal to the idle period.
3672 #if ( configUSE_TICKLESS_IDLE != 0 )
3673 void vTaskStepTick( TickType_t xTicksToJump ) PRIVILEGED_FUNCTION;
3677 * Only available when configUSE_TICKLESS_IDLE is set to 1.
3678 * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port
3679 * specific sleep function to determine if it is ok to proceed with the sleep,
3680 * and if it is ok to proceed, if it is ok to sleep indefinitely.
3682 * This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only
3683 * called with the scheduler suspended, not from within a critical section. It
3684 * is therefore possible for an interrupt to request a context switch between
3685 * portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being
3686 * entered. eTaskConfirmSleepModeStatus() should be called from a short
3687 * critical section between the timer being stopped and the sleep mode being
3688 * entered to ensure it is ok to proceed into the sleep mode.
3690 #if ( configUSE_TICKLESS_IDLE != 0 )
3691 eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;
3695 * For internal use only. Increment the mutex held count when a mutex is
3696 * taken and return the handle of the task that has taken the mutex.
3698 TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;
3701 * For internal use only. Same as vTaskSetTimeOutState(), but without a critical
3704 void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
3707 * For internal use only. Same as portYIELD_WITHIN_API() in single core FreeRTOS.
3708 * For SMP this is not defined by the port.
3710 #if ( configNUMBER_OF_CORES > 1 )
3711 void vTaskYieldWithinAPI( void );
3715 * This function is only intended for use when implementing a port of the scheduler
3716 * and is only available when portCRITICAL_NESTING_IN_TCB is set to 1 or configNUMBER_OF_CORES
3717 * is greater than 1. This function can be used in the implementation of portENTER_CRITICAL
3718 * if port wants to maintain critical nesting count in TCB in single core FreeRTOS.
3719 * It should be used in the implementation of portENTER_CRITICAL if port is running a
3720 * multiple core FreeRTOS.
3722 #if ( ( portCRITICAL_NESTING_IN_TCB == 1 ) || ( configNUMBER_OF_CORES > 1 ) )
3723 void vTaskEnterCritical( void );
3727 * This function is only intended for use when implementing a port of the scheduler
3728 * and is only available when portCRITICAL_NESTING_IN_TCB is set to 1 or configNUMBER_OF_CORES
3729 * is greater than 1. This function can be used in the implementation of portEXIT_CRITICAL
3730 * if port wants to maintain critical nesting count in TCB in single core FreeRTOS.
3731 * It should be used in the implementation of portEXIT_CRITICAL if port is running a
3732 * multiple core FreeRTOS.
3734 #if ( ( portCRITICAL_NESTING_IN_TCB == 1 ) || ( configNUMBER_OF_CORES > 1 ) )
3735 void vTaskExitCritical( void );
3739 * This function is only intended for use when implementing a port of the scheduler
3740 * and is only available when configNUMBER_OF_CORES is greater than 1. This function
3741 * should be used in the implementation of portENTER_CRITICAL_FROM_ISR if port is
3742 * running a multiple core FreeRTOS.
3744 #if ( configNUMBER_OF_CORES > 1 )
3745 UBaseType_t vTaskEnterCriticalFromISR( void );
3749 * This function is only intended for use when implementing a port of the scheduler
3750 * and is only available when configNUMBER_OF_CORES is greater than 1. This function
3751 * should be used in the implementation of portEXIT_CRITICAL_FROM_ISR if port is
3752 * running a multiple core FreeRTOS.
3754 #if ( configNUMBER_OF_CORES > 1 )
3755 void vTaskExitCriticalFromISR( UBaseType_t uxSavedInterruptStatus );
3758 #if ( portUSING_MPU_WRAPPERS == 1 )
3761 * For internal use only. Get MPU settings associated with a task.
3763 xMPU_SETTINGS * xTaskGetMPUSettings( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
3765 #endif /* portUSING_MPU_WRAPPERS */
3768 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) && ( configENABLE_ACCESS_CONTROL_LIST == 1 ) )
3771 * For internal use only. Grant/Revoke a task's access to a kernel object.
3773 void vGrantAccessToKernelObject( TaskHandle_t xExternalTaskHandle,
3774 int32_t lExternalKernelObjectHandle ) PRIVILEGED_FUNCTION;
3775 void vRevokeAccessToKernelObject( TaskHandle_t xExternalTaskHandle,
3776 int32_t lExternalKernelObjectHandle ) PRIVILEGED_FUNCTION;
3779 * For internal use only. Grant/Revoke a task's access to a kernel object.
3781 void vPortGrantAccessToKernelObject( TaskHandle_t xInternalTaskHandle,
3782 int32_t lInternalIndexOfKernelObject ) PRIVILEGED_FUNCTION;
3783 void vPortRevokeAccessToKernelObject( TaskHandle_t xInternalTaskHandle,
3784 int32_t lInternalIndexOfKernelObject ) PRIVILEGED_FUNCTION;
3786 #endif /* #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) && ( configENABLE_ACCESS_CONTROL_LIST == 1 ) ) */
3793 #endif /* INC_TASK_H */