Jeremy

LanguageENZH

freeRTOS API Reference

Update: 2026-07-01

1.Task

Task Creation


// Create a new task and add it to the list of tasks that are ready to run.
BaseType_t xTaskCreate( TaskFunction_t pvTaskCode,
                         const char * const pcName,
                         const configSTACK_DEPTH_TYPE uxStackDepth,
                         void *pvParameters,
                         UBaseType_t uxPriority,
                         TaskHandle_t *pxCreatedTask
                       );

// Create a new task and add it to the list of tasks that are ready to run.
TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
                                 const char * const pcName,
                                 const uint32_t ulStackDepth,
                                 void * const pvParameters,
                                 UBaseType_t uxPriority,
                                 StackType_t * const puxStackBuffer,
                                 StaticTask_t * const pxTaskBuffer );

/**
 * Create a new Memory Protection Unit (MPU) restricted task and add it to the list of tasks that are ready to run.
 */
BaseType_t xTaskCreateRestrictedStatic( TaskParameters_t *pxTaskDefinition,
                                        TaskHandle_t *pxCreatedTask );


// Remove a task from the RTOS kernels management. The task being deleted will be removed from all ready, blocked, suspended and event lists.
void vTaskDelete( TaskHandle_t xTask );

Task Control


// Delay a task for a given number of ticks. The actual time that the task remains blocked depends on the tick rate.
void vTaskDelay( const TickType_t xTicksToDelay );

// Delay a task until a specified time.
void vTaskDelayUntil( TickType_t *pxPreviousWakeTime,
                      const TickType_t xTimeIncrement );

UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask );

void vTaskPrioritySet( TaskHandle_t xTask,
                       UBaseType_t uxNewPriority );

// Suspend any task. When suspended a task will never get any microcontroller processing time, no matter what its priority.
void vTaskSuspend( TaskHandle_t xTaskToSuspend );

// Resumes a suspended task.
void vTaskResume( TaskHandle_t xTaskToResume );

// A function to resume a suspended task that can be called from within an ISR.
BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume );

// Forces a task to leave the Blocked state, and enter the Ready state, even if the event the task was in the Blocked state to wait for has not occurred, and any specified timeout has not expired.
BaseType_t xTaskAbortDelay( TaskHandle_t xTask );

// Obtain the priority of any task. This function is safe to use from within an interrupt service routine (ISR).
UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask );

// Obtain the base priority of any task.
UBaseType_t uxTaskBasePriorityGet( const TaskHandle_t xTask );

// Obtain the base priority of any task.
UBaseType_t uxTaskBasePriorityGetFromISR( const TaskHandle_t xTask );

Task Utilities


UBaseType_t uxTaskGetSystemState(
                       TaskStatus_t * const pxTaskStatusArray,
                       const UBaseType_t uxArraySize,
                       unsigned long * const pulTotalRunTime );

void vTaskGetInfo( TaskHandle_t xTask,
                   TaskStatus_t *pxTaskStatus,
                   BaseType_t xGetFreeStackSpace,
                   eTaskState eState );

TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask );
TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );


UBaseType_t uxTaskGetStackHighWaterMark
 ( TaskHandle_t xTask );

configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2
 ( TaskHandle_t xTask );


BaseType_t xTaskCallApplicationTaskHook(
                                         TaskHandle_t xTask,
                                         void *pvParameter );

void vTaskSetApplicationTaskTag(
                                 TaskHandle_t xTask,
                                 TaskHookFunction_t pxTagValue );

void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet,
                                        BaseType_t xIndex,
                                        void *pvValue )

void *pvTaskGetThreadLocalStoragePointer(
                                 TaskHandle_t xTaskToQuery,
                                 BaseType_t xIndex );

void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut );

BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut,
                                 TickType_t * const pxTicksToWait );

eSleepModeStatus eTaskConfirmSleepModeStatus( void );

2. RTOS kernel control


// The taskENTER_CRITICAL() and taskEXIT_CRITICAL() macros provide a basic critical section implementation that works by simply disabling interrupts, either globally, or up to a specific interrupt priority level. See the vTaskSuspendAll() RTOS API function for information on creating a critical section without disabling interrupts.
void taskENTER_CRITICAL( void );
void taskEXIT_CRITICAL( void );

// The taskENTER_CRITICAL_FROM_ISR() and taskEXIT_CRITICAL_FROM_ISR() macros provide a basic critical section implementation that works by simply disabling interrupts, either globally, or up to a specific interrupt priority level.
UBaseType_t taskENTER_CRITICAL_FROM_ISR( void );
void taskEXIT_CRITICAL_FROM_ISR( UBaseType_t uxSavedInterruptStatus );

