RTOS Abstraction (abstraction-rtos)
Queue

General Description

APIs for creating and working with Queues.

cy_rslt_t cy_rtos_queue_init (cy_queue_t *queue, size_t length, size_t itemsize)
 Create a queue. More...
 
cy_rslt_t cy_rtos_queue_put (cy_queue_t *queue, const void *item_ptr, cy_time_t timeout_ms)
 Put an item in a queue. More...
 
cy_rslt_t cy_rtos_queue_get (cy_queue_t *queue, void *item_ptr, cy_time_t timeout_ms)
 Gets an item in a queue. More...
 
cy_rslt_t cy_rtos_queue_count (cy_queue_t *queue, size_t *num_waiting)
 Return the number of items in the queue. More...
 
cy_rslt_t cy_rtos_queue_space (cy_queue_t *queue, size_t *num_spaces)
 Return the amount of empty space in the queue. More...
 
cy_rslt_t cy_rtos_queue_reset (cy_queue_t *queue)
 Reset the queue. More...
 
cy_rslt_t cy_rtos_queue_deinit (cy_queue_t *queue)
 Deinitialize the queue handle. More...
 
#define CY_RTOS_QUEUE_FULL    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_OS, 3)
 The Queue is already full and can't accept any more items at this time.
 
#define CY_RTOS_QUEUE_EMPTY    CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_OS, 4)
 The Queue is empty and has nothing to remove.
 
#define cy_rtos_init_queue(queue, length, itemsize)    cy_rtos_queue_init(queue, length, itemsize)
 Create a queue. More...
 
#define cy_rtos_put_queue(queue, item_ptr, timeout_ms, in_isr)    cy_rtos_queue_put(queue, item_ptr, timeout_ms)
 Put an item in a queue. More...
 
#define cy_rtos_get_queue(queue, item_ptr, timeout_ms, in_isr)    cy_rtos_queue_get(queue, item_ptr, timeout_ms)
 Gets an item in a queue. More...
 
#define cy_rtos_count_queue(queue, num_waiting)    cy_rtos_queue_count(queue, num_waiting)
 Return the number of items in the queue. More...
 
#define cy_rtos_space_queue(queue, num_spaces)    cy_rtos_queue_space(queue, num_spaces)
 Return the amount of empty space in the queue. More...
 
#define cy_rtos_reset_queue(queue)    cy_rtos_queue_reset(queue)
 Reset the queue. More...
 
#define cy_rtos_deinit_queue(queue)    cy_rtos_queue_deinit(queue)
 Deinitialize the queue handle. More...
 

Macro Definition Documentation

◆ cy_rtos_init_queue

#define cy_rtos_init_queue (   queue,
  length,
  itemsize 
)     cy_rtos_queue_init(queue, length, itemsize)

Create a queue.

This is a queue of data where entries are placed on the back of the queue and removed from the front of the queue.

Parameters
[out]queuePointer to the queue handle
[in]lengthThe maximum length of the queue in items
[in]itemsizeThe size of each item in the queue.
Returns
The status of the init request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_put_queue

#define cy_rtos_put_queue (   queue,
  item_ptr,
  timeout_ms,
  in_isr 
)     cy_rtos_queue_put(queue, item_ptr, timeout_ms)

Put an item in a queue.

This function puts an item in the queue. The item is copied into the queue using a memory copy and the data pointed to by item_ptr is no longer referenced once the call returns.

Note
If in_isr is true, timeout_ms must be zero.
Parameters
[in]queuePointer to the queue handle
[in]item_ptrPointer to the item to place in the queue
[in]timeout_msThe time to wait to place the item in the queue
[in]in_isrIf true this is being called from within and ISR
Returns
The status of the put request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR, CY_RTOS_QUEUE_FULL]

◆ cy_rtos_get_queue

#define cy_rtos_get_queue (   queue,
  item_ptr,
  timeout_ms,
  in_isr 
)     cy_rtos_queue_get(queue, item_ptr, timeout_ms)

Gets an item in a queue.

This function gets an item from the queue. The item is copied out of the queue into the memory provide by item_ptr. This space must be large enough to hold a queue entry as defined when the queue was initialized.

Note
If in_isr is true, timeout_ms must be zero.
A value of CY_RTOS_NEVER_TIMEOUT assigned to timeout_ms will cause the task to block indefinitely (without a timeout).
Parameters
[in]queuePointer to the queue handle
[in]item_ptrPointer to the memory for the item from the queue
[in]timeout_msThe time to wait to get an item from the queue
[in]in_isrIf true this is being called from within an ISR
Returns
The status of the get request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR, CY_RTOS_QUEUE_EMPTY]

