Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Typedefs | Enumerations | Functions | Variables
lampda::hal::queues Namespace Reference

Implementation of inter thread queues. More...

Typedefs

typedef void * QueueHandle_t
 

Enumerations

enum  HAL_queue_status_t {
  HAL_QUEUE_OK = 0 , HAL_QUEUE_ERR_INVALID_PARAM = -1 , HAL_QUEUE_ERR_TIMEOUT = -2 , HAL_QUEUE_ERR_FULL = -3 ,
  HAL_QUEUE_ERR_EMPTY = -4 , HAL_QUEUE_ERR_OTHER = -5
}
 Queue operation status codes.
 

Functions

QueueHandle_t HAL_create_queue (size_t itemSize, uint32_t queueLength, uint32_t staticIndex, uint8_t *buffer)
 Create a queue with the specified item size and maximum length.
 
void HAL_delete_queue (QueueHandle_t handle)
 Delete/free a queue and release its underlying resources.
 
HAL_queue_status_t HAL_queue_send (QueueHandle_t handle, const void *item, uint32_t timeoutMs)
 Send an item to the queue.
 
HAL_queue_status_t HAL_queue_receive (QueueHandle_t handle, void *const outItem, uint32_t timeoutMs)
 Receive an item from the queue. Blocks until an item is available or timeout expires.
 
size_t HAL_queue_get_number_of_items (QueueHandle_t handle)
 Return the number of items currently in a queue.
 

Variables

static constexpr uint32_t MaxStaticQueues = 5
 Define the max number of queue objets that can be defined.
 

Detailed Description

Implementation of inter thread queues.

Function Documentation

◆ HAL_create_queue()

QueueHandle_t lampda::hal::queues::HAL_create_queue ( size_t  itemSize,
uint32_t  queueLength,
uint32_t  staticIndex,
uint8_t *  buffer 
)

Create a queue with the specified item size and maximum length.

Parameters
[in]itemSizeSize of each item in bytes (abstracts the data type)
[in]queueLengthMaximum number of items the queue can hold
[in]staticIndexIndex of the static object to use. Limited to MaxStaticQueues. THEY CANNOT BE SHARED BETWEEN QUEUES
[in,out]bufferPreallocated static buffer to itemSize * queueLength
Returns
The allocated queue handle

◆ HAL_delete_queue()

void lampda::hal::queues::HAL_delete_queue ( QueueHandle_t  handle)

Delete/free a queue and release its underlying resources.

Parameters
[in]handleHandle of the queue to delete

◆ HAL_queue_receive()

HAL_queue_status_t lampda::hal::queues::HAL_queue_receive ( QueueHandle_t  handle,
void *const  outItem,
uint32_t  timeoutMs 
)

Receive an item from the queue. Blocks until an item is available or timeout expires.

Parameters
[in]handleHandle of the queue
[out]outItemPointer to buffer to store the received item
[in]timeoutMsTimeout in milliseconds. 0 = non-blocking
Returns
HAL_QUEUE_OK on success, HAL_QUEUE_ERR_EMPTY if queue is empty, HAL_QUEUE_ERR_TIMEOUT on timeout

◆ HAL_queue_send()

HAL_queue_status_t lampda::hal::queues::HAL_queue_send ( QueueHandle_t  handle,
const void *  item,
uint32_t  timeoutMs 
)

Send an item to the queue.

Parameters
[in]handleHandle of the queue
[in]itemPointer to the item to send
[in]timeoutMsTimeout in milliseconds. 0 = non-blocking, UINT32_MAX = block indefinitely
Returns
HAL_QUEUE_OK on success, HAL_QUEUE_ERR_FULL if queue is full, HAL_QUEUE_ERR_TIMEOUT on timeout