The xQueueCreate() API Function. FreeRTOS Real Time Kernel
Mainos
Mainos
161204 Pre-release for FreeRTOS V8.x.x. See http://www.FreeRTOS.org/FreeRTOS-V9.html
for information about FreeRTOS
V9.x.x. Use http://www.FreeRTOS.org/contact to provide feedback, corrections, and check for updates.
4.3 Using a Queue
The xQueueCreate() API Function
A queue must be explicitly created before it can be used.
Queues are referenced by handles, which are variables of type QueueHandle_t. The xQueueCreate() API function creates a queue and returns a QueueHandle_t that references the queue it created.
FreeRTOS V9.0.0 also includes the xQueueCreateStatic() function, which allocates the memory required to create a queue statically at compile time
: FreeRTOS allocates RAM from the FreeRTOS heap when a queue is created. The RAM is used to hold both the queue data structures and the items that are contained in the queue. xQueueCreate() will return NULL if there is insufficient heap RAM
available for the queue to be created. Chapter 2 provides more information on the FreeRTOS
heap.
QueueHandle_t xQueueCreate( UBaseType_t uxQueueLength, UBaseType_t uxItemSize );
Listing 40. The xQueueCreate() API function prototype
Parameter Name
Table 18. xQueueCreate() parameters and return value
Description
uxQueueLength The maximum number of items that the queue being created can hold at any one time. uxItemSize
Return Value
The size in bytes of each data item that can be stored in the queue.
If NULL is returned, then the queue cannot be created because there is insufficient heap memory available for FreeRTOS to allocate the queue data structures and storage area.
A non-NULL value being returned indicates that the queue has been created successfully. The returned value should be stored as the handle to the created queue.
After a queue has been created the xQueueReset() API function can be used to return the queue to its original empty state.
108
Lataa
Mainos