AM261x MCU+ SDK: Queue

| AM261x MCU+ SDK 26.00.00 |

Queue

# Features Supported

- APIs to create and destroy Queues
- APIs to Put element in Queue
- APIs to Get element from Queue
- APIs to Check if Queue is Empty

# Features NOT Supported

NA

# Important Usage Guidelines

- For creating the Queue application needs to provide the QueueP_Object and it should not be modified by the applicaion.
- A field of type QueueP_Elem should be placed at the head of client structs passed as Queue Elements to function QueueP_put.
- It is recommended not to place the QueueP Object and QueueP Element objects in stack as they will be accessed by the driver till they are released.

# Example Usage

Include the below file to access the APIs,

#include <kernel/dpl/QueueP.h>

Example usage define Queue Object and Elements

/* Define a client structure for the queue elements.
The object of type QueueP_Elem should be placed at the head of the structure. */
typedef struct Test_Queue_Elem_s
{
QueueP_Elem lnk;
uint32_t index;
} Test_Queue_Elem;
Test_Queue_Elem elem1, elem2;
QueueP_Object qObj;

Example to Create and use the Queue

QueueP_Handle handle;
Test_Queue_Elem *pElem;
/* Create the Queue. */
handle = QueueP_create(&qObj);
/* Put elements in a Queue. */
QueueP_put(handle, (QueueP_Elem *)&elem1);
QueueP_put(handle, (QueueP_Elem *)&elem2);
/* Get elements from the queue. */
pElem = (Test_Queue_Elem *)QueueP_get(handle);
pElem = (Test_Queue_Elem *)QueueP_get(handle);
/* Typically pElem would be processed by application.
* In sample typecast to void to kill warning
* regarding variable set but not used
*/
(void) pElem;
QueueP_delete(handle);

# API

APIs for Queue

QueueP_Elem
Opaque QueueP element.
Definition: QueueP.h:70
QueueP_create
QueueP_Handle QueueP_create(QueueP_Object *obj)
Function to create a queue.
QueueP_put
int32_t QueueP_put(QueueP_Handle handle, void *elem)
Function to Put an element at end of queue.
QueueP.h
QueueP_Object
Opaque task object used with the task APIs.
Definition: QueueP.h:81
QueueP_delete
int32_t QueueP_delete(QueueP_Handle handle)
Function to delete a queue.
QueueP_get
void * QueueP_get(QueueP_Handle handle)
Function to Get the element at the front of the queue. This function removes an element from the fron...