◆ cy_rtos_count_queue

#define cy_rtos_count_queue (   queue,
  num_waiting 
)     cy_rtos_queue_count(queue, num_waiting)

Return the number of items in the queue.

This function returns the number of items currently in the queue.

Parameters
[in]queuePointer to the queue handle
[out]num_waitingPointer to the return count
Returns
The status of the count request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_space_queue

#define cy_rtos_space_queue (   queue,
  num_spaces 
)     cy_rtos_queue_space(queue, num_spaces)

Return the amount of empty space in the queue.

This function returns the amount of empty space in the queue. For instance, if the queue was created with 10 entries max and there are currently 2 entries in the queue, this will return 8.

Parameters
[in]queuePointer to the queue handle
[out]num_spacesPointer to the return count.
Returns
The status of the space request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_reset_queue

#define cy_rtos_reset_queue (   queue)     cy_rtos_queue_reset(queue)

Reset the queue.

This function sets the queue to empty.

Parameters
[in]queuepointer to the queue handle
Returns
The status of the reset request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_deinit_queue

#define cy_rtos_deinit_queue (   queue)     cy_rtos_queue_deinit(queue)

Deinitialize the queue handle.

This function de-initializes the queue and returns all resources used by the queue.

Parameters
[in]queuePointer to the queue handle
Returns
The status of the deinit request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

Function Documentation

◆ cy_rtos_queue_init()

cy_rslt_t cy_rtos_queue_init ( cy_queue_t queue,
size_t  length,
size_t  itemsize 
)

Create a queue.

This is a queue of data where entries are placed on the back of the queue and removed from the front of the queue.

Parameters
[out]queuePointer to the queue handle
[in]lengthThe maximum length of the queue in items
[in]itemsizeThe size of each item in the queue.
Returns
The status of the init request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_queue_put()

cy_rslt_t cy_rtos_queue_put ( cy_queue_t queue,
const void *  item_ptr,
cy_time_t  timeout_ms 
)

Put an item in a queue.

This function puts an item in the queue. The item is copied into the queue using a memory copy and the data pointed to by item_ptr is no longer referenced once the call returns.

Note
If in_isr is true, timeout_ms must be zero.
Parameters
[in]queuePointer to the queue handle
[in]item_ptrPointer to the item to place in the queue
[in]timeout_msThe time to wait to place the item in the queue
Returns
The status of the put request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR, CY_RTOS_QUEUE_FULL]

◆ cy_rtos_queue_get()

cy_rslt_t cy_rtos_queue_get ( cy_queue_t queue,
void *  item_ptr,
cy_time_t  timeout_ms 
)

Gets an item in a queue.

This function gets an item from the queue. The item is copied out of the queue into the memory provide by item_ptr. This space must be large enough to hold a queue entry as defined when the queue was initialized.

Note
If in_isr is true, timeout_ms must be zero.
Parameters
[in]queuePointer to the queue handle
[in]item_ptrPointer to the memory for the item from the queue
[in]timeout_msThe time to wait to get an item from the queue
Returns
The status of the get request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR, CY_RTOS_QUEUE_EMPTY]

◆ cy_rtos_queue_count()

cy_rslt_t cy_rtos_queue_count ( cy_queue_t queue,
size_t *  num_waiting 
)

Return the number of items in the queue.

This function returns the number of items currently in the queue.

Parameters
[in]queuePointer to the queue handle
[out]num_waitingPointer to the return count
Returns
The status of the count request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_queue_space()

cy_rslt_t cy_rtos_queue_space ( cy_queue_t queue,
size_t *  num_spaces 
)

Return the amount of empty space in the queue.

This function returns the amount of empty space in the queue. For instance, if the queue was created with 10 entries max and there are currently 2 entries in the queue, this will return 8.

Parameters
[in]queuePointer to the queue handle
[out]num_spacesPointer to the return count.
Returns
The status of the space request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_queue_reset()

cy_rslt_t cy_rtos_queue_reset ( cy_queue_t queue)

Reset the queue.

This function sets the queue to empty.

Parameters
[in]queuepointer to the queue handle
Returns
The status of the reset request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

◆ cy_rtos_queue_deinit()

cy_rslt_t cy_rtos_queue_deinit ( cy_queue_t queue)

Deinitialize the queue handle.

This function de-initializes the queue and returns all resources used by the queue.

Parameters
[in]queuePointer to the queue handle
Returns
The status of the deinit request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]