// Starts the RTOS scheduler. After calling the RTOS kernel has control over which tasks are executed and when.
void vTaskStartScheduler( void );

// Stops the RTOS kernel tick.
void vTaskEndScheduler( void );

// Suspends the scheduler.
void vTaskSuspendAll( void );

// Resumes the scheduler after it was suspended using a call to vTaskSuspendAll().
BaseType_t xTaskResumeAll( void );

void vTaskStepTick( TickType_t xTicksToJump );

BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp );

Direct to task notifications


// ulTaskNotifyTake() and ulTaskNotifyTakeIndexed() are equivalent macros - the only difference being ulTaskNotifyTakeIndexed() can operate on any task notification within the array and ulTaskNotifyTake() always operates on the task notification at array index 0.
BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );

BaseType_t xTaskNotifyGiveIndexed( TaskHandle_t xTaskToNotify,
                                  UBaseType_t uxIndexToNotify );

// Versions of xTaskNotifyGive() and xTaskNotifyGiveIndexed() that can be used from an interrupt service routine (ISR).
void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify,
                             BaseType_t *pxHigherPriorityTaskWoken );

void vTaskNotifyGiveIndexedFromISR( TaskHandle_t xTaskHandle,
                                    UBaseType_t uxIndexToNotify,
                                    BaseType_t *pxHigherPriorityTaskWoken );

uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit,
                           TickType_t xTicksToWait );

uint32_t ulTaskNotifyTakeIndexed( UBaseType_t uxIndexToWaitOn,
                                  BaseType_t xClearCountOnExit,
                                  TickType_t xTicksToWait );

BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify,
                        uint32_t ulValue,
                        eNotifyAction eAction );

BaseType_t xTaskNotifyIndexed( TaskHandle_t xTaskToNotify,
                              UBaseType_t uxIndexToNotify,
                              uint32_t ulValue,
                              eNotifyAction eAction );

// xTaskNotifyAndQueryIndexed() performs the same operation as xTaskNotifyIndexed() with the addition that it also returns the target task's prior notification value
BaseType_t xTaskNotifyAndQuery( TaskHandle_t xTaskToNotify,
                                uint32_t ulValue,
                                eNotifyAction eAction,
                                uint32_t *pulPreviousNotifyValue );

BaseType_t xTaskNotifyAndQueryIndexed( TaskHandle_t xTaskToNotify,
                                      UBaseType_t uxIndexToNotify,
                                      uint32_t ulValue,
                                      eNotifyAction eAction,
                                      uint32_t *pulPreviousNotifyValue );

BaseType_t xTaskNotifyAndQueryFromISR(
                    TaskHandle_t xTaskToNotify,
                    uint32_t ulValue,
                    eNotifyAction eAction,
                    uint32_t *pulPreviousNotifyValue,
                    BaseType_t *pxHigherPriorityTaskWoken );

BaseType_t xTaskNotifyAndQueryIndexedFromISR(
                    TaskHandle_t xTaskToNotify,
                    UBaseType_t uxIndexToNotify
                    uint32_t ulValue,
                    eNotifyAction eAction,
                    uint32_t *pulPreviousNotifyValue,
                    BaseType_t *pxHigherPriorityTaskWoken );


 BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify,
                                uint32_t ulValue,
                                eNotifyAction eAction,
                                BaseType_t *pxHigherPriorityTaskWoken );

 BaseType_t xTaskNotifyIndexedFromISR( TaskHandle_t xTaskToNotify,
                                       UBaseType_t uxIndexToNotify,
                                       uint32_t ulValue,
                                       eNotifyAction eAction,
                                       BaseType_t *pxHigherPriorityTaskWoken );


// xTaskNotifyWait() waits, with an optional timeout, for the calling task to receive a notification. If the receiving RTOS task was already Blocked waiting for a notification when the notification it is waiting for arrives the receiving RTOS task will be removed from the Blocked state and the notification cleared.
BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry,
                            uint32_t ulBitsToClearOnExit,
                            uint32_t *pulNotificationValue,
                            TickType_t xTicksToWait );

BaseType_t xTaskNotifyWaitIndexed( UBaseType_t uxIndexToWaitOn,
                                  uint32_t ulBitsToClearOnEntry,
                                  uint32_t ulBitsToClearOnExit,
                                  uint32_t *pulNotificationValue,
                                  TickType_t xTicksToWait );

// If a notification is sent to an index within the array of notifications then the notification at that index is said to be 'pending' until the task reads its notification value or explicitly clears the notification state to 'not pending' by calling xTaskNotifyStateClear().

BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );

BaseType_t xTaskNotifyStateClearIndexed( TaskHandle_t xTask,
                                         UBaseType_t uxIndexToClear );


uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask,
                                 uint32_t ulBitsToClear );

uint32_t ulTaskNotifyValueClearIndexed( TaskHandle_t xTask,
                                        UBaseType_t uxIndexToClear,
                                        uint32_t ulBitsToClear );

3.Queues

Queue Management


// Creates a new queue and returns a handle by which the queue can be referenced.
QueueHandle_t xQueueCreate( UBaseType_t uxQueueLength,
                            UBaseType_t uxItemSize );

QueueHandle_t xQueueCreateStatic(
                            UBaseType_t uxQueueLength,
                            UBaseType_t uxItemSize,
                            uint8_t *pucQueueStorageBuffer,
                            StaticQueue_t *pxQueueBuffer );

// Post an item on a queue. The item is queued by copy, not by reference.
BaseType_t xQueueSend(
                      QueueHandle_t xQueue,
                      const void * pvItemToQueue,
                      TickType_t xTicksToWait
                    );

BaseType_t xQueueSendFromISR(
                              QueueHandle_t xQueue,
                              const void *pvItemToQueue,
                              BaseType_t *pxHigherPriorityTaskWoken
                            );

// Post an item to the back of a queue. The item is queued by copy, not by reference.
BaseType_t xQueueSendToBack(
                            QueueHandle_t xQueue,
                            const void * pvItemToQueue,
                            TickType_t xTicksToWait
                          );

BaseType_t xQueueSendToBackFromISR(
                                   QueueHandle_t xQueue,
                                   const void *pvItemToQueue,
                                   BaseType_t *pxHigherPriorityTaskWoken
                                  );

// Post an item to the front of a queue. The item is queued by copy, not by reference.
BaseType_t xQueueSendToFront( QueueHandle_t xQueue,
                              const void * pvItemToQueue,
                              TickType_t xTicksToWait
                            );

BaseType_t xQueueSendToFrontFromISR(
                                    QueueHandle_t xQueue,
                                    const void *pvItemToQueue,
                                    BaseType_t *pxHigherPriorityTaskWoken
                                   );
// Receive an item from a queue. The item is received by copy so a buffer of adequate size must be provided.
BaseType_t xQueueReceive(
                          QueueHandle_t xQueue,
                          void *pvBuffer,
                          TickType_t xTicksToWait
                        );

BaseType_t xQueueReceiveFromISR(
                                 QueueHandle_t xQueue,
                                 void *pvBuffer,
                                 BaseType_t *pxHigherPriorityTaskWoken
                               );

// A version of xQueueSendToBack() that will write to the queue even if the queue is full, overwriting data that is already held in the queue.
BaseType_t xQueueOverwrite(
                            QueueHandle_t xQueue,
                            const void * pvItemToQueue
                          );

BaseType_t xQueueOverwrite(
                           QueueHandle_t xQueue,
                           const void * pvItemToQueue,
                           BaseType_t *pxHigherPriorityTaskWoken
                          );

// This is a macro that calls the xQueueGenericReceive() function.
// Receive an item from a queue without removing the item from the queue.
BaseType_t xQueuePeek(
                      QueueHandle_t xQueue,
                      void *pvBuffer,
                      TickType_t xTicksToWait
                    );

BaseType_t xQueuePeekFromISR(
                              QueueHandle_t xQueue,
                              void *pvBuffer,
                             );

// Assigns a name to a queue and adds the queue to the registry.
void vQueueAddToRegistry(
                          QueueHandle_t xQueue,
                          char *pcQueueName,
                        );

// Removes a queue from the queue registry.
void vQueueUnregisterQueue( QueueHandle_t xQueue );

// Look up a queue name from the queue's handle.
const char *pcQueueGetName( QueueHandle_t xQueue );

// Retrieve pointers to a statically created queue's data structure buffer and storage area buffer. These are the same buffers that are supplied at the time of creation.
BaseType_t xQueueGetStaticBuffers( QueueHandle_t xQueue,
                                  uint8_t ** ppucQueueStorage,
                                  StaticQueue_t ** ppxStaticQueue );

Queue Set


// Queue sets provide a mechanism to allow an RTOS task to block (pend) on a read operation from multiple RTOS queues or semaphores simultaneously.
QueueSetHandle_t xQueueCreateSet(
                                 const UBaseType_t uxEventQueueLength
                                );

