2 * FreeRTOS Kernel V10.4.3
3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * https://www.FreeRTOS.org
23 * https://github.com/FreeRTOS
31 #ifndef INC_FREERTOS_H
32 #error "include FreeRTOS.h must appear in source files before include task.h"
43 /*-----------------------------------------------------------
44 * MACROS AND DEFINITIONS
45 *----------------------------------------------------------*/
47 #define tskKERNEL_VERSION_NUMBER "V10.4.3"
48 #define tskKERNEL_VERSION_MAJOR 10
49 #define tskKERNEL_VERSION_MINOR 4
50 #define tskKERNEL_VERSION_BUILD 3
52 /* MPU region parameters passed in ulParameters
53 * of MemoryRegion_t struct. */
54 #define tskMPU_REGION_READ_ONLY ( 1UL << 0UL )
55 #define tskMPU_REGION_READ_WRITE ( 1UL << 1UL )
56 #define tskMPU_REGION_EXECUTE_NEVER ( 1UL << 2UL )
57 #define tskMPU_REGION_NORMAL_MEMORY ( 1UL << 3UL )
58 #define tskMPU_REGION_DEVICE_MEMORY ( 1UL << 4UL )
60 /* The direct to task notification feature used to have only a single notification
61 * per task. Now there is an array of notifications per task that is dimensioned by
62 * configTASK_NOTIFICATION_ARRAY_ENTRIES. For backward compatibility, any use of the
63 * original direct to task notification defaults to using the first index in the
65 #define tskDEFAULT_INDEX_TO_NOTIFY ( 0 )
70 * Type by which tasks are referenced. For example, a call to xTaskCreate
71 * returns (via a pointer parameter) an TaskHandle_t variable that can then
72 * be used as a parameter to vTaskDelete to delete the task.
74 * \defgroup TaskHandle_t TaskHandle_t
77 struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */
78 typedef struct tskTaskControlBlock * TaskHandle_t;
81 * Defines the prototype to which the application task hook function must
84 typedef BaseType_t (* TaskHookFunction_t)( void * );
86 /* Task states returned by eTaskGetState. */
89 eRunning = 0, /* A task is querying the state of itself, so must be running. */
90 eReady, /* The task being queried is in a ready or pending ready list. */
91 eBlocked, /* The task being queried is in the Blocked state. */
92 eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */
93 eDeleted, /* The task being queried has been deleted, but its TCB has not yet been freed. */
94 eInvalid /* Used as an 'invalid state' value. */
97 /* Actions that can be performed when vTaskNotify() is called. */
100 eNoAction = 0, /* Notify the task without updating its notify value. */
101 eSetBits, /* Set bits in the task's notification value. */
102 eIncrement, /* Increment the task's notification value. */
103 eSetValueWithOverwrite, /* Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */
104 eSetValueWithoutOverwrite /* Set the task's notification value if the previous value has been read by the task. */
108 * Used internally only.
110 typedef struct xTIME_OUT
112 BaseType_t xOverflowCount;
113 TickType_t xTimeOnEntering;
117 * Defines the memory ranges allocated to the task when an MPU is used.
119 typedef struct xMEMORY_REGION
121 void * pvBaseAddress;
122 uint32_t ulLengthInBytes;
123 uint32_t ulParameters;
127 * Parameters required to create an MPU protected task.
129 typedef struct xTASK_PARAMETERS
131 TaskFunction_t pvTaskCode;
132 const char * pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
133 configSTACK_DEPTH_TYPE usStackDepth;
135 UBaseType_t uxPriority;
136 StackType_t * puxStackBuffer;
137 MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ];
138 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
139 StaticTask_t * const pxTaskBuffer;
143 /* Used with the uxTaskGetSystemState() function to return the state of each task
145 typedef struct xTASK_STATUS
147 TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */
148 const char * pcTaskName; /* A pointer to the task's name. This value will be invalid if the task was deleted since the structure was populated! */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
149 UBaseType_t xTaskNumber; /* A number unique to the task. */
150 eTaskState eCurrentState; /* The state in which the task existed when the structure was populated. */
151 UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */
152 UBaseType_t uxBasePriority; /* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */
153 uint32_t ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock. See https://www.FreeRTOS.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */
154 StackType_t * pxStackBase; /* Points to the lowest address of the task's stack area. */
155 configSTACK_DEPTH_TYPE usStackHighWaterMark; /* The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */
158 /* Possible return values for eTaskConfirmSleepModeStatus(). */
161 eAbortSleep = 0, /* A task has been made ready or a context switch pended since portSUPPRESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */
162 eStandardSleep, /* Enter a sleep mode that will not last any longer than the expected idle time. */
163 eNoTasksWaitingTimeout /* No tasks are waiting for a timeout so it is safe to enter a sleep mode that can only be exited by an external interrupt. */
167 * Defines the priority used by the idle task. This must not be modified.
171 #define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U )
176 * Macro for forcing a context switch.
178 * \defgroup taskYIELD taskYIELD
179 * \ingroup SchedulerControl
181 #define taskYIELD() portYIELD()
186 * Macro to mark the start of a critical code region. Preemptive context
187 * switches cannot occur when in a critical region.
189 * NOTE: This may alter the stack (depending on the portable implementation)
190 * so must be used with care!
192 * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL
193 * \ingroup SchedulerControl
195 #define taskENTER_CRITICAL() portENTER_CRITICAL()
196 #define taskENTER_CRITICAL_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()
201 * Macro to mark the end of a critical code region. Preemptive context
202 * switches cannot occur when in a critical region.
204 * NOTE: This may alter the stack (depending on the portable implementation)
205 * so must be used with care!
207 * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL
208 * \ingroup SchedulerControl
210 #define taskEXIT_CRITICAL() portEXIT_CRITICAL()
211 #define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x )
216 * Macro to disable all maskable interrupts.
217 * This also returns what the interrupt state was
218 * upon being called. This state may subsequently
219 * be passed to taskRESTORE_INTERRUPTS().
221 * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS
222 * \ingroup SchedulerControl
224 #define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS()
229 * Macro to enable microcontroller interrupts.
231 * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS
232 * \ingroup SchedulerControl
234 #define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS()
239 * Macro to restore microcontroller interrupts to
242 * \defgroup taskRESTORE_INTERRUPTS taskRESTORE_INTERRUPTS
243 * \ingroup SchedulerControl
245 #define taskRESTORE_INTERRUPTS(ulState) portRESTORE_INTERRUPTS(ulState)
250 * Macro that determines if it is being called from within an ISR
251 * or a task. Returns non-zero if it is in an ISR.
253 * \defgroup taskCHECK_IF_IN_ISR taskCHECK_IF_IN_ISR
254 * \ingroup SchedulerControl
256 #define taskCHECK_IF_IN_ISR() portCHECK_IF_IN_ISR()
258 /* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is
259 * 0 to generate more optimal code when configASSERT() is defined as the constant
260 * is used in assert() statements. */
261 #define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 )
262 #define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 )
263 #define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 )
265 /* Check if core value is valid */
266 #define taskVALID_CORE_ID( xCoreID ) ( ( BaseType_t ) ( ( 0 <= xCoreID ) && ( xCoreID < configNUM_CORES ) ) )
268 /*-----------------------------------------------------------
270 *----------------------------------------------------------*/
275 * BaseType_t xTaskCreate(
276 * TaskFunction_t pxTaskCode,
277 * const char *pcName,
278 * configSTACK_DEPTH_TYPE usStackDepth,
279 * void *pvParameters,
280 * UBaseType_t uxPriority,
281 * TaskHandle_t *pxCreatedTask
285 * Create a new task and add it to the list of tasks that are ready to run.
287 * Internally, within the FreeRTOS implementation, tasks use two blocks of
288 * memory. The first block is used to hold the task's data structures. The
289 * second block is used by the task as its stack. If a task is created using
290 * xTaskCreate() then both blocks of memory are automatically dynamically
291 * allocated inside the xTaskCreate() function. (see
292 * https://www.FreeRTOS.org/a00111.html). If a task is created using
293 * xTaskCreateStatic() then the application writer must provide the required
294 * memory. xTaskCreateStatic() therefore allows a task to be created without
295 * using any dynamic memory allocation.
297 * See xTaskCreateStatic() for a version that does not use any dynamic memory
300 * xTaskCreate() can only be used to create a task that has unrestricted
301 * access to the entire microcontroller memory map. Systems that include MPU
302 * support can alternatively create an MPU constrained task using
303 * xTaskCreateRestricted().
305 * @param pxTaskCode Pointer to the task entry function. Tasks
306 * must be implemented to never return (i.e. continuous loop).
308 * @param pcName A descriptive name for the task. This is mainly used to
309 * facilitate debugging. Max length defined by configMAX_TASK_NAME_LEN - default
312 * @param usStackDepth The size of the task stack specified as the number of
313 * variables the stack can hold - not the number of bytes. For example, if
314 * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes
315 * will be allocated for stack storage.
317 * @param pvParameters Pointer that will be used as the parameter for the task
320 * @param uxPriority The priority at which the task should run. Systems that
321 * include MPU support can optionally create tasks in a privileged (system)
322 * mode by setting bit portPRIVILEGE_BIT of the priority parameter. For
323 * example, to create a privileged task at priority 2 the uxPriority parameter
324 * should be set to ( 2 | portPRIVILEGE_BIT ).
326 * @param pxCreatedTask Used to pass back a handle by which the created task
329 * @return pdPASS if the task was successfully created and added to a ready
330 * list, otherwise an error code defined in the file projdefs.h
334 * // Task to be created.
335 * void vTaskCode( void * pvParameters )
339 * // Task code goes here.
343 * // Function that creates a task.
344 * void vOtherFunction( void )
346 * static uint8_t ucParameterToPass;
347 * TaskHandle_t xHandle = NULL;
349 * // Create the task, storing the handle. Note that the passed parameter ucParameterToPass
350 * // must exist for the lifetime of the task, so in this case is declared static. If it was just an
351 * // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time
352 * // the new task attempts to access it.
353 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
354 * configASSERT( xHandle );
356 * // Use the handle to delete the task.
357 * if( xHandle != NULL )
359 * vTaskDelete( xHandle );
363 * \defgroup xTaskCreate xTaskCreate
366 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
367 BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
368 const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
369 const configSTACK_DEPTH_TYPE usStackDepth,
370 void * const pvParameters,
371 UBaseType_t uxPriority,
372 TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
378 * TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
379 * const char *pcName,
380 * uint32_t ulStackDepth,
381 * void *pvParameters,
382 * UBaseType_t uxPriority,
383 * StackType_t *puxStackBuffer,
384 * StaticTask_t *pxTaskBuffer );
387 * Create a new task and add it to the list of tasks that are ready to run.
389 * Internally, within the FreeRTOS implementation, tasks use two blocks of
390 * memory. The first block is used to hold the task's data structures. The
391 * second block is used by the task as its stack. If a task is created using
392 * xTaskCreate() then both blocks of memory are automatically dynamically
393 * allocated inside the xTaskCreate() function. (see
394 * https://www.FreeRTOS.org/a00111.html). If a task is created using
395 * xTaskCreateStatic() then the application writer must provide the required
396 * memory. xTaskCreateStatic() therefore allows a task to be created without
397 * using any dynamic memory allocation.
399 * @param pxTaskCode Pointer to the task entry function. Tasks
400 * must be implemented to never return (i.e. continuous loop).
402 * @param pcName A descriptive name for the task. This is mainly used to
403 * facilitate debugging. The maximum length of the string is defined by
404 * configMAX_TASK_NAME_LEN in FreeRTOSConfig.h.
406 * @param ulStackDepth The size of the task stack specified as the number of
407 * variables the stack can hold - not the number of bytes. For example, if
408 * the stack is 32-bits wide and ulStackDepth is defined as 100 then 400 bytes
409 * will be allocated for stack storage.
411 * @param pvParameters Pointer that will be used as the parameter for the task
414 * @param uxPriority The priority at which the task will run.
416 * @param puxStackBuffer Must point to a StackType_t array that has at least
417 * ulStackDepth indexes - the array will then be used as the task's stack,
418 * removing the need for the stack to be allocated dynamically.
420 * @param pxTaskBuffer Must point to a variable of type StaticTask_t, which will
421 * then be used to hold the task's data structures, removing the need for the
422 * memory to be allocated dynamically.
424 * @return If neither puxStackBuffer nor pxTaskBuffer are NULL, then the task
425 * will be created and a handle to the created task is returned. If either
426 * puxStackBuffer or pxTaskBuffer are NULL then the task will not be created and
432 * // Dimensions of the buffer that the task being created will use as its stack.
433 * // NOTE: This is the number of words the stack will hold, not the number of
434 * // bytes. For example, if each stack item is 32-bits, and this is set to 100,
435 * // then 400 bytes (100 * 32-bits) will be allocated.
436 #define STACK_SIZE 200
438 * // Structure that will hold the TCB of the task being created.
439 * StaticTask_t xTaskBuffer;
441 * // Buffer that the task being created will use as its stack. Note this is
442 * // an array of StackType_t variables. The size of StackType_t is dependent on
444 * StackType_t xStack[ STACK_SIZE ];
446 * // Function that implements the task being created.
447 * void vTaskCode( void * pvParameters )
449 * // The parameter value is expected to be 1 as 1 is passed in the
450 * // pvParameters value in the call to xTaskCreateStatic().
451 * configASSERT( ( uint32_t ) pvParameters == 1UL );
455 * // Task code goes here.
459 * // Function that creates a task.
460 * void vOtherFunction( void )
462 * TaskHandle_t xHandle = NULL;
464 * // Create the task without using any dynamic memory allocation.
465 * xHandle = xTaskCreateStatic(
466 * vTaskCode, // Function that implements the task.
467 * "NAME", // Text name for the task.
468 * STACK_SIZE, // Stack size in words, not bytes.
469 * ( void * ) 1, // Parameter passed into the task.
470 * tskIDLE_PRIORITY,// Priority at which the task is created.
471 * xStack, // Array to use as the task's stack.
472 * &xTaskBuffer ); // Variable to hold the task's data structure.
474 * // puxStackBuffer and pxTaskBuffer were not NULL, so the task will have
475 * // been created, and xHandle will be the task's handle. Use the handle
476 * // to suspend the task.
477 * vTaskSuspend( xHandle );
480 * \defgroup xTaskCreateStatic xTaskCreateStatic
483 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
484 TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
485 const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
486 const uint32_t ulStackDepth,
487 void * const pvParameters,
488 UBaseType_t uxPriority,
489 StackType_t * const puxStackBuffer,
490 StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION;
491 #endif /* configSUPPORT_STATIC_ALLOCATION */
496 * BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
499 * Only available when configSUPPORT_DYNAMIC_ALLOCATION is set to 1.
501 * xTaskCreateRestricted() should only be used in systems that include an MPU
504 * Create a new task and add it to the list of tasks that are ready to run.
505 * The function parameters define the memory regions and associated access
506 * permissions allocated to the task.
508 * See xTaskCreateRestrictedStatic() for a version that does not use any
509 * dynamic memory allocation.
511 * @param pxTaskDefinition Pointer to a structure that contains a member
512 * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
513 * documentation) plus an optional stack buffer and the memory region
516 * @param pxCreatedTask Used to pass back a handle by which the created task
519 * @return pdPASS if the task was successfully created and added to a ready
520 * list, otherwise an error code defined in the file projdefs.h
524 * // Create an TaskParameters_t structure that defines the task to be created.
525 * static const TaskParameters_t xCheckTaskParameters =
527 * vATask, // pvTaskCode - the function that implements the task.
528 * "ATask", // pcName - just a text name for the task to assist debugging.
529 * 100, // usStackDepth - the stack size DEFINED IN WORDS.
530 * NULL, // pvParameters - passed into the task function as the function parameters.
531 * ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
532 * cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
534 * // xRegions - Allocate up to three separate memory regions for access by
535 * // the task, with appropriate access permissions. Different processors have
536 * // different memory alignment requirements - refer to the FreeRTOS documentation
537 * // for full information.
539 * // Base address Length Parameters
540 * { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },
541 * { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },
542 * { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }
548 * TaskHandle_t xHandle;
550 * // Create a task from the const structure defined above. The task handle
551 * // is requested (the second parameter is not NULL) but in this case just for
552 * // demonstration purposes as its not actually used.
553 * xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
555 * // Start the scheduler.
556 * vTaskStartScheduler();
558 * // Will only get here if there was insufficient memory to create the idle
559 * // and/or timer task.
563 * \defgroup xTaskCreateRestricted xTaskCreateRestricted
566 #if ( portUSING_MPU_WRAPPERS == 1 )
567 BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition,
568 TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
574 * BaseType_t xTaskCreateRestrictedStatic( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
577 * Only available when configSUPPORT_STATIC_ALLOCATION is set to 1.
579 * xTaskCreateRestrictedStatic() should only be used in systems that include an
580 * MPU implementation.
582 * Internally, within the FreeRTOS implementation, tasks use two blocks of
583 * memory. The first block is used to hold the task's data structures. The
584 * second block is used by the task as its stack. If a task is created using
585 * xTaskCreateRestricted() then the stack is provided by the application writer,
586 * and the memory used to hold the task's data structure is automatically
587 * dynamically allocated inside the xTaskCreateRestricted() function. If a task
588 * is created using xTaskCreateRestrictedStatic() then the application writer
589 * must provide the memory used to hold the task's data structures too.
590 * xTaskCreateRestrictedStatic() therefore allows a memory protected task to be
591 * created without using any dynamic memory allocation.
593 * @param pxTaskDefinition Pointer to a structure that contains a member
594 * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
595 * documentation) plus an optional stack buffer and the memory region
596 * definitions. If configSUPPORT_STATIC_ALLOCATION is set to 1 the structure
597 * contains an additional member, which is used to point to a variable of type
598 * StaticTask_t - which is then used to hold the task's data structure.
600 * @param pxCreatedTask Used to pass back a handle by which the created task
603 * @return pdPASS if the task was successfully created and added to a ready
604 * list, otherwise an error code defined in the file projdefs.h
608 * // Create an TaskParameters_t structure that defines the task to be created.
609 * // The StaticTask_t variable is only included in the structure when
610 * // configSUPPORT_STATIC_ALLOCATION is set to 1. The PRIVILEGED_DATA macro can
611 * // be used to force the variable into the RTOS kernel's privileged data area.
612 * static PRIVILEGED_DATA StaticTask_t xTaskBuffer;
613 * static const TaskParameters_t xCheckTaskParameters =
615 * vATask, // pvTaskCode - the function that implements the task.
616 * "ATask", // pcName - just a text name for the task to assist debugging.
617 * 100, // usStackDepth - the stack size DEFINED IN WORDS.
618 * NULL, // pvParameters - passed into the task function as the function parameters.
619 * ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
620 * cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
622 * // xRegions - Allocate up to three separate memory regions for access by
623 * // the task, with appropriate access permissions. Different processors have
624 * // different memory alignment requirements - refer to the FreeRTOS documentation
625 * // for full information.
627 * // Base address Length Parameters
628 * { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },
629 * { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },
630 * { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }
633 * &xTaskBuffer; // Holds the task's data structure.
638 * TaskHandle_t xHandle;
640 * // Create a task from the const structure defined above. The task handle
641 * // is requested (the second parameter is not NULL) but in this case just for
642 * // demonstration purposes as its not actually used.
643 * xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
645 * // Start the scheduler.
646 * vTaskStartScheduler();
648 * // Will only get here if there was insufficient memory to create the idle
649 * // and/or timer task.
653 * \defgroup xTaskCreateRestrictedStatic xTaskCreateRestrictedStatic
656 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
657 BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition,
658 TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
664 * void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions );
667 * Memory regions are assigned to a restricted task when the task is created by
668 * a call to xTaskCreateRestricted(). These regions can be redefined using
669 * vTaskAllocateMPURegions().
671 * @param xTask The handle of the task being updated.
673 * @param xRegions A pointer to a MemoryRegion_t structure that contains the
674 * new memory region definitions.
678 * // Define an array of MemoryRegion_t structures that configures an MPU region
679 * // allowing read/write access for 1024 bytes starting at the beginning of the
680 * // ucOneKByte array. The other two of the maximum 3 definable regions are
681 * // unused so set to zero.
682 * static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =
684 * // Base address Length Parameters
685 * { ucOneKByte, 1024, portMPU_REGION_READ_WRITE },
690 * void vATask( void *pvParameters )
692 * // This task was created such that it has access to certain regions of
693 * // memory as defined by the MPU configuration. At some point it is
694 * // desired that these MPU regions are replaced with that defined in the
695 * // xAltRegions const struct above. Use a call to vTaskAllocateMPURegions()
696 * // for this purpose. NULL is used as the task handle to indicate that this
697 * // function should modify the MPU regions of the calling task.
698 * vTaskAllocateMPURegions( NULL, xAltRegions );
700 * // Now the task can continue its function, but from this point on can only
701 * // access its stack and the ucOneKByte array (unless any other statically
702 * // defined or shared regions have been declared elsewhere).
705 * \defgroup xTaskCreateRestricted xTaskCreateRestricted
708 void vTaskAllocateMPURegions( TaskHandle_t xTask,
709 const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION;
714 * void vTaskDelete( TaskHandle_t xTaskToDelete );
717 * INCLUDE_vTaskDelete must be defined as 1 for this function to be available.
718 * See the configuration section for more information.
720 * Remove a task from the RTOS real time kernel's management. The task being
721 * deleted will be removed from all ready, blocked, suspended and event lists.
723 * NOTE: The idle task is responsible for freeing the kernel allocated
724 * memory from tasks that have been deleted. It is therefore important that
725 * the idle task is not starved of microcontroller processing time if your
726 * application makes any calls to vTaskDelete (). Memory allocated by the
727 * task code is not automatically freed, and should be freed before the task
730 * See the demo application file death.c for sample code that utilises
733 * @param xTaskToDelete The handle of the task to be deleted. Passing NULL will
734 * cause the calling task to be deleted.
738 * void vOtherFunction( void )
740 * TaskHandle_t xHandle;
742 * // Create the task, storing the handle.
743 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
745 * // Use the handle to delete the task.
746 * vTaskDelete( xHandle );
749 * \defgroup vTaskDelete vTaskDelete
752 void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
754 /*-----------------------------------------------------------
756 *----------------------------------------------------------*/
761 * void vTaskDelay( const TickType_t xTicksToDelay );
764 * Delay a task for a given number of ticks. The actual time that the
765 * task remains blocked depends on the tick rate. The constant
766 * portTICK_PERIOD_MS can be used to calculate real time from the tick
767 * rate - with the resolution of one tick period.
769 * INCLUDE_vTaskDelay must be defined as 1 for this function to be available.
770 * See the configuration section for more information.
773 * vTaskDelay() specifies a time at which the task wishes to unblock relative to
774 * the time at which vTaskDelay() is called. For example, specifying a block
775 * period of 100 ticks will cause the task to unblock 100 ticks after
776 * vTaskDelay() is called. vTaskDelay() does not therefore provide a good method
777 * of controlling the frequency of a periodic task as the path taken through the
778 * code, as well as other task and interrupt activity, will effect the frequency
779 * at which vTaskDelay() gets called and therefore the time at which the task
780 * next executes. See xTaskDelayUntil() for an alternative API function designed
781 * to facilitate fixed frequency execution. It does this by specifying an
782 * absolute time (rather than a relative time) at which the calling task should
785 * @param xTicksToDelay The amount of time, in tick periods, that
786 * the calling task should block.
790 * void vTaskFunction( void * pvParameters )
792 * // Block for 500ms.
793 * const TickType_t xDelay = 500 / portTICK_PERIOD_MS;
797 * // Simply toggle the LED every 500ms, blocking between each toggle.
799 * vTaskDelay( xDelay );
803 * \defgroup vTaskDelay vTaskDelay
806 void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
811 * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
814 * INCLUDE_xTaskDelayUntil must be defined as 1 for this function to be available.
815 * See the configuration section for more information.
817 * Delay a task until a specified time. This function can be used by periodic
818 * tasks to ensure a constant execution frequency.
820 * This function differs from vTaskDelay () in one important aspect: vTaskDelay () will
821 * cause a task to block for the specified number of ticks from the time vTaskDelay () is
822 * called. It is therefore difficult to use vTaskDelay () by itself to generate a fixed
823 * execution frequency as the time between a task starting to execute and that task
824 * calling vTaskDelay () may not be fixed [the task may take a different path though the
825 * code between calls, or may get interrupted or preempted a different number of times
826 * each time it executes].
828 * Whereas vTaskDelay () specifies a wake time relative to the time at which the function
829 * is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to
832 * The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a
833 * time specified in milliseconds with a resolution of one tick period.
835 * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the
836 * task was last unblocked. The variable must be initialised with the current time
837 * prior to its first use (see the example below). Following this the variable is
838 * automatically updated within xTaskDelayUntil ().
840 * @param xTimeIncrement The cycle time period. The task will be unblocked at
841 * time *pxPreviousWakeTime + xTimeIncrement. Calling xTaskDelayUntil with the
842 * same xTimeIncrement parameter value will cause the task to execute with
843 * a fixed interface period.
845 * @return Value which can be used to check whether the task was actually delayed.
846 * Will be pdTRUE if the task way delayed and pdFALSE otherwise. A task will not
847 * be delayed if the next expected wake time is in the past.
851 * // Perform an action every 10 ticks.
852 * void vTaskFunction( void * pvParameters )
854 * TickType_t xLastWakeTime;
855 * const TickType_t xFrequency = 10;
856 * BaseType_t xWasDelayed;
858 * // Initialise the xLastWakeTime variable with the current time.
859 * xLastWakeTime = xTaskGetTickCount ();
862 * // Wait for the next cycle.
863 * xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency );
865 * // Perform action here. xWasDelayed value can be used to determine
866 * // whether a deadline was missed if the code here took too long.
870 * \defgroup xTaskDelayUntil xTaskDelayUntil
873 BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
874 const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
877 * vTaskDelayUntil() is the older version of xTaskDelayUntil() and does not
880 #define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ) \
882 ( void ) xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); \
889 * BaseType_t xTaskAbortDelay( TaskHandle_t xTask );
892 * INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this
893 * function to be available.
895 * A task will enter the Blocked state when it is waiting for an event. The
896 * event it is waiting for can be a temporal event (waiting for a time), such
897 * as when vTaskDelay() is called, or an event on an object, such as when
898 * xQueueReceive() or ulTaskNotifyTake() is called. If the handle of a task
899 * that is in the Blocked state is used in a call to xTaskAbortDelay() then the
900 * task will leave the Blocked state, and return from whichever function call
901 * placed the task into the Blocked state.
903 * There is no 'FromISR' version of this function as an interrupt would need to
904 * know which object a task was blocked on in order to know which actions to
905 * take. For example, if the task was blocked on a queue the interrupt handler
906 * would then need to know if the queue was locked.
908 * @param xTask The handle of the task to remove from the Blocked state.
910 * @return If the task referenced by xTask was not in the Blocked state then
911 * pdFAIL is returned. Otherwise pdPASS is returned.
913 * \defgroup xTaskAbortDelay xTaskAbortDelay
916 BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
921 * UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask );
924 * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available.
925 * See the configuration section for more information.
927 * Obtain the priority of any task.
929 * @param xTask Handle of the task to be queried. Passing a NULL
930 * handle results in the priority of the calling task being returned.
932 * @return The priority of xTask.
936 * void vAFunction( void )
938 * TaskHandle_t xHandle;
940 * // Create a task, storing the handle.
941 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
945 * // Use the handle to obtain the priority of the created task.
946 * // It was created with tskIDLE_PRIORITY, but may have changed
948 * if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
950 * // The task has changed it's priority.
955 * // Is our priority higher than the created task?
956 * if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
958 * // Our priority (obtained using NULL handle) is higher.
962 * \defgroup uxTaskPriorityGet uxTaskPriorityGet
965 UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
970 * UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask );
973 * A version of uxTaskPriorityGet() that can be used from an ISR.
975 UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
980 * eTaskState eTaskGetState( TaskHandle_t xTask );
983 * INCLUDE_eTaskGetState must be defined as 1 for this function to be available.
984 * See the configuration section for more information.
986 * Obtain the state of any task. States are encoded by the eTaskState
989 * @param xTask Handle of the task to be queried.
991 * @return The state of xTask at the time the function was called. Note the
992 * state of the task might change between the function being called, and the
993 * functions return value being tested by the calling task.
995 eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1000 * void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState );
1003 * configUSE_TRACE_FACILITY must be defined as 1 for this function to be
1004 * available. See the configuration section for more information.
1006 * Populates a TaskStatus_t structure with information about a task.
1008 * @param xTask Handle of the task being queried. If xTask is NULL then
1009 * information will be returned about the calling task.
1011 * @param pxTaskStatus A pointer to the TaskStatus_t structure that will be
1012 * filled with information about the task referenced by the handle passed using
1013 * the xTask parameter.
1015 * @xGetFreeStackSpace The TaskStatus_t structure contains a member to report
1016 * the stack high water mark of the task being queried. Calculating the stack
1017 * high water mark takes a relatively long time, and can make the system
1018 * temporarily unresponsive - so the xGetFreeStackSpace parameter is provided to
1019 * allow the high water mark checking to be skipped. The high watermark value
1020 * will only be written to the TaskStatus_t structure if xGetFreeStackSpace is
1021 * not set to pdFALSE;
1023 * @param eState The TaskStatus_t structure contains a member to report the
1024 * state of the task being queried. Obtaining the task state is not as fast as
1025 * a simple assignment - so the eState parameter is provided to allow the state
1026 * information to be omitted from the TaskStatus_t structure. To obtain state
1027 * information then set eState to eInvalid - otherwise the value passed in
1028 * eState will be reported as the task state in the TaskStatus_t structure.
1032 * void vAFunction( void )
1034 * TaskHandle_t xHandle;
1035 * TaskStatus_t xTaskDetails;
1037 * // Obtain the handle of a task from its name.
1038 * xHandle = xTaskGetHandle( "Task_Name" );
1040 * // Check the handle is not NULL.
1041 * configASSERT( xHandle );
1043 * // Use the handle to obtain further information about the task.
1044 * vTaskGetInfo( xHandle,
1046 * pdTRUE, // Include the high water mark in xTaskDetails.
1047 * eInvalid ); // Include the task state in xTaskDetails.
1050 * \defgroup vTaskGetInfo vTaskGetInfo
1053 void vTaskGetInfo( TaskHandle_t xTask,
1054 TaskStatus_t * pxTaskStatus,
1055 BaseType_t xGetFreeStackSpace,
1056 eTaskState eState ) PRIVILEGED_FUNCTION;
1061 * void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );
1064 * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.
1065 * See the configuration section for more information.
1067 * Set the priority of any task.
1069 * A context switch will occur before the function returns if the priority
1070 * being set is higher than the currently executing task.
1072 * @param xTask Handle to the task for which the priority is being set.
1073 * Passing a NULL handle results in the priority of the calling task being set.
1075 * @param uxNewPriority The priority to which the task will be set.
1079 * void vAFunction( void )
1081 * TaskHandle_t xHandle;
1083 * // Create a task, storing the handle.
1084 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1088 * // Use the handle to raise the priority of the created task.
1089 * vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
1093 * // Use a NULL handle to raise our priority to the same value.
1094 * vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
1097 * \defgroup vTaskPrioritySet vTaskPrioritySet
1100 void vTaskPrioritySet( TaskHandle_t xTask,
1101 UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
1106 * void vTaskSuspend( TaskHandle_t xTaskToSuspend );
1109 * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
1110 * See the configuration section for more information.
1112 * Suspend any task. When suspended a task will never get any microcontroller
1113 * processing time, no matter what its priority.
1115 * Calls to vTaskSuspend are not accumulative -
1116 * i.e. calling vTaskSuspend () twice on the same task still only requires one
1117 * call to vTaskResume () to ready the suspended task.
1119 * @param xTaskToSuspend Handle to the task being suspended. Passing a NULL
1120 * handle will cause the calling task to be suspended.
1124 * void vAFunction( void )
1126 * TaskHandle_t xHandle;
1128 * // Create a task, storing the handle.
1129 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1133 * // Use the handle to suspend the created task.
1134 * vTaskSuspend( xHandle );
1138 * // The created task will not run during this period, unless
1139 * // another task calls vTaskResume( xHandle ).
1144 * // Suspend ourselves.
1145 * vTaskSuspend( NULL );
1147 * // We cannot get here unless another task calls vTaskResume
1148 * // with our handle as the parameter.
1151 * \defgroup vTaskSuspend vTaskSuspend
1154 void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION;
1159 * void vTaskResume( TaskHandle_t xTaskToResume );
1162 * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
1163 * See the configuration section for more information.
1165 * Resumes a suspended task.
1167 * A task that has been suspended by one or more calls to vTaskSuspend ()
1168 * will be made available for running again by a single call to
1171 * @param xTaskToResume Handle to the task being readied.
1175 * void vAFunction( void )
1177 * TaskHandle_t xHandle;
1179 * // Create a task, storing the handle.
1180 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1184 * // Use the handle to suspend the created task.
1185 * vTaskSuspend( xHandle );
1189 * // The created task will not run during this period, unless
1190 * // another task calls vTaskResume( xHandle ).
1195 * // Resume the suspended task ourselves.
1196 * vTaskResume( xHandle );
1198 * // The created task will once again get microcontroller processing
1199 * // time in accordance with its priority within the system.
1202 * \defgroup vTaskResume vTaskResume
1205 void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
1210 * void xTaskResumeFromISR( TaskHandle_t xTaskToResume );
1213 * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be
1214 * available. See the configuration section for more information.
1216 * An implementation of vTaskResume() that can be called from within an ISR.
1218 * A task that has been suspended by one or more calls to vTaskSuspend ()
1219 * will be made available for running again by a single call to
1220 * xTaskResumeFromISR ().
1222 * xTaskResumeFromISR() should not be used to synchronise a task with an
1223 * interrupt if there is a chance that the interrupt could arrive prior to the
1224 * task being suspended - as this can lead to interrupts being missed. Use of a
1225 * semaphore as a synchronisation mechanism would avoid this eventuality.
1227 * @param xTaskToResume Handle to the task being readied.
1229 * @return pdTRUE if resuming the task should result in a context switch,
1230 * otherwise pdFALSE. This is used by the ISR to determine if a context switch
1231 * may be required following the ISR.
1233 * \defgroup vTaskResumeFromISR vTaskResumeFromISR
1236 BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
1238 void vTaskCoreExclusionSet( const TaskHandle_t xTask, UBaseType_t uxCoreExclude );
1239 UBaseType_t vTaskCoreExclusionGet( const TaskHandle_t xTask );
1241 void vTaskPreemptionDisable( const TaskHandle_t xTask );
1242 void vTaskPreemptionEnable( const TaskHandle_t xTask );
1244 /*-----------------------------------------------------------
1246 *----------------------------------------------------------*/
1251 * void vTaskStartScheduler( void );
1254 * Starts the real time kernel tick processing. After calling the kernel
1255 * has control over which tasks are executed and when.
1257 * See the demo application file main.c for an example of creating
1258 * tasks and starting the kernel.
1262 * void vAFunction( void )
1264 * // Create at least one task before starting the kernel.
1265 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
1267 * // Start the real time kernel with preemption.
1268 * vTaskStartScheduler ();
1270 * // Will not get here unless a task calls vTaskEndScheduler ()
1274 * \defgroup vTaskStartScheduler vTaskStartScheduler
1275 * \ingroup SchedulerControl
1277 void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;
1282 * void vTaskEndScheduler( void );
1285 * NOTE: At the time of writing only the x86 real mode port, which runs on a PC
1286 * in place of DOS, implements this function.
1288 * Stops the real time kernel tick. All created tasks will be automatically
1289 * deleted and multitasking (either preemptive or cooperative) will
1290 * stop. Execution then resumes from the point where vTaskStartScheduler ()
1291 * was called, as if vTaskStartScheduler () had just returned.
1293 * See the demo application file main. c in the demo/PC directory for an
1294 * example that uses vTaskEndScheduler ().
1296 * vTaskEndScheduler () requires an exit function to be defined within the
1297 * portable layer (see vPortEndScheduler () in port. c for the PC port). This
1298 * performs hardware specific operations such as stopping the kernel tick.
1300 * vTaskEndScheduler () will cause all of the resources allocated by the
1301 * kernel to be freed - but will not free resources allocated by application
1306 * void vTaskCode( void * pvParameters )
1310 * // Task code goes here.
1312 * // At some point we want to end the real time kernel processing
1314 * vTaskEndScheduler ();
1318 * void vAFunction( void )
1320 * // Create at least one task before starting the kernel.
1321 * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
1323 * // Start the real time kernel with preemption.
1324 * vTaskStartScheduler ();
1326 * // Will only get here when the vTaskCode () task has called
1327 * // vTaskEndScheduler (). When we get here we are back to single task
1332 * \defgroup vTaskEndScheduler vTaskEndScheduler
1333 * \ingroup SchedulerControl
1335 void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;
1340 * void vTaskSuspendAll( void );
1343 * Suspends the scheduler without disabling interrupts. Context switches will
1344 * not occur while the scheduler is suspended.
1346 * After calling vTaskSuspendAll () the calling task will continue to execute
1347 * without risk of being swapped out until a call to xTaskResumeAll () has been
1350 * API functions that have the potential to cause a context switch (for example,
1351 * xTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler
1356 * void vTask1( void * pvParameters )
1360 * // Task code goes here.
1364 * // At some point the task wants to perform a long operation during
1365 * // which it does not want to get swapped out. It cannot use
1366 * // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
1367 * // operation may cause interrupts to be missed - including the
1370 * // Prevent the real time kernel swapping out the task.
1371 * vTaskSuspendAll ();
1373 * // Perform the operation here. There is no need to use critical
1374 * // sections as we have all the microcontroller processing time.
1375 * // During this time interrupts will still operate and the kernel
1376 * // tick count will be maintained.
1380 * // The operation is complete. Restart the kernel.
1381 * xTaskResumeAll ();
1385 * \defgroup vTaskSuspendAll vTaskSuspendAll
1386 * \ingroup SchedulerControl
1388 void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;
1393 * BaseType_t xTaskResumeAll( void );
1396 * Resumes scheduler activity after it was suspended by a call to
1397 * vTaskSuspendAll().
1399 * xTaskResumeAll() only resumes the scheduler. It does not unsuspend tasks
1400 * that were previously suspended by a call to vTaskSuspend().
1402 * @return If resuming the scheduler caused a context switch then pdTRUE is
1403 * returned, otherwise pdFALSE is returned.
1407 * void vTask1( void * pvParameters )
1411 * // Task code goes here.
1415 * // At some point the task wants to perform a long operation during
1416 * // which it does not want to get swapped out. It cannot use
1417 * // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
1418 * // operation may cause interrupts to be missed - including the
1421 * // Prevent the real time kernel swapping out the task.
1422 * vTaskSuspendAll ();
1424 * // Perform the operation here. There is no need to use critical
1425 * // sections as we have all the microcontroller processing time.
1426 * // During this time interrupts will still operate and the real
1427 * // time kernel tick count will be maintained.
1431 * // The operation is complete. Restart the kernel. We want to force
1432 * // a context switch - but there is no point if resuming the scheduler
1433 * // caused a context switch already.
1434 * if( !xTaskResumeAll () )
1441 * \defgroup xTaskResumeAll xTaskResumeAll
1442 * \ingroup SchedulerControl
1444 BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION;
1446 /*-----------------------------------------------------------
1448 *----------------------------------------------------------*/
1452 * <PRE>TickType_t xTaskGetTickCount( void );</PRE>
1454 * @return The count of ticks since vTaskStartScheduler was called.
1456 * \defgroup xTaskGetTickCount xTaskGetTickCount
1457 * \ingroup TaskUtils
1459 TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;
1463 * <PRE>TickType_t xTaskGetTickCountFromISR( void );</PRE>
1465 * @return The count of ticks since vTaskStartScheduler was called.
1467 * This is a version of xTaskGetTickCount() that is safe to be called from an
1468 * ISR - provided that TickType_t is the natural word size of the
1469 * microcontroller being used or interrupt nesting is either not supported or
1472 * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR
1473 * \ingroup TaskUtils
1475 TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION;
1479 * <PRE>uint16_t uxTaskGetNumberOfTasks( void );</PRE>
1481 * @return The number of tasks that the real time kernel is currently managing.
1482 * This includes all ready, blocked and suspended tasks. A task that
1483 * has been deleted but not yet freed by the idle task will also be
1484 * included in the count.
1486 * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks
1487 * \ingroup TaskUtils
1489 UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;
1493 * <PRE>char *pcTaskGetName( TaskHandle_t xTaskToQuery );</PRE>
1495 * @return The text (human readable) name of the task referenced by the handle
1496 * xTaskToQuery. A task can query its own name by either passing in its own
1497 * handle, or by setting xTaskToQuery to NULL.
1499 * \defgroup pcTaskGetName pcTaskGetName
1500 * \ingroup TaskUtils
1502 char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1506 * <PRE>TaskHandle_t xTaskGetHandle( const char *pcNameToQuery );</PRE>
1508 * NOTE: This function takes a relatively long time to complete and should be
1511 * @return The handle of the task that has the human readable name pcNameToQuery.
1512 * NULL is returned if no matching name is found. INCLUDE_xTaskGetHandle
1513 * must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available.
1515 * \defgroup pcTaskGetHandle pcTaskGetHandle
1516 * \ingroup TaskUtils
1518 TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1522 * <PRE>UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );</PRE>
1524 * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for
1525 * this function to be available.
1527 * Returns the high water mark of the stack associated with xTask. That is,
1528 * the minimum free stack space there has been (in words, so on a 32 bit machine
1529 * a value of 1 means 4 bytes) since the task started. The smaller the returned
1530 * number the closer the task has come to overflowing its stack.
1532 * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
1533 * same except for their return type. Using configSTACK_DEPTH_TYPE allows the
1534 * user to determine the return type. It gets around the problem of the value
1535 * overflowing on 8-bit types without breaking backward compatibility for
1536 * applications that expect an 8-bit return type.
1538 * @param xTask Handle of the task associated with the stack to be checked.
1539 * Set xTask to NULL to check the stack of the calling task.
1541 * @return The smallest amount of free stack space there has been (in words, so
1542 * actual spaces on the stack rather than bytes) since the task referenced by
1543 * xTask was created.
1545 UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1549 * <PRE>configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask );</PRE>
1551 * INCLUDE_uxTaskGetStackHighWaterMark2 must be set to 1 in FreeRTOSConfig.h for
1552 * this function to be available.
1554 * Returns the high water mark of the stack associated with xTask. That is,
1555 * the minimum free stack space there has been (in words, so on a 32 bit machine
1556 * a value of 1 means 4 bytes) since the task started. The smaller the returned
1557 * number the closer the task has come to overflowing its stack.
1559 * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
1560 * same except for their return type. Using configSTACK_DEPTH_TYPE allows the
1561 * user to determine the return type. It gets around the problem of the value
1562 * overflowing on 8-bit types without breaking backward compatibility for
1563 * applications that expect an 8-bit return type.
1565 * @param xTask Handle of the task associated with the stack to be checked.
1566 * Set xTask to NULL to check the stack of the calling task.
1568 * @return The smallest amount of free stack space there has been (in words, so
1569 * actual spaces on the stack rather than bytes) since the task referenced by
1570 * xTask was created.
1572 configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1574 /* When using trace macros it is sometimes necessary to include task.h before
1575 * FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,
1576 * so the following two prototypes will cause a compilation error. This can be
1577 * fixed by simply guarding against the inclusion of these two prototypes unless
1578 * they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration
1580 #ifdef configUSE_APPLICATION_TASK_TAG
1581 #if configUSE_APPLICATION_TASK_TAG == 1
1586 * void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );
1589 * Sets pxHookFunction to be the task hook function used by the task xTask.
1590 * Passing xTask as NULL has the effect of setting the calling tasks hook
1593 void vTaskSetApplicationTaskTag( TaskHandle_t xTask,
1594 TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION;
1599 * void xTaskGetApplicationTaskTag( TaskHandle_t xTask );
1602 * Returns the pxHookFunction value assigned to the task xTask. Do not
1603 * call from an interrupt service routine - call
1604 * xTaskGetApplicationTaskTagFromISR() instead.
1606 TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1611 * void xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );
1614 * Returns the pxHookFunction value assigned to the task xTask. Can
1615 * be called from an interrupt service routine.
1617 TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1618 #endif /* configUSE_APPLICATION_TASK_TAG ==1 */
1619 #endif /* ifdef configUSE_APPLICATION_TASK_TAG */
1621 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
1623 /* Each task contains an array of pointers that is dimensioned by the
1624 * configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. The
1625 * kernel does not use the pointers itself, so the application writer can use
1626 * the pointers for any purpose they wish. The following two functions are
1627 * used to set and query a pointer respectively. */
1628 void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet,
1630 void * pvValue ) PRIVILEGED_FUNCTION;
1631 void * pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery,
1632 BaseType_t xIndex ) PRIVILEGED_FUNCTION;
1636 #if ( configCHECK_FOR_STACK_OVERFLOW > 0 )
1640 * <pre>void vApplicationStackOverflowHook( TaskHandle_t xTask char *pcTaskName); </pre>
1642 * The application stack overflow hook is called when a stack overflow is detected for a task.
1644 * Details on stack overflow detection can be found here: https://www.FreeRTOS.org/Stacks-and-stack-overflow-checking.html
1646 * @param xTask the task that just exceeded its stack boundaries.
1647 * @param pcTaskName A character string containing the name of the offending task.
1649 void vApplicationStackOverflowHook( TaskHandle_t xTask,
1650 char * pcTaskName );
1654 #if ( configUSE_TICK_HOOK > 0 )
1657 * <pre>void vApplicationTickHook( void ); </pre>
1659 * This hook function is called in the system tick handler after any OS work is completed.
1661 void vApplicationTickHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */
1665 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1668 * <pre>void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) </pre>
1670 * 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
1671 * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION
1673 * @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer
1674 * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task
1675 * @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
1677 void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
1678 StackType_t ** ppxIdleTaskStackBuffer,
1679 uint32_t * pulIdleTaskStackSize ); /*lint !e526 Symbol not defined as it is an application callback. */
1685 * BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );
1688 * Calls the hook function associated with xTask. Passing xTask as NULL has
1689 * the effect of calling the Running tasks (the calling task) hook function.
1691 * pvParameter is passed to the hook function for the task to interpret as it
1692 * wants. The return value is the value returned by the task hook function
1693 * registered by the user.
1695 BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask,
1696 void * pvParameter ) PRIVILEGED_FUNCTION;
1699 * xTaskGetIdleTaskHandle() is only available if
1700 * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.
1702 * Simply returns a pointer to the array of idle task handles.
1703 * It is not valid to call xTaskGetIdleTaskHandle() before the scheduler has been started.
1705 TaskHandle_t *xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
1708 * configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for
1709 * uxTaskGetSystemState() to be available.
1711 * uxTaskGetSystemState() populates an TaskStatus_t structure for each task in
1712 * the system. TaskStatus_t structures contain, among other things, members
1713 * for the task handle, task name, task priority, task state, and total amount
1714 * of run time consumed by the task. See the TaskStatus_t structure
1715 * definition in this file for the full member list.
1717 * NOTE: This function is intended for debugging use only as its use results in
1718 * the scheduler remaining suspended for an extended period.
1720 * @param pxTaskStatusArray A pointer to an array of TaskStatus_t structures.
1721 * The array must contain at least one TaskStatus_t structure for each task
1722 * that is under the control of the RTOS. The number of tasks under the control
1723 * of the RTOS can be determined using the uxTaskGetNumberOfTasks() API function.
1725 * @param uxArraySize The size of the array pointed to by the pxTaskStatusArray
1726 * parameter. The size is specified as the number of indexes in the array, or
1727 * the number of TaskStatus_t structures contained in the array, not by the
1728 * number of bytes in the array.
1730 * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in
1731 * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the
1732 * total run time (as defined by the run time stats clock, see
1733 * https://www.FreeRTOS.org/rtos-run-time-stats.html) since the target booted.
1734 * pulTotalRunTime can be set to NULL to omit the total run time information.
1736 * @return The number of TaskStatus_t structures that were populated by
1737 * uxTaskGetSystemState(). This should equal the number returned by the
1738 * uxTaskGetNumberOfTasks() API function, but will be zero if the value passed
1739 * in the uxArraySize parameter was too small.
1743 * // This example demonstrates how a human readable table of run time stats
1744 * // information is generated from raw data provided by uxTaskGetSystemState().
1745 * // The human readable table is written to pcWriteBuffer
1746 * void vTaskGetRunTimeStats( char *pcWriteBuffer )
1748 * TaskStatus_t *pxTaskStatusArray;
1749 * volatile UBaseType_t uxArraySize, x;
1750 * uint32_t ulTotalRunTime, ulStatsAsPercentage;
1752 * // Make sure the write buffer does not contain a string.
1753 * pcWriteBuffer = 0x00;
1755 * // Take a snapshot of the number of tasks in case it changes while this
1756 * // function is executing.
1757 * uxArraySize = uxTaskGetNumberOfTasks();
1759 * // Allocate a TaskStatus_t structure for each task. An array could be
1760 * // allocated statically at compile time.
1761 * pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
1763 * if( pxTaskStatusArray != NULL )
1765 * // Generate raw status information about each task.
1766 * uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );
1768 * // For percentage calculations.
1769 * ulTotalRunTime /= 100UL;
1771 * // Avoid divide by zero errors.
1772 * if( ulTotalRunTime > 0 )
1774 * // For each populated position in the pxTaskStatusArray array,
1775 * // format the raw data as human readable ASCII data
1776 * for( x = 0; x < uxArraySize; x++ )
1778 * // What percentage of the total run time has the task used?
1779 * // This will always be rounded down to the nearest integer.
1780 * // ulTotalRunTimeDiv100 has already been divided by 100.
1781 * ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;
1783 * if( ulStatsAsPercentage > 0UL )
1785 * sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
1789 * // If the percentage is zero here then the task has
1790 * // consumed less than 1% of the total run time.
1791 * sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );
1794 * pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );
1798 * // The array is no longer needed, free the memory it consumes.
1799 * vPortFree( pxTaskStatusArray );
1804 UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray,
1805 const UBaseType_t uxArraySize,
1806 uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION;
1810 * <PRE>void vTaskList( char *pcWriteBuffer );</PRE>
1812 * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must
1813 * both be defined as 1 for this function to be available. See the
1814 * configuration section of the FreeRTOS.org website for more information.
1816 * NOTE 1: This function will disable interrupts for its duration. It is
1817 * not intended for normal application runtime use but as a debug aid.
1819 * Lists all the current tasks, along with their current state and stack
1820 * usage high water mark.
1822 * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or
1827 * This function is provided for convenience only, and is used by many of the
1828 * demo applications. Do not consider it to be part of the scheduler.
1830 * vTaskList() calls uxTaskGetSystemState(), then formats part of the
1831 * uxTaskGetSystemState() output into a human readable table that displays task:
1832 * names, states, priority, stack usage and task number.
1833 * Stack usage specified as the number of unused StackType_t words stack can hold
1834 * on top of stack - not the number of bytes.
1836 * vTaskList() has a dependency on the sprintf() C library function that might
1837 * bloat the code size, use a lot of stack, and provide different results on
1838 * different platforms. An alternative, tiny, third party, and limited
1839 * functionality implementation of sprintf() is provided in many of the
1840 * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
1841 * printf-stdarg.c does not provide a full snprintf() implementation!).
1843 * It is recommended that production systems call uxTaskGetSystemState()
1844 * directly to get access to raw stats data, rather than indirectly through a
1845 * call to vTaskList().
1847 * @param pcWriteBuffer A buffer into which the above mentioned details
1848 * will be written, in ASCII form. This buffer is assumed to be large
1849 * enough to contain the generated report. Approximately 40 bytes per
1850 * task should be sufficient.
1852 * \defgroup vTaskList vTaskList
1853 * \ingroup TaskUtils
1855 void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1859 * <PRE>void vTaskGetRunTimeStats( char *pcWriteBuffer );</PRE>
1861 * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
1862 * must both be defined as 1 for this function to be available. The application
1863 * must also then provide definitions for
1864 * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
1865 * to configure a peripheral timer/counter and return the timers current count
1866 * value respectively. The counter should be at least 10 times the frequency of
1869 * NOTE 1: This function will disable interrupts for its duration. It is
1870 * not intended for normal application runtime use but as a debug aid.
1872 * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
1873 * accumulated execution time being stored for each task. The resolution
1874 * of the accumulated time value depends on the frequency of the timer
1875 * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
1876 * Calling vTaskGetRunTimeStats() writes the total execution time of each
1877 * task into a buffer, both as an absolute count value and as a percentage
1878 * of the total system execution time.
1882 * This function is provided for convenience only, and is used by many of the
1883 * demo applications. Do not consider it to be part of the scheduler.
1885 * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the
1886 * uxTaskGetSystemState() output into a human readable table that displays the
1887 * amount of time each task has spent in the Running state in both absolute and
1890 * vTaskGetRunTimeStats() has a dependency on the sprintf() C library function
1891 * that might bloat the code size, use a lot of stack, and provide different
1892 * results on different platforms. An alternative, tiny, third party, and
1893 * limited functionality implementation of sprintf() is provided in many of the
1894 * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
1895 * printf-stdarg.c does not provide a full snprintf() implementation!).
1897 * It is recommended that production systems call uxTaskGetSystemState() directly
1898 * to get access to raw stats data, rather than indirectly through a call to
1899 * vTaskGetRunTimeStats().
1901 * @param pcWriteBuffer A buffer into which the execution times will be
1902 * written, in ASCII form. This buffer is assumed to be large enough to
1903 * contain the generated report. Approximately 40 bytes per task should
1906 * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats
1907 * \ingroup TaskUtils
1909 void vTaskGetRunTimeStats( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1913 * <PRE>uint32_t ulTaskGetIdleRunTimeCounter( void );</PRE>
1915 * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
1916 * must both be defined as 1 for this function to be available. The application
1917 * must also then provide definitions for
1918 * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
1919 * to configure a peripheral timer/counter and return the timers current count
1920 * value respectively. The counter should be at least 10 times the frequency of
1923 * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
1924 * accumulated execution time being stored for each task. The resolution
1925 * of the accumulated time value depends on the frequency of the timer
1926 * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
1927 * While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total
1928 * execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter()
1929 * returns the total execution time of just the idle task.
1931 * @return The total run time of the idle task. This is the amount of time the
1932 * idle task has actually been executing. The unit of time is dependent on the
1933 * frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
1934 * portGET_RUN_TIME_COUNTER_VALUE() macros.
1936 * \defgroup ulTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter
1937 * \ingroup TaskUtils
1939 uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION;
1943 * <PRE>BaseType_t xTaskNotifyIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction );</PRE>
1944 * <PRE>BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );</PRE>
1946 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
1948 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
1949 * functions to be available.
1951 * Sends a direct to task notification to a task, with an optional value and
1954 * Each task has a private array of "notification values" (or 'notifications'),
1955 * each of which is a 32-bit unsigned integer (uint32_t). The constant
1956 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
1957 * array, and (for backward compatibility) defaults to 1 if left undefined.
1958 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
1960 * Events can be sent to a task using an intermediary object. Examples of such
1961 * objects are queues, semaphores, mutexes and event groups. Task notifications
1962 * are a method of sending an event directly to a task without the need for such
1963 * an intermediary object.
1965 * A notification sent to a task can optionally perform an action, such as
1966 * update, overwrite or increment one of the task's notification values. In
1967 * that way task notifications can be used to send data to a task, or be used as
1968 * light weight and fast binary or counting semaphores.
1970 * A task can use xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() to
1971 * [optionally] block to wait for a notification to be pending. The task does
1972 * not consume any CPU time while it is in the Blocked state.
1974 * A notification sent to a task will remain pending until it is cleared by the
1975 * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
1976 * un-indexed equivalents). If the task was already in the Blocked state to
1977 * wait for a notification when the notification arrives then the task will
1978 * automatically be removed from the Blocked state (unblocked) and the
1979 * notification cleared.
1981 * **NOTE** Each notification within the array operates independently - a task
1982 * can only block on one notification within the array at a time and will not be
1983 * unblocked by a notification sent to any other array index.
1985 * Backward compatibility information:
1986 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
1987 * all task notification API functions operated on that value. Replacing the
1988 * single notification value with an array of notification values necessitated a
1989 * new set of API functions that could address specific notifications within the
1990 * array. xTaskNotify() is the original API function, and remains backward
1991 * compatible by always operating on the notification value at index 0 in the
1992 * array. Calling xTaskNotify() is equivalent to calling xTaskNotifyIndexed()
1993 * with the uxIndexToNotify parameter set to 0.
1995 * @param xTaskToNotify The handle of the task being notified. The handle to a
1996 * task can be returned from the xTaskCreate() API function used to create the
1997 * task, and the handle of the currently running task can be obtained by calling
1998 * xTaskGetCurrentTaskHandle().
2000 * @param uxIndexToNotify The index within the target task's array of
2001 * notification values to which the notification is to be sent. uxIndexToNotify
2002 * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotify() does
2003 * not have this parameter and always sends notifications to index 0.
2005 * @param ulValue Data that can be sent with the notification. How the data is
2006 * used depends on the value of the eAction parameter.
2008 * @param eAction Specifies how the notification updates the task's notification
2009 * value, if at all. Valid values for eAction are as follows:
2012 * The target notification value is bitwise ORed with ulValue.
2013 * xTaskNotifyIndexed() always returns pdPASS in this case.
2016 * The target notification value is incremented. ulValue is not used and
2017 * xTaskNotifyIndexed() always returns pdPASS in this case.
2019 * eSetValueWithOverwrite -
2020 * The target notification value is set to the value of ulValue, even if the
2021 * task being notified had not yet processed the previous notification at the
2022 * same array index (the task already had a notification pending at that index).
2023 * xTaskNotifyIndexed() always returns pdPASS in this case.
2025 * eSetValueWithoutOverwrite -
2026 * If the task being notified did not already have a notification pending at the
2027 * same array index then the target notification value is set to ulValue and
2028 * xTaskNotifyIndexed() will return pdPASS. If the task being notified already
2029 * had a notification pending at the same array index then no action is
2030 * performed and pdFAIL is returned.
2033 * The task receives a notification at the specified array index without the
2034 * notification value at that index being updated. ulValue is not used and
2035 * xTaskNotifyIndexed() always returns pdPASS in this case.
2037 * pulPreviousNotificationValue -
2038 * Can be used to pass out the subject task's notification value before any
2039 * bits are modified by the notify function.
2041 * @return Dependent on the value of eAction. See the description of the
2042 * eAction parameter.
2044 * \defgroup xTaskNotifyIndexed xTaskNotifyIndexed
2045 * \ingroup TaskNotifications
2047 BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify,
2048 UBaseType_t uxIndexToNotify,
2050 eNotifyAction eAction,
2051 uint32_t * pulPreviousNotificationValue ) PRIVILEGED_FUNCTION;
2052 #define xTaskNotify( xTaskToNotify, ulValue, eAction ) \
2053 xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL )
2054 #define xTaskNotifyIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction ) \
2055 xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL )
2059 * <PRE>BaseType_t xTaskNotifyAndQueryIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue );</PRE>
2060 * <PRE>BaseType_t xTaskNotifyAndQuery( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue );</PRE>
2062 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2064 * xTaskNotifyAndQueryIndexed() performs the same operation as
2065 * xTaskNotifyIndexed() with the addition that it also returns the subject
2066 * task's prior notification value (the notification value at the time the
2067 * function is called rather than when the function returns) in the additional
2068 * pulPreviousNotifyValue parameter.
2070 * xTaskNotifyAndQuery() performs the same operation as xTaskNotify() with the
2071 * addition that it also returns the subject task's prior notification value
2072 * (the notification value as it was at the time the function is called, rather
2073 * than when the function returns) in the additional pulPreviousNotifyValue
2076 * \defgroup xTaskNotifyAndQueryIndexed xTaskNotifyAndQueryIndexed
2077 * \ingroup TaskNotifications
2079 #define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) \
2080 xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
2081 #define xTaskNotifyAndQueryIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotifyValue ) \
2082 xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
2086 * <PRE>BaseType_t xTaskNotifyIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );</PRE>
2087 * <PRE>BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );</PRE>
2089 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2091 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2092 * functions to be available.
2094 * A version of xTaskNotifyIndexed() that can be used from an interrupt service
2097 * Each task has a private array of "notification values" (or 'notifications'),
2098 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2099 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2100 * array, and (for backward compatibility) defaults to 1 if left undefined.
2101 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2103 * Events can be sent to a task using an intermediary object. Examples of such
2104 * objects are queues, semaphores, mutexes and event groups. Task notifications
2105 * are a method of sending an event directly to a task without the need for such
2106 * an intermediary object.
2108 * A notification sent to a task can optionally perform an action, such as
2109 * update, overwrite or increment one of the task's notification values. In
2110 * that way task notifications can be used to send data to a task, or be used as
2111 * light weight and fast binary or counting semaphores.
2113 * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a
2114 * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block
2115 * to wait for a notification value to have a non-zero value. The task does
2116 * not consume any CPU time while it is in the Blocked state.
2118 * A notification sent to a task will remain pending until it is cleared by the
2119 * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
2120 * un-indexed equivalents). If the task was already in the Blocked state to
2121 * wait for a notification when the notification arrives then the task will
2122 * automatically be removed from the Blocked state (unblocked) and the
2123 * notification cleared.
2125 * **NOTE** Each notification within the array operates independently - a task
2126 * can only block on one notification within the array at a time and will not be
2127 * unblocked by a notification sent to any other array index.
2129 * Backward compatibility information:
2130 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2131 * all task notification API functions operated on that value. Replacing the
2132 * single notification value with an array of notification values necessitated a
2133 * new set of API functions that could address specific notifications within the
2134 * array. xTaskNotifyFromISR() is the original API function, and remains
2135 * backward compatible by always operating on the notification value at index 0
2136 * within the array. Calling xTaskNotifyFromISR() is equivalent to calling
2137 * xTaskNotifyIndexedFromISR() with the uxIndexToNotify parameter set to 0.
2139 * @param uxIndexToNotify The index within the target task's array of
2140 * notification values to which the notification is to be sent. uxIndexToNotify
2141 * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyFromISR()
2142 * does not have this parameter and always sends notifications to index 0.
2144 * @param xTaskToNotify The handle of the task being notified. The handle to a
2145 * task can be returned from the xTaskCreate() API function used to create the
2146 * task, and the handle of the currently running task can be obtained by calling
2147 * xTaskGetCurrentTaskHandle().
2149 * @param ulValue Data that can be sent with the notification. How the data is
2150 * used depends on the value of the eAction parameter.
2152 * @param eAction Specifies how the notification updates the task's notification
2153 * value, if at all. Valid values for eAction are as follows:
2156 * The task's notification value is bitwise ORed with ulValue. xTaskNotify()
2157 * always returns pdPASS in this case.
2160 * The task's notification value is incremented. ulValue is not used and
2161 * xTaskNotify() always returns pdPASS in this case.
2163 * eSetValueWithOverwrite -
2164 * The task's notification value is set to the value of ulValue, even if the
2165 * task being notified had not yet processed the previous notification (the
2166 * task already had a notification pending). xTaskNotify() always returns
2167 * pdPASS in this case.
2169 * eSetValueWithoutOverwrite -
2170 * If the task being notified did not already have a notification pending then
2171 * the task's notification value is set to ulValue and xTaskNotify() will
2172 * return pdPASS. If the task being notified already had a notification
2173 * pending then no action is performed and pdFAIL is returned.
2176 * The task receives a notification without its notification value being
2177 * updated. ulValue is not used and xTaskNotify() always returns pdPASS in
2180 * @param pxHigherPriorityTaskWoken xTaskNotifyFromISR() will set
2181 * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
2182 * task to which the notification was sent to leave the Blocked state, and the
2183 * unblocked task has a priority higher than the currently running task. If
2184 * xTaskNotifyFromISR() sets this value to pdTRUE then a context switch should
2185 * be requested before the interrupt is exited. How a context switch is
2186 * requested from an ISR is dependent on the port - see the documentation page
2187 * for the port in use.
2189 * @return Dependent on the value of eAction. See the description of the
2190 * eAction parameter.
2192 * \defgroup xTaskNotifyIndexedFromISR xTaskNotifyIndexedFromISR
2193 * \ingroup TaskNotifications
2195 BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify,
2196 UBaseType_t uxIndexToNotify,
2198 eNotifyAction eAction,
2199 uint32_t * pulPreviousNotificationValue,
2200 BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
2201 #define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \
2202 xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
2203 #define xTaskNotifyIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \
2204 xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
2208 * <PRE>BaseType_t xTaskNotifyAndQueryIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken );</PRE>
2209 * <PRE>BaseType_t xTaskNotifyAndQueryFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken );</PRE>
2211 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2213 * xTaskNotifyAndQueryIndexedFromISR() performs the same operation as
2214 * xTaskNotifyIndexedFromISR() with the addition that it also returns the
2215 * subject task's prior notification value (the notification value at the time
2216 * the function is called rather than at the time the function returns) in the
2217 * additional pulPreviousNotifyValue parameter.
2219 * xTaskNotifyAndQueryFromISR() performs the same operation as
2220 * xTaskNotifyFromISR() with the addition that it also returns the subject
2221 * task's prior notification value (the notification value at the time the
2222 * function is called rather than at the time the function returns) in the
2223 * additional pulPreviousNotifyValue parameter.
2225 * \defgroup xTaskNotifyAndQueryIndexedFromISR xTaskNotifyAndQueryIndexedFromISR
2226 * \ingroup TaskNotifications
2228 #define xTaskNotifyAndQueryIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \
2229 xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
2230 #define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \
2231 xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
2236 * BaseType_t xTaskNotifyWaitIndexed( UBaseType_t uxIndexToWaitOn, uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
2238 * BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
2241 * Waits for a direct to task notification to be pending at a given index within
2242 * an array of direct to task notifications.
2244 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2246 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
2247 * function to be available.
2249 * Each task has a private array of "notification values" (or 'notifications'),
2250 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2251 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2252 * array, and (for backward compatibility) defaults to 1 if left undefined.
2253 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2255 * Events can be sent to a task using an intermediary object. Examples of such
2256 * objects are queues, semaphores, mutexes and event groups. Task notifications
2257 * are a method of sending an event directly to a task without the need for such
2258 * an intermediary object.
2260 * A notification sent to a task can optionally perform an action, such as
2261 * update, overwrite or increment one of the task's notification values. In
2262 * that way task notifications can be used to send data to a task, or be used as
2263 * light weight and fast binary or counting semaphores.
2265 * A notification sent to a task will remain pending until it is cleared by the
2266 * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
2267 * un-indexed equivalents). If the task was already in the Blocked state to
2268 * wait for a notification when the notification arrives then the task will
2269 * automatically be removed from the Blocked state (unblocked) and the
2270 * notification cleared.
2272 * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a
2273 * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block
2274 * to wait for a notification value to have a non-zero value. The task does
2275 * not consume any CPU time while it is in the Blocked state.
2277 * **NOTE** Each notification within the array operates independently - a task
2278 * can only block on one notification within the array at a time and will not be
2279 * unblocked by a notification sent to any other array index.
2281 * Backward compatibility information:
2282 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2283 * all task notification API functions operated on that value. Replacing the
2284 * single notification value with an array of notification values necessitated a
2285 * new set of API functions that could address specific notifications within the
2286 * array. xTaskNotifyWait() is the original API function, and remains backward
2287 * compatible by always operating on the notification value at index 0 in the
2288 * array. Calling xTaskNotifyWait() is equivalent to calling
2289 * xTaskNotifyWaitIndexed() with the uxIndexToWaitOn parameter set to 0.
2291 * @param uxIndexToWaitOn The index within the calling task's array of
2292 * notification values on which the calling task will wait for a notification to
2293 * be received. uxIndexToWaitOn must be less than
2294 * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyWait() does
2295 * not have this parameter and always waits for notifications on index 0.
2297 * @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value
2298 * will be cleared in the calling task's notification value before the task
2299 * checks to see if any notifications are pending, and optionally blocks if no
2300 * notifications are pending. Setting ulBitsToClearOnEntry to ULONG_MAX (if
2301 * limits.h is included) or 0xffffffffUL (if limits.h is not included) will have
2302 * the effect of resetting the task's notification value to 0. Setting
2303 * ulBitsToClearOnEntry to 0 will leave the task's notification value unchanged.
2305 * @param ulBitsToClearOnExit If a notification is pending or received before
2306 * the calling task exits the xTaskNotifyWait() function then the task's
2307 * notification value (see the xTaskNotify() API function) is passed out using
2308 * the pulNotificationValue parameter. Then any bits that are set in
2309 * ulBitsToClearOnExit will be cleared in the task's notification value (note
2310 * *pulNotificationValue is set before any bits are cleared). Setting
2311 * ulBitsToClearOnExit to ULONG_MAX (if limits.h is included) or 0xffffffffUL
2312 * (if limits.h is not included) will have the effect of resetting the task's
2313 * notification value to 0 before the function exits. Setting
2314 * ulBitsToClearOnExit to 0 will leave the task's notification value unchanged
2315 * when the function exits (in which case the value passed out in
2316 * pulNotificationValue will match the task's notification value).
2318 * @param pulNotificationValue Used to pass the task's notification value out
2319 * of the function. Note the value passed out will not be effected by the
2320 * clearing of any bits caused by ulBitsToClearOnExit being non-zero.
2322 * @param xTicksToWait The maximum amount of time that the task should wait in
2323 * the Blocked state for a notification to be received, should a notification
2324 * not already be pending when xTaskNotifyWait() was called. The task
2325 * will not consume any processing time while it is in the Blocked state. This
2326 * is specified in kernel ticks, the macro pdMS_TO_TICKS( value_in_ms ) can be
2327 * used to convert a time specified in milliseconds to a time specified in
2330 * @return If a notification was received (including notifications that were
2331 * already pending when xTaskNotifyWait was called) then pdPASS is
2332 * returned. Otherwise pdFAIL is returned.
2334 * \defgroup xTaskNotifyWaitIndexed xTaskNotifyWaitIndexed
2335 * \ingroup TaskNotifications
2337 BaseType_t xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn,
2338 uint32_t ulBitsToClearOnEntry,
2339 uint32_t ulBitsToClearOnExit,
2340 uint32_t * pulNotificationValue,
2341 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2342 #define xTaskNotifyWait( ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \
2343 xTaskGenericNotifyWait( tskDEFAULT_INDEX_TO_NOTIFY, ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) )
2344 #define xTaskNotifyWaitIndexed( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \
2345 xTaskGenericNotifyWait( ( uxIndexToWaitOn ), ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) )
2349 * <PRE>BaseType_t xTaskNotifyGiveIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify );</PRE>
2350 * <PRE>BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );</PRE>
2352 * Sends a direct to task notification to a particular index in the target
2353 * task's notification array in a manner similar to giving a counting semaphore.
2355 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
2357 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2358 * macros to be available.
2360 * Each task has a private array of "notification values" (or 'notifications'),
2361 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2362 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2363 * array, and (for backward compatibility) defaults to 1 if left undefined.
2364 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2366 * Events can be sent to a task using an intermediary object. Examples of such
2367 * objects are queues, semaphores, mutexes and event groups. Task notifications
2368 * are a method of sending an event directly to a task without the need for such
2369 * an intermediary object.
2371 * A notification sent to a task can optionally perform an action, such as
2372 * update, overwrite or increment one of the task's notification values. In
2373 * that way task notifications can be used to send data to a task, or be used as
2374 * light weight and fast binary or counting semaphores.
2376 * xTaskNotifyGiveIndexed() is a helper macro intended for use when task
2377 * notifications are used as light weight and faster binary or counting
2378 * semaphore equivalents. Actual FreeRTOS semaphores are given using the
2379 * xSemaphoreGive() API function, the equivalent action that instead uses a task
2380 * notification is xTaskNotifyGiveIndexed().
2382 * When task notifications are being used as a binary or counting semaphore
2383 * equivalent then the task being notified should wait for the notification
2384 * using the ulTaskNotificationTakeIndexed() API function rather than the
2385 * xTaskNotifyWaitIndexed() API function.
2387 * **NOTE** Each notification within the array operates independently - a task
2388 * can only block on one notification within the array at a time and will not be
2389 * unblocked by a notification sent to any other array index.
2391 * Backward compatibility information:
2392 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2393 * all task notification API functions operated on that value. Replacing the
2394 * single notification value with an array of notification values necessitated a
2395 * new set of API functions that could address specific notifications within the
2396 * array. xTaskNotifyGive() is the original API function, and remains backward
2397 * compatible by always operating on the notification value at index 0 in the
2398 * array. Calling xTaskNotifyGive() is equivalent to calling
2399 * xTaskNotifyGiveIndexed() with the uxIndexToNotify parameter set to 0.
2401 * @param xTaskToNotify The handle of the task being notified. The handle to a
2402 * task can be returned from the xTaskCreate() API function used to create the
2403 * task, and the handle of the currently running task can be obtained by calling
2404 * xTaskGetCurrentTaskHandle().
2406 * @param uxIndexToNotify The index within the target task's array of
2407 * notification values to which the notification is to be sent. uxIndexToNotify
2408 * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyGive()
2409 * does not have this parameter and always sends notifications to index 0.
2411 * @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the
2412 * eAction parameter set to eIncrement - so pdPASS is always returned.
2414 * \defgroup xTaskNotifyGiveIndexed xTaskNotifyGiveIndexed
2415 * \ingroup TaskNotifications
2417 #define xTaskNotifyGive( xTaskToNotify ) \
2418 xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( 0 ), eIncrement, NULL )
2419 #define xTaskNotifyGiveIndexed( xTaskToNotify, uxIndexToNotify ) \
2420 xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( 0 ), eIncrement, NULL )
2424 * <PRE>void vTaskNotifyGiveIndexedFromISR( TaskHandle_t xTaskHandle, UBaseType_t uxIndexToNotify, BaseType_t *pxHigherPriorityTaskWoken );</PRE>
2425 * <PRE>void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );</PRE>
2427 * A version of xTaskNotifyGiveIndexed() that can be called from an interrupt
2428 * service routine (ISR).
2430 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
2432 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro
2435 * Each task has a private array of "notification values" (or 'notifications'),
2436 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2437 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2438 * array, and (for backward compatibility) defaults to 1 if left undefined.
2439 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2441 * Events can be sent to a task using an intermediary object. Examples of such
2442 * objects are queues, semaphores, mutexes and event groups. Task notifications
2443 * are a method of sending an event directly to a task without the need for such
2444 * an intermediary object.
2446 * A notification sent to a task can optionally perform an action, such as
2447 * update, overwrite or increment one of the task's notification values. In
2448 * that way task notifications can be used to send data to a task, or be used as
2449 * light weight and fast binary or counting semaphores.
2451 * vTaskNotifyGiveIndexedFromISR() is intended for use when task notifications
2452 * are used as light weight and faster binary or counting semaphore equivalents.
2453 * Actual FreeRTOS semaphores are given from an ISR using the
2454 * xSemaphoreGiveFromISR() API function, the equivalent action that instead uses
2455 * a task notification is vTaskNotifyGiveIndexedFromISR().
2457 * When task notifications are being used as a binary or counting semaphore
2458 * equivalent then the task being notified should wait for the notification
2459 * using the ulTaskNotificationTakeIndexed() API function rather than the
2460 * xTaskNotifyWaitIndexed() API function.
2462 * **NOTE** Each notification within the array operates independently - a task
2463 * can only block on one notification within the array at a time and will not be
2464 * unblocked by a notification sent to any other array index.
2466 * Backward compatibility information:
2467 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2468 * all task notification API functions operated on that value. Replacing the
2469 * single notification value with an array of notification values necessitated a
2470 * new set of API functions that could address specific notifications within the
2471 * array. xTaskNotifyFromISR() is the original API function, and remains
2472 * backward compatible by always operating on the notification value at index 0
2473 * within the array. Calling xTaskNotifyGiveFromISR() is equivalent to calling
2474 * xTaskNotifyGiveIndexedFromISR() with the uxIndexToNotify parameter set to 0.
2476 * @param xTaskToNotify The handle of the task being notified. The handle to a
2477 * task can be returned from the xTaskCreate() API function used to create the
2478 * task, and the handle of the currently running task can be obtained by calling
2479 * xTaskGetCurrentTaskHandle().
2481 * @param uxIndexToNotify The index within the target task's array of
2482 * notification values to which the notification is to be sent. uxIndexToNotify
2483 * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
2484 * xTaskNotifyGiveFromISR() does not have this parameter and always sends
2485 * notifications to index 0.
2487 * @param pxHigherPriorityTaskWoken vTaskNotifyGiveFromISR() will set
2488 * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
2489 * task to which the notification was sent to leave the Blocked state, and the
2490 * unblocked task has a priority higher than the currently running task. If
2491 * vTaskNotifyGiveFromISR() sets this value to pdTRUE then a context switch
2492 * should be requested before the interrupt is exited. How a context switch is
2493 * requested from an ISR is dependent on the port - see the documentation page
2494 * for the port in use.
2496 * \defgroup vTaskNotifyGiveIndexedFromISR vTaskNotifyGiveIndexedFromISR
2497 * \ingroup TaskNotifications
2499 void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify,
2500 UBaseType_t uxIndexToNotify,
2501 BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
2502 #define vTaskNotifyGiveFromISR( xTaskToNotify, pxHigherPriorityTaskWoken ) \
2503 vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( pxHigherPriorityTaskWoken ) );
2504 #define vTaskNotifyGiveIndexedFromISR( xTaskToNotify, uxIndexToNotify, pxHigherPriorityTaskWoken ) \
2505 vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( pxHigherPriorityTaskWoken ) );
2510 * uint32_t ulTaskNotifyTakeIndexed( UBaseType_t uxIndexToWaitOn, BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
2512 * uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
2515 * Waits for a direct to task notification on a particular index in the calling
2516 * task's notification array in a manner similar to taking a counting semaphore.
2518 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2520 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
2521 * function to be available.
2523 * Each task has a private array of "notification values" (or 'notifications'),
2524 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2525 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2526 * array, and (for backward compatibility) defaults to 1 if left undefined.
2527 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2529 * Events can be sent to a task using an intermediary object. Examples of such
2530 * objects are queues, semaphores, mutexes and event groups. Task notifications
2531 * are a method of sending an event directly to a task without the need for such
2532 * an intermediary object.
2534 * A notification sent to a task can optionally perform an action, such as
2535 * update, overwrite or increment one of the task's notification values. In
2536 * that way task notifications can be used to send data to a task, or be used as
2537 * light weight and fast binary or counting semaphores.
2539 * ulTaskNotifyTakeIndexed() is intended for use when a task notification is
2540 * used as a faster and lighter weight binary or counting semaphore alternative.
2541 * Actual FreeRTOS semaphores are taken using the xSemaphoreTake() API function,
2542 * the equivalent action that instead uses a task notification is
2543 * ulTaskNotifyTakeIndexed().
2545 * When a task is using its notification value as a binary or counting semaphore
2546 * other tasks should send notifications to it using the xTaskNotifyGiveIndexed()
2547 * macro, or xTaskNotifyIndex() function with the eAction parameter set to
2550 * ulTaskNotifyTakeIndexed() can either clear the task's notification value at
2551 * the array index specified by the uxIndexToWaitOn parameter to zero on exit,
2552 * in which case the notification value acts like a binary semaphore, or
2553 * decrement the notification value on exit, in which case the notification
2554 * value acts like a counting semaphore.
2556 * A task can use ulTaskNotifyTakeIndexed() to [optionally] block to wait for
2557 * a notification. The task does not consume any CPU time while it is in the
2560 * Where as xTaskNotifyWaitIndexed() will return when a notification is pending,
2561 * ulTaskNotifyTakeIndexed() will return when the task's notification value is
2564 * **NOTE** Each notification within the array operates independently - a task
2565 * can only block on one notification within the array at a time and will not be
2566 * unblocked by a notification sent to any other array index.
2568 * Backward compatibility information:
2569 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2570 * all task notification API functions operated on that value. Replacing the
2571 * single notification value with an array of notification values necessitated a
2572 * new set of API functions that could address specific notifications within the
2573 * array. ulTaskNotifyTake() is the original API function, and remains backward
2574 * compatible by always operating on the notification value at index 0 in the
2575 * array. Calling ulTaskNotifyTake() is equivalent to calling
2576 * ulTaskNotifyTakeIndexed() with the uxIndexToWaitOn parameter set to 0.
2578 * @param uxIndexToWaitOn The index within the calling task's array of
2579 * notification values on which the calling task will wait for a notification to
2580 * be non-zero. uxIndexToWaitOn must be less than
2581 * configTASK_NOTIFICATION_ARRAY_ENTRIES. xTaskNotifyTake() does
2582 * not have this parameter and always waits for notifications on index 0.
2584 * @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's
2585 * notification value is decremented when the function exits. In this way the
2586 * notification value acts like a counting semaphore. If xClearCountOnExit is
2587 * not pdFALSE then the task's notification value is cleared to zero when the
2588 * function exits. In this way the notification value acts like a binary
2591 * @param xTicksToWait The maximum amount of time that the task should wait in
2592 * the Blocked state for the task's notification value to be greater than zero,
2593 * should the count not already be greater than zero when
2594 * ulTaskNotifyTake() was called. The task will not consume any processing
2595 * time while it is in the Blocked state. This is specified in kernel ticks,
2596 * the macro pdMS_TO_TICKS( value_in_ms ) can be used to convert a time
2597 * specified in milliseconds to a time specified in ticks.
2599 * @return The task's notification count before it is either cleared to zero or
2600 * decremented (see the xClearCountOnExit parameter).
2602 * \defgroup ulTaskNotifyTakeIndexed ulTaskNotifyTakeIndexed
2603 * \ingroup TaskNotifications
2605 uint32_t ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn,
2606 BaseType_t xClearCountOnExit,
2607 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2608 #define ulTaskNotifyTake( xClearCountOnExit, xTicksToWait ) \
2609 ulTaskGenericNotifyTake( ( tskDEFAULT_INDEX_TO_NOTIFY ), ( xClearCountOnExit ), ( xTicksToWait ) )
2610 #define ulTaskNotifyTakeIndexed( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait ) \
2611 ulTaskGenericNotifyTake( ( uxIndexToWaitOn ), ( xClearCountOnExit ), ( xTicksToWait ) )
2616 * BaseType_t xTaskNotifyStateClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToCLear );
2618 * BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
2621 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2623 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2624 * functions to be available.
2626 * Each task has a private array of "notification values" (or 'notifications'),
2627 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2628 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2629 * array, and (for backward compatibility) defaults to 1 if left undefined.
2630 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2632 * If a notification is sent to an index within the array of notifications then
2633 * the notification at that index is said to be 'pending' until it is read or
2634 * explicitly cleared by the receiving task. xTaskNotifyStateClearIndexed()
2635 * is the function that clears a pending notification without reading the
2636 * notification value. The notification value at the same array index is not
2637 * altered. Set xTask to NULL to clear the notification state of the calling
2640 * Backward compatibility information:
2641 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2642 * all task notification API functions operated on that value. Replacing the
2643 * single notification value with an array of notification values necessitated a
2644 * new set of API functions that could address specific notifications within the
2645 * array. xTaskNotifyStateClear() is the original API function, and remains
2646 * backward compatible by always operating on the notification value at index 0
2647 * within the array. Calling xTaskNotifyStateClear() is equivalent to calling
2648 * xTaskNotifyStateClearIndexed() with the uxIndexToNotify parameter set to 0.
2650 * @param xTask The handle of the RTOS task that will have a notification state
2651 * cleared. Set xTask to NULL to clear a notification state in the calling
2652 * task. To obtain a task's handle create the task using xTaskCreate() and
2653 * make use of the pxCreatedTask parameter, or create the task using
2654 * xTaskCreateStatic() and store the returned value, or use the task's name in
2655 * a call to xTaskGetHandle().
2657 * @param uxIndexToClear The index within the target task's array of
2658 * notification values to act upon. For example, setting uxIndexToClear to 1
2659 * will clear the state of the notification at index 1 within the array.
2660 * uxIndexToClear must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
2661 * ulTaskNotifyStateClear() does not have this parameter and always acts on the
2662 * notification at index 0.
2664 * @return pdTRUE if the task's notification state was set to
2665 * eNotWaitingNotification, otherwise pdFALSE.
2667 * \defgroup xTaskNotifyStateClearIndexed xTaskNotifyStateClearIndexed
2668 * \ingroup TaskNotifications
2670 BaseType_t xTaskGenericNotifyStateClear( TaskHandle_t xTask,
2671 UBaseType_t uxIndexToClear ) PRIVILEGED_FUNCTION;
2672 #define xTaskNotifyStateClear( xTask ) \
2673 xTaskGenericNotifyStateClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ) )
2674 #define xTaskNotifyStateClearIndexed( xTask, uxIndexToClear ) \
2675 xTaskGenericNotifyStateClear( ( xTask ), ( uxIndexToClear ) )
2680 * uint32_t ulTaskNotifyValueClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear );
2682 * uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear );
2685 * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2687 * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2688 * functions to be available.
2690 * Each task has a private array of "notification values" (or 'notifications'),
2691 * each of which is a 32-bit unsigned integer (uint32_t). The constant
2692 * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2693 * array, and (for backward compatibility) defaults to 1 if left undefined.
2694 * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2696 * ulTaskNotifyValueClearIndexed() clears the bits specified by the
2697 * ulBitsToClear bit mask in the notification value at array index uxIndexToClear
2698 * of the task referenced by xTask.
2700 * Backward compatibility information:
2701 * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2702 * all task notification API functions operated on that value. Replacing the
2703 * single notification value with an array of notification values necessitated a
2704 * new set of API functions that could address specific notifications within the
2705 * array. ulTaskNotifyValueClear() is the original API function, and remains
2706 * backward compatible by always operating on the notification value at index 0
2707 * within the array. Calling ulTaskNotifyValueClear() is equivalent to calling
2708 * ulTaskNotifyValueClearIndexed() with the uxIndexToClear parameter set to 0.
2710 * @param xTask The handle of the RTOS task that will have bits in one of its
2711 * notification values cleared. Set xTask to NULL to clear bits in a
2712 * notification value of the calling task. To obtain a task's handle create the
2713 * task using xTaskCreate() and make use of the pxCreatedTask parameter, or
2714 * create the task using xTaskCreateStatic() and store the returned value, or
2715 * use the task's name in a call to xTaskGetHandle().
2717 * @param uxIndexToClear The index within the target task's array of
2718 * notification values in which to clear the bits. uxIndexToClear
2719 * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
2720 * ulTaskNotifyValueClear() does not have this parameter and always clears bits
2721 * in the notification value at index 0.
2723 * @param ulBitsToClear Bit mask of the bits to clear in the notification value of
2724 * xTask. Set a bit to 1 to clear the corresponding bits in the task's notification
2725 * value. Set ulBitsToClear to 0xffffffff (UINT_MAX on 32-bit architectures) to clear
2726 * the notification value to 0. Set ulBitsToClear to 0 to query the task's
2727 * notification value without clearing any bits.
2730 * @return The value of the target task's notification value before the bits
2731 * specified by ulBitsToClear were cleared.
2732 * \defgroup ulTaskNotifyValueClear ulTaskNotifyValueClear
2733 * \ingroup TaskNotifications
2735 uint32_t ulTaskGenericNotifyValueClear( TaskHandle_t xTask,
2736 UBaseType_t uxIndexToClear,
2737 uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
2738 #define ulTaskNotifyValueClear( xTask, ulBitsToClear ) \
2739 ulTaskGenericNotifyValueClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulBitsToClear ) )
2740 #define ulTaskNotifyValueClearIndexed( xTask, uxIndexToClear, ulBitsToClear ) \
2741 ulTaskGenericNotifyValueClear( ( xTask ), ( uxIndexToClear ), ( ulBitsToClear ) )
2746 * void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut );
2749 * Capture the current time for future use with xTaskCheckForTimeOut().
2751 * @param pxTimeOut Pointer to a timeout object into which the current time
2752 * is to be captured. The captured time includes the tick count and the number
2753 * of times the tick count has overflowed since the system first booted.
2754 * \defgroup vTaskSetTimeOutState vTaskSetTimeOutState
2757 void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
2762 * BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait );
2765 * Determines if pxTicksToWait ticks has passed since a time was captured
2766 * using a call to vTaskSetTimeOutState(). The captured time includes the tick
2767 * count and the number of times the tick count has overflowed.
2769 * @param pxTimeOut The time status as captured previously using
2770 * vTaskSetTimeOutState. If the timeout has not yet occurred, it is updated
2771 * to reflect the current time status.
2772 * @param pxTicksToWait The number of ticks to check for timeout i.e. if
2773 * pxTicksToWait ticks have passed since pxTimeOut was last updated (either by
2774 * vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred.
2775 * If the timeout has not occurred, pxTicksToWait is updated to reflect the
2776 * number of remaining ticks.
2778 * @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is
2779 * returned and pxTicksToWait is updated to reflect the number of remaining
2782 * @see https://www.FreeRTOS.org/xTaskCheckForTimeOut.html
2786 * // Driver library function used to receive uxWantedBytes from an Rx buffer
2787 * // that is filled by a UART interrupt. If there are not enough bytes in the
2788 * // Rx buffer then the task enters the Blocked state until it is notified that
2789 * // more data has been placed into the buffer. If there is still not enough
2790 * // data then the task re-enters the Blocked state, and xTaskCheckForTimeOut()
2791 * // is used to re-calculate the Block time to ensure the total amount of time
2792 * // spent in the Blocked state does not exceed MAX_TIME_TO_WAIT. This
2793 * // continues until either the buffer contains at least uxWantedBytes bytes,
2794 * // or the total amount of time spent in the Blocked state reaches
2795 * // MAX_TIME_TO_WAIT – at which point the task reads however many bytes are
2796 * // available up to a maximum of uxWantedBytes.
2798 * size_t xUART_Receive( uint8_t *pucBuffer, size_t uxWantedBytes )
2800 * size_t uxReceived = 0;
2801 * TickType_t xTicksToWait = MAX_TIME_TO_WAIT;
2802 * TimeOut_t xTimeOut;
2804 * // Initialize xTimeOut. This records the time at which this function
2806 * vTaskSetTimeOutState( &xTimeOut );
2808 * // Loop until the buffer contains the wanted number of bytes, or a
2809 * // timeout occurs.
2810 * while( UART_bytes_in_rx_buffer( pxUARTInstance ) < uxWantedBytes )
2812 * // The buffer didn't contain enough data so this task is going to
2813 * // enter the Blocked state. Adjusting xTicksToWait to account for
2814 * // any time that has been spent in the Blocked state within this
2815 * // function so far to ensure the total amount of time spent in the
2816 * // Blocked state does not exceed MAX_TIME_TO_WAIT.
2817 * if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) != pdFALSE )
2819 * //Timed out before the wanted number of bytes were available,
2824 * // Wait for a maximum of xTicksToWait ticks to be notified that the
2825 * // receive interrupt has placed more data into the buffer.
2826 * ulTaskNotifyTake( pdTRUE, xTicksToWait );
2829 * // Attempt to read uxWantedBytes from the receive buffer into pucBuffer.
2830 * // The actual number of bytes read (which might be less than
2831 * // uxWantedBytes) is returned.
2832 * uxReceived = UART_read_from_receive_buffer( pxUARTInstance,
2836 * return uxReceived;
2839 * \defgroup xTaskCheckForTimeOut xTaskCheckForTimeOut
2842 BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut,
2843 TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;
2848 * BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp );
2851 * This function corrects the tick count value after the application code has held
2852 * interrupts disabled for an extended period resulting in tick interrupts having
2855 * This function is similar to vTaskStepTick(), however, unlike
2856 * vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a
2857 * time at which a task should be removed from the blocked state. That means
2858 * tasks may have to be removed from the blocked state as the tick count is
2861 * @param xTicksToCatchUp The number of tick interrupts that have been missed due to
2862 * interrupts being disabled. Its value is not computed automatically, so must be
2863 * computed by the application writer.
2865 * @return pdTRUE if moving the tick count forward resulted in a task leaving the
2866 * blocked state and a context switch being performed. Otherwise pdFALSE.
2868 * \defgroup xTaskCatchUpTicks xTaskCatchUpTicks
2871 BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION;
2874 /*-----------------------------------------------------------
2875 * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
2876 *----------------------------------------------------------*/
2879 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
2880 * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
2881 * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2883 * Called from the real time kernel tick (either preemptive or cooperative),
2884 * this increments the tick count and checks if any tasks that are blocked
2885 * for a finite period required removing from a blocked list and placing on
2886 * a ready list. If a non-zero value is returned then a context switch is
2887 * required because either:
2888 * + A task was removed from a blocked list because its timeout had expired,
2890 * + Time slicing is in use and there is a task of equal priority to the
2891 * currently running task.
2893 BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;
2896 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
2897 * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2899 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
2901 * Removes the calling task from the ready list and places it both
2902 * on the list of tasks waiting for a particular event, and the
2903 * list of delayed tasks. The task will be removed from both lists
2904 * and replaced on the ready list should either the event occur (and
2905 * there be no higher priority tasks waiting on the same event) or
2906 * the delay period expires.
2908 * The 'unordered' version replaces the event list item value with the
2909 * xItemValue value, and inserts the list item at the end of the list.
2911 * The 'ordered' version uses the existing event list item value (which is the
2912 * owning task's priority) to insert the list item into the event list in task
2915 * @param pxEventList The list containing tasks that are blocked waiting
2916 * for the event to occur.
2918 * @param xItemValue The item value to use for the event list item when the
2919 * event list is not ordered by task priority.
2921 * @param xTicksToWait The maximum amount of time that the task should wait
2922 * for the event to occur. This is specified in kernel ticks, the constant
2923 * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time
2926 void vTaskPlaceOnEventList( List_t * const pxEventList,
2927 const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2928 void vTaskPlaceOnUnorderedEventList( List_t * pxEventList,
2929 const TickType_t xItemValue,
2930 const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2933 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
2934 * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2936 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
2938 * This function performs nearly the same function as vTaskPlaceOnEventList().
2939 * The difference being that this function does not permit tasks to block
2940 * indefinitely, whereas vTaskPlaceOnEventList() does.
2943 void vTaskPlaceOnEventListRestricted( List_t * const pxEventList,
2944 TickType_t xTicksToWait,
2945 const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;
2948 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
2949 * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2951 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
2953 * Removes a task from both the specified event list and the list of blocked
2954 * tasks, and places it on a ready queue.
2956 * xTaskRemoveFromEventList()/vTaskRemoveFromUnorderedEventList() will be called
2957 * if either an event occurs to unblock a task, or the block timeout period
2960 * xTaskRemoveFromEventList() is used when the event list is in task priority
2961 * order. It removes the list item from the head of the event list as that will
2962 * have the highest priority owning task of all the tasks on the event list.
2963 * vTaskRemoveFromUnorderedEventList() is used when the event list is not
2964 * ordered and the event list items hold something other than the owning tasks
2965 * priority. In this case the event list item value is updated to the value
2966 * passed in the xItemValue parameter.
2968 * @return pdTRUE if the task being removed has a higher priority than the task
2969 * making the call, otherwise pdFALSE.
2971 BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION;
2972 void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem,
2973 const TickType_t xItemValue ) PRIVILEGED_FUNCTION;
2976 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
2977 * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
2978 * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2980 * Sets the pointer to the current TCB to the TCB of the highest priority task
2981 * that is ready to run.
2983 portDONT_DISCARD void vTaskSwitchContext( BaseType_t xCoreID ) PRIVILEGED_FUNCTION;
2986 * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY
2987 * THE EVENT BITS MODULE.
2989 TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION;
2992 * Return the handle of the calling task.
2994 TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;
2997 * Return the handle of the task running on specified core.
2999 TaskHandle_t xTaskGetCurrentTaskHandleCPU( UBaseType_t xCoreID ) PRIVILEGED_FUNCTION;
3002 * Shortcut used by the queue implementation to prevent unnecessary call to
3005 void vTaskMissedYield( void ) PRIVILEGED_FUNCTION;
3008 * Returns the scheduler state as taskSCHEDULER_RUNNING,
3009 * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.
3011 BaseType_t xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION;
3014 * Raises the priority of the mutex holder to that of the calling task should
3015 * the mutex holder have a priority less than the calling task.
3017 BaseType_t xTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
3020 * Set the priority of a task back to its proper priority in the case that it
3021 * inherited a higher priority while it was holding a semaphore.
3023 BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
3026 * If a higher priority task attempting to obtain a mutex caused a lower
3027 * priority task to inherit the higher priority task's priority - but the higher
3028 * priority task then timed out without obtaining the mutex, then the lower
3029 * priority task will disinherit the priority again - but only down as far as
3030 * the highest priority task that is still waiting for the mutex (if there were
3031 * more than one task waiting for the mutex).
3033 void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder,
3034 UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION;
3037 * Get the uxTCBNumber assigned to the task referenced by the xTask parameter.
3039 UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
3042 * Set the uxTaskNumber of the task referenced by the xTask parameter to
3045 void vTaskSetTaskNumber( TaskHandle_t xTask,
3046 const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION;
3049 * Only available when configUSE_TICKLESS_IDLE is set to 1.
3050 * If tickless mode is being used, or a low power mode is implemented, then
3051 * the tick interrupt will not execute during idle periods. When this is the
3052 * case, the tick count value maintained by the scheduler needs to be kept up
3053 * to date with the actual execution time by being skipped forward by a time
3054 * equal to the idle period.
3056 void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION;
3059 * Only available when configUSE_TICKLESS_IDLE is set to 1.
3060 * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port
3061 * specific sleep function to determine if it is ok to proceed with the sleep,
3062 * and if it is ok to proceed, if it is ok to sleep indefinitely.
3064 * This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only
3065 * called with the scheduler suspended, not from within a critical section. It
3066 * is therefore possible for an interrupt to request a context switch between
3067 * portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being
3068 * entered. eTaskConfirmSleepModeStatus() should be called from a short
3069 * critical section between the timer being stopped and the sleep mode being
3070 * entered to ensure it is ok to proceed into the sleep mode.
3072 eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;
3075 * For internal use only. Increment the mutex held count when a mutex is
3076 * taken and return the handle of the task that has taken the mutex.
3078 TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;
3081 * For internal use only. Same as vTaskSetTimeOutState(), but without a critical
3084 void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
3087 * For internal use only. Same as portYIELD_WITHIN_API() in single core FreeRTOS.
3088 * For SMP this is not defined by the port.
3090 void vTaskYieldWithinAPI( void );
3097 #endif /* INC_TASK_H */