Queue

group group_abstraction_rtos_queue

APIs for creating and working with Queues.

Unnamed Group

CY_RTOS_QUEUE_FULL

The Queue is already full and can’t accept any more items at this time.

CY_RTOS_QUEUE_EMPTY

The Queue is empty and has nothing to remove.

Unnamed Group

cy_rslt_t cy_rtos_init_queue(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.

Return

The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]

Parameters
  • [out] queue: Pointer to the queue handle

  • [in] length: The maximum length of the queue in items

  • [in] itemsize: The size of each item in the queue.

cy_rslt_t cy_rtos_put_queue(cy_queue_t *queue, const void *item_ptr, cy_time_t timeout_ms, bool in_isr)

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.

Return

The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR, CY_RTOS_QUEUE_FULL]

Parameters
  • [in] queue: Pointer to the queue handle

  • [in] item_ptr: Pointer to the item to place in the queue

  • [in] timeout_ms: The time to wait to place the item in the queue

  • [in] in_isr: If true this is being called from within and ISR

cy_rslt_t cy_rtos_get_queue(cy_queue_t *queue, void *item_ptr, cy_time_t timeout_ms, bool in_isr)

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.

Return

The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR, CY_RTOS_QUEUE_EMPTY]

Parameters
  • [in] queue: Pointer to the queue handle

  • [in] item_ptr: Pointer to the memory for the item from the queue

  • [in] timeout_ms: The time to wait to get an item from the queue

  • [in] in_isr: If true this is being called from within an ISR

cy_rslt_t cy_rtos_count_queue(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.

Return

The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

Parameters
  • [in] queue: Pointer to the queue handle

  • [out] num_waiting: Pointer to the return count

cy_rslt_t cy_rtos_space_queue(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.

Return

The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

Parameters
  • [in] queue: Pointer to the queue handle

  • [out] num_spaces: Pointer to the return count.

cy_rslt_t cy_rtos_reset_queue(cy_queue_t *queue)

Reset the queue.

This function sets the queue to empty.

Return

The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

Parameters
  • [in] queue: pointer to the queue handle

cy_rslt_t cy_rtos_deinit_queue(cy_queue_t *queue)

Deinitialize the queue handle.

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

Return

The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]

Parameters
  • [in] queue: Pointer to the queue handle