QueueSetHandle_t xQueueCreateSetStatic( const UBaseType_t uxEventQueueLength,
                                        uint8_t * pucQueueStorage,
                                        StaticQueue_t * pxStaticQueue );

// Adds an RTOS queue or semaphore to a queue set that was previously created by a call to xQueueCreateSet().
BaseType_t xQueueAddToSet(
                          QueueSetMemberHandle_t xQueueOrSemaphore,
                          QueueSetHandle_t xQueueSet
                         );

// Remove an RTOS queue or semaphore from a queue set.
BaseType_t xQueueRemoveFromSet(
                               QueueSetMemberHandle_t xQueueOrSemaphore,
                               QueueSetHandle_t xQueueSet
                              );

// xQueueSelectFromSet() effectively allows a task to block (pend) on a read operation on all the queues and semaphores in a queue set simultaneously.
QueueSetMemberHandle_t xQueueSelectFromSet(
                                           QueueSetHandle_t xQueueSet,
                                           const TickType_t xTicksToWait
                                          );

QueueSetMemberHandle_t xQueueSelectFromSetFromISR(
                                                  QueueSetHandle_t xQueueSet
                                                 );

4.Stream buffers


// Creates a new stream buffer that uses dynamically allocated memory.
StreamBufferHandle_t xStreamBufferCreate( size_t xBufferSizeBytes,
                                           size_t xTriggerLevelBytes );

StreamBufferHandle_t xStreamBufferCreateWithCallback(
                         size_t xBufferSizeBytes,
                         size_t xTriggerLevelBytes
                         StreamBufferCallbackFunction_t pxSendCompletedCallback,
                         StreamBufferCallbackFunction_t pxReceiveCompletedCallback );
// 其中
void vSendCallbackFunction( StreamBufferHandle_t xStreamBuffer,
                            BaseType_t xIsInsideISR,
                            BaseType_t * const pxHigherPriorityTaskWoken );

void vReceiveCallbackFunction( StreamBufferHandle_t xStreamBuffer,
                               BaseType_t xIsInsideISR,
                               BaseType_t * const pxHigherPriorityTaskWoken );

StreamBufferHandle_t xStreamBufferCreateStatic(
                                    size_t xBufferSizeBytes,
                                    size_t xTriggerLevelBytes,
                                    uint8_t *pucStreamBufferStorageArea,
                                    StaticStreamBuffer_t *pxStaticStreamBuffer );

StreamBufferHandle_t xStreamBufferCreateStaticWithCallback(
                                    size_t xBufferSizeBytes,
                                    size_t xTriggerLevelBytes,
                                    uint8_t *pucStreamBufferStorageArea,
                                    StaticStreamBuffer_t *pxStaticStreamBuffer,
                                    StreamBufferCallbackFunction_t pxSendCompletedCallback,
                                    StreamBufferCallbackFunction_t pxReceiveCompletedCallback );

// Sends bytes to a stream buffer. The bytes are copied into the stream buffer.
size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
                          const void *pvTxData,
                          size_t xDataLengthBytes,
                          TickType_t xTicksToWait );

size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
                                 const void *pvTxData,
                                 size_t xDataLengthBytes,
                                 BaseType_t *pxHigherPriorityTaskWoken );

// Receives bytes from a stream buffer.
size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
                             void *pvRxData,
                             size_t xBufferLengthBytes,
                             TickType_t xTicksToWait );


size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
                                    void *pvRxData,
                                    size_t xBufferLengthBytes,
                                    BaseType_t *pxHigherPriorityTaskWoken);

//Deletes a stream buffer that was previously created using a call to xStreamBufferCreate() or xStreamBufferCreateStatic().
void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer );

// Queries a stream buffer to see how much data it contains, which is equal to the number of bytes that can be read from the stream buffer before the stream buffer would be empty.
size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer );

// Queries a stream buffer to see how much free space it contains, which is equal to the amount of data that can be sent to the stream buffer before it is full.
size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer );

// A stream buffer's trigger level is the number of bytes that must be in the stream buffer before a task that is blocked on the stream buffer to wait for data is moved out of the blocked state.
BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer,
                                         size_t xTriggerLevel );

// Resets a stream buffer to its initial, empty, state.
BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer );

// Queries a stream buffer to see if it is empty. A stream buffer is empty if it does not contain any data.
BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer );

// Queries a stream buffer to see if it is full. A stream buffer is full if it does not have any free space, and therefore cannot accept any more data.
BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer );

// Resets a stream buffer to its initial, empty, state.
BaseType_t xStreamBufferResetFromISR( StreamBufferHandle_t xStreamBuffer );

// Retrieve pointers to a statically created stream buffer's data structure buffer and storage area buffer. These are the same buffers that are supplied at the time of creation.
BaseType_t xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffer,
                                          uint8_t ** ppucStreamBufferStorageArea,
                                          StaticStreamBuffer_t ** ppxStaticStreamBuffer );

// Retrieves the task notification index used for the supplied stream buffer, which can be set using vStreamBufferSetStreamBufferNotificationIndex.
UBaseType_t uxStreamBufferGetStreamBufferNotificationIndex( StreamBufferHandle_t xStreamBuffer );

// Sets the task notification index used for the supplied stream buffer.
void vStreamBufferSetStreamBufferNotificationIndex( StreamBufferHandle_t xStreamBuffer,
                                                    UBaseType_t uxNotificationIndex );

// Creates a new stream batching buffer using dynamically allocated memory.
StreamBufferHandle_t xStreamBatchingBufferCreate( size_t xBufferSizeBytes,
                                                  size_t xTriggerLevelBytes );

StreamBufferHandle_t xStreamBatchingBufferCreateWithCallback(
                         size_t xBufferSizeBytes,
                         size_t xTriggerLevelBytes
                         StreamBufferCallbackFunction_t pxSendCompletedCallback,
                         StreamBufferCallbackFunction_t pxReceiveCompletedCallback );

StreamBufferHandle_t xStreamBatchingBufferCreateStatic( size_t xBufferSizeBytes,
                                                        size_t xTriggerLevelBytes,
                                                        uint8_t *pucStreamBufferStorageArea,
                                                        StaticStreamBuffer_t *pxStaticStreamBuffer );

StreamBufferHandle_t xStreamBatchingBufferCreateStaticWithCallback(
                                    size_t xBufferSizeBytes,
                                    size_t xTriggerLevelBytes,
                                    uint8_t *pucStreamBufferStorageArea,
                                    StaticStreamBuffer_t *pxStaticStreamBuffer,
                                    StreamBufferCallbackFunction_t pxSendCompletedCallback,
                                    StreamBufferCallbackFunction_t pxReceiveCompletedCallback );

5.Message buffers


// Creates a new message buffer that uses dynamically allocated memory. 
MessageBufferHandle_t xMessageBufferCreate( size_t xBufferSizeBytes );

MessageBufferHandle_t xMessageBufferCreateWithCallback( 
                          size_t xBufferSizeBytes,
                          StreamBufferCallbackFunction_t pxSendCompletedCallback,
                          StreamBufferCallbackFunction_t pxReceiveCompletedCallback );

// Creates a new message buffer using statically allocated memory. 
MessageBufferHandle_t xMessageBufferCreateStatic(
                          size_t xBufferSizeBytes,
                          uint8_t *pucMessageBufferStorageArea,
                          StaticMessageBuffer_t *pxStaticMessageBuffer );

MessageBufferHandle_t xMessageBufferCreateStaticWithCallback(
                          size_t xBufferSizeBytes,
                          uint8_t *pucMessageBufferStorageArea,
                          StaticMessageBuffer_t *pxStaticMessageBuffer,
                          StreamBufferCallbackFunction_t pxSendCompletedCallback,
                          StreamBufferCallbackFunction_t pxReceiveCompletedCallback );

// Sends a discrete message to a message buffer.
size_t xMessageBufferSend( MessageBufferHandle_t xMessageBuffer,
                           const void *pvTxData,
                           size_t xDataLengthBytes,
                           TickType_t xTicksToWait );

// Interrupt safe version of the API function that sends a discrete message to the message buffer.
size_t xMessageBufferSendFromISR( MessageBufferHandle_t xMessageBuffer,
                                  const void *pvTxData,
                                  size_t xDataLengthBytes,
                                  BaseType_t *pxHigherPriorityTaskWoken );

// Receives a discrete message from an RTOS message buffer. 
size_t xMessageBufferReceive( MessageBufferHandle_t xMessageBuffer,
                              void *pvRxData,
                              size_t xBufferLengthBytes,
                              TickType_t xTicksToWait );

size_t xMessageBufferReceiveFromISR( MessageBufferHandle_t xMessageBuffer,
                                     void *pvRxData,
                                     size_t xBufferLengthBytes,
                                     BaseType_t *pxHigherPriorityTaskWoken );

// Deletes a message buffer that was previously created using a call to xMessageBufferCreate() or xMessageBufferCreateStatic().
void vMessageBufferDelete( MessageBufferHandle_t xMessageBuffer );

// Queries a message buffer to see how much free space it contains, which is equal to the amount of data that can be sent to the message buffer before it is full.
size_t xMessageBufferSpacesAvailable( MessageBufferHandle_t xMessageBuffer );

// Resets a message buffer to its initial, empty, state. Any data that was in the message buffer is discarded.
BaseType_t xMessageBufferReset( MessageBufferHandle_t xMessageBuffer );

// Queries a message buffer to see if it is empty. A
BaseType_t xMessageBufferIsEmpty( MessageBufferHandle_t xMessageBuffer );

// Queries a message buffer to see if it is full. 
BaseType_t xMessageBufferIsFull( MessageBufferHandle_t xMessageBuffer );

// An interrupt safe version of the xMessageBufferReset() API function.
BaseType_t xMessageBufferResetFromISR( MessageBufferHandle_t xMessageBuffer );

// configSUPPORT_STATIC_ALLOCATION must be defined as 1 for this function to be available.
BaseType_t xMessageBufferGetStaticBuffers( MessageBufferHandle_t xMessageBuffer,
                                           uint8_t ** ppucMessageBufferStorageArea,
                                           StaticMessageBuffer_t ** ppxStaticMessageBuffer );

6. Semaphore and Mutexes

Semaphores


// Creates a binary semaphore, and returns a handle by which the semaphore can be referenced.
SemaphoreHandle_t xSemaphoreCreateBinary( void );

SemaphoreHandle_t xSemaphoreCreateBinaryStatic(
                          StaticSemaphore_t *pxSemaphoreBuffer );

// Creates a counting semaphore and returns a handle by which the newly created semaphore can be referenced.
SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount,
                                            UBaseType_t uxInitialCount);

SemaphoreHandle_t xSemaphoreCreateCountingStatic(
                                 UBaseType_t uxMaxCount,
                                 UBaseType_t uxInitialCount
                                 StaticSemaphore_t *pxSemaphoreBuffer );

// Returns the count of a semaphore.
UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xSemaphore );

// Macro to obtain a semaphore.
// The semaphore must have previously been created with a call to
// xSemaphoreCreateBinary(), xSemaphoreCreateMutex() or xSemaphoreCreateCounting()
xSemaphoreTake( SemaphoreHandle_t xSemaphore,
                 TickType_t xTicksToWait );

// A version of xSemaphoreTake() that can be called from an ISR.
xSemaphoreTakeFromISR(
                  SemaphoreHandle_t xSemaphore,
                  signed BaseType_t *pxHigherPriorityTaskWoken);

// Macro to recursively obtain, or 'take', a mutex type semaphore. 
// The mutex must have previously been created using a call to xSemaphoreCreateRecursiveMutex();
xSemaphoreTakeRecursive( SemaphoreHandle_t xMutex,
                         TickType_t xTicksToWait );
                       
// Macro to release a semaphore.
// The semaphore must have previously been created with a call to
// xSemaphoreCreateBinary(), xSemaphoreCreateMutex() or xSemaphoreCreateCounting()
xSemaphoreGive( SemaphoreHandle_t xSemaphore );

// Macro to recursively release, or 'give', a mutex type semaphore.
xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex )

// Macro to release a semaphore. 
xSemaphoreGiveFromISR(SemaphoreHandle_t xSemaphore,
                      signed BaseType_t *pxHigherPriorityTaskWoken)

// Deletes a semaphore, including mutex type semaphores and recursive semaphores.
void vSemaphoreDelete( SemaphoreHandle_t xSemaphore );

Mutexes


// Creates a mutex, and returns a handle by which the created mutex can be referenced.
SemaphoreHandle_t xSemaphoreCreateMutex( void )

SemaphoreHandle_t xSemaphoreCreateMutexStatic(
                            StaticSemaphore_t *pxMutexBuffer );

// reates a recursive mutex, and returns a handle by which the mutex can be referenced. 
// Recursive mutexes cannot be used in interrupt service routines.
SemaphoreHandle_t xSemaphoreCreateRecursiveMutex( void )

SemaphoreHandle_t xSemaphoreCreateRecursiveMutexStatic(
                              StaticSemaphore_t *pxMutexBuffer );

// Return the handle of the task that holds the mutex specified by the function parameter, if any.
TaskHandle_t xSemaphoreGetMutexHolder( SemaphoreHandle_t xMutex );

7. Software Timers


// Creates a new software timer instance and returns a handle by which the timer can be referenced.
TimerHandle_t xTimerCreate( const char * const pcTimerName,
                            const TickType_t xTimerPeriod,
                            const UBaseType_t uxAutoReload,
                            void * const pvTimerID,
                            TimerCallbackFunction_t pxCallbackFunction );


// Queries a software timer to see if it is active or dormant.
// A timer will be dormant if:
// It has been created but not started, or
// It is an expired one-shot timer that has not been restarted.
BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer );

// starts a timer that was previously created using the xTimerCreate() API function. 
BaseType_t xTimerStart( TimerHandle_t xTimer,
                          TickType_t xBlockTime );

// xTimerStop() stops a timer that was previously started using either of the 
// xTimerStart(), xTimerReset(), xTimerStartFromISR(), 
// xTimerResetFromISR(), xTimerChangePeriod(), 
// and xTimerChangePeriodFromISR() API functions.
BaseType_t xTimerStop( TimerHandle_t xTimer,
                      TickType_t xBlockTime );

// changes the period of a timer that was previously created using the xTimerCreate() API function.
BaseType_t xTimerChangePeriod( TimerHandle_t xTimer,
                              TickType_t xNewPeriod,
                              TickType_t xBlockTime );

// xTimerDelete() deletes a timer that was previously created using the xTimerCreate() API function.
BaseType_t xTimerDelete( TimerHandle_t xTimer,
                        TickType_t xBlockTime );
                              
// re-starts a timer that was previously created using the xTimerCreate() API function.
BaseType_t xTimerReset( TimerHandle_t xTimer,
                        TickType_t xBlockTime );

// A version of xTimerStart() that can be called from an interrupt service routine.
BaseType_t xTimerStartFromISR(
                              TimerHandle_t xTimer,
                              BaseType_t *pxHigherPriorityTaskWoken
                             );

// A version of xTimerStop() that can be called from an interrupt service routine.
BaseType_t xTimerStopFromISR(
                             TimerHandle_t xTimer,
                             BaseType_t *pxHigherPriorityTaskWoken
                            );

// A version of xTimerChangePeriod() that can be called from an interrupt service routine.
BaseType_t xTimerChangePeriodFromISR(
                                     TimerHandle_t xTimer,
                                     TickType_t xNewPeriod,
                                     BaseType_t *pxHigherPriorityTaskWoken
                                    );

// A version of xTimerReset() that can be called from an interrupt service routine.
BaseType_t xTimerResetFromISR(
                              TimerHandle_t xTimer,
                              BaseType_t *pxHigherPriorityTaskWoken
                             );

// Returns the ID assigned to the software timer.
void *pvTimerGetTimerID( TimerHandle_t xTimer );

// Updates the 'mode' of a software timer to be either an auto reload timer or a one-shot timer.
// Set uxAutoReload to pdTRUE to set the timer into auto reload mode, 
// or pdFALSE to set the timer into one shot mode.
void vTimerSetReloadMode( TimerHandle_t xTimer,
                          const UBaseType_t uxAutoReload );

// An identifier (ID) is assigned to a software timer when the timer is created, 
// and can be changed at any time using the vTimerSetTimerID() API function.
void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID );

// Used to pend the execution of a function to the RTOS daemon task
// void vPendableFunction( void * pvParameter1, uint32_t ulParameter2 );
BaseType_t xTimerPendFunctionCall(
                            PendedFunction_t xFunctionToPend,
                            void *pvParameter1,
                            uint32_t ulParameter2,
                            TickType_t xTicksToWait );

// void vPendableFunction( void * pvParameter1, uint32_t ulParameter2 );
BaseType_t xTimerPendFunctionCallFromISR(
                       PendedFunction_t xFunctionToPend,
                       void *pvParameter1,
                       uint32_t ulParameter2,
                       BaseType_t *pxHigherPriorityTaskWoken );

// Returns the human readable text name of a software timer.
const char * pcTimerGetName( TimerHandle_t xTimer );

// Returns the period of a software timer. The period is specified in ticks.
TickType_t xTimerGetPeriod( TimerHandle_t xTimer );

// Returns the time at which the software timer will expire, 
// which is the time at which the timer's callback function will execute.
TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer );

// Creates a new software timer instance and 
// returns a handle by which the timer can be referenced.
TimerHandle_t xTimerCreateStatic( const char * const pcTimerName,
                                  const TickType_t xTimerPeriod,
                                  const UBaseType_t uxAutoReload,
                                  void * const pvTimerID,
                                  TimerCallbackFunction_t pxCallbackFunction
                                  StaticTimer_t *pxTimerBuffer );

BaseType_t  xTimerGetReloadMode( TimerHandle_t xTimer );
UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer );

8. Event Groups


// Creates a new RTOS event group, 
// and returns a handle by which the newly created event group can be referenced.
EventGroupHandle_t xEventGroupCreate( void );

EventGroupHandle_t xEventGroupCreateStatic(
                             StaticEventGroup_t *pxEventGroupBuffer );

// Delete an event group that was previously created using a call to xEventGroupCreate().
void vEventGroupDelete( EventGroupHandle_t xEventGroup );

// Read bits within an RTOS event group, 
// optionally entering the Blocked state (with a timeout) to wait 
// for a bit or group of bits to become set.
EventBits_t xEventGroupWaitBits(
                      const EventGroupHandle_t xEventGroup,
                      const EventBits_t uxBitsToWaitFor,
                      const BaseType_t xClearOnExit,
                      const BaseType_t xWaitForAllBits,
                      TickType_t xTicksToWait );

// Set bits (flags) within an RTOS event group.
EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup,
                                const EventBits_t uxBitsToSet );

BaseType_t xEventGroupSetBitsFromISR(
                         EventGroupHandle_t xEventGroup,
                         const EventBits_t uxBitsToSet,
                         BaseType_t *pxHigherPriorityTaskWoken );

// Clear bits (flags) within an RTOS event group.
EventBits_t xEventGroupClearBits(
                                  EventGroupHandle_t xEventGroup,
                                  const EventBits_t uxBitsToClear );

// A version of xEventGroupClearBits() that can be called from an interrupt.
BaseType_t xEventGroupClearBitsFromISR(
                               EventGroupHandle_t xEventGroup,
                               const EventBits_t uxBitsToClear );

// Returns the current value of the event bits (event flags) in an RTOS event group.
EventBits_t xEventGroupGetBits( EventGroupHandle_t xEventGroup );

EventBits_t xEventGroupGetBitsFromISR(
                              EventGroupHandle_t xEventGroup );

// Atomically set bits (flags) within an RTOS event group,
// then wait for a combination of bits to be set within the same event group.
EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
                             const EventBits_t uxBitsToSet,
                             const EventBits_t uxBitsToWaitFor,
                             TickType_t xTicksToWait );

// Retrieve a pointer to a statically created event group's data structure buffer.
// It is the same buffer that is supplied at the time of creation.
BaseType_t xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
                                       StaticEventGroup_t ** ppxEventGroupBuffer );               

9. Memory Protection Unit (MPU)


// Create a new Memory Protection Unit (MPU) restricted task 
// and add it to the list of tasks that are ready to run.
BaseType_t xTaskCreateRestricted(
                            TaskParameters_t *pxTaskDefinition,
                            TaskHandle_t *pxCreatedTask );

BaseType_t xTaskCreateRestrictedStatic( TaskParameters_t *pxTaskDefinition,
                                        TaskHandle_t *pxCreatedTask );

// Memory regions are assigned to a restricted task
// when the task is created using a call to xTaskCreateRestricted().
void vTaskAllocateMPURegions(
               TaskHandle_t xTaskToModify,
               const MemoryRegion_t * const xRegions );

// Sets the calling task into User mode.
void portSWITCH_TO_USER_MODE( void );

10. Co-routines


// Create a new co-routine and add it to the list of co-routines that are ready to run.
BaseType_t xCoRoutineCreate(
                            crCOROUTINE_CODE pxCoRoutineCode,
                            UBaseType_t uxPriority,
                            UBaseType_t uxIndex
                           );

// Delay a co-routine for a fixed period of time.
void crDELAY( CoRoutineHandle_t xHandle,
              TickType_t xTicksToDelay )

// The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine equivalent to the 
// xQueueSend() and xQueueReceive() functions used by tasks.
crQUEUE_SEND(
              CoRoutineHandle_t xHandle,
              QueueHandle_t xQueue,
              void *pvItemToQueue,
              TickType_t xTicksToWait,
              BaseType_t *pxResult
            )

// The macros crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine equivalent to the 
// xQueueSend() and xQueueReceive() functions used by tasks.
void crQUEUE_RECEIVE(
                      CoRoutineHandle_t xHandle,
                      QueueHandle_t xQueue,
                      void *pvBuffer,
                      TickType_t xTicksToWait,
                      BaseType_t *pxResult
                    )

BaseType_t crQUEUE_SEND_FROM_ISR( QueueHandle_t xQueue,
                                  void *pvItemToQueue,
                                  BaseType_t xCoRoutinePreviouslyWoken )

BaseType_t crQUEUE_RECEIVE_FROM_ISR( QueueHandle_t xQueue,
                                  void *pvBuffer,
                                  BaseType_t * pxCoRoutineWoken )

// executes the highest priority co-routine that is able to run.
void vCoRoutineSchedule( void );

Reference

  1. FreeRTOS Offical Website