EtcPal
0.3.0
ETC Platform Abstraction Layer (EtcPal)
|
View other versions:
|
Platform-neutral blocking RTOS queues.
Provides a platform-neutral API to RTOS queue functionality.
There are also functions for sending and receiving with a timeout, and for checking to see if the queue is empty.
Queues are only available on RTOS platforms. The current availability is as follows:
Platform | Queue Functions Available |
---|---|
FreeRTOS | Yes |
Linux | No |
macOS | No |
MQX | No |
Windows | No |
Functions | |
bool | etcpal_queue_create (etcpal_queue_t *id, size_t size, size_t item_size) |
Create a new queue. More... | |
void | etcpal_queue_destroy (etcpal_queue_t *id) |
Destroy a queue. More... | |
bool | etcpal_queue_send (etcpal_queue_t *id, const void *data) |
Add an item to a queue. More... | |
bool | etcpal_queue_timed_send (etcpal_queue_t *id, const void *data, int timeout_ms) |
Add an item to a queue, giving up after a timeout. More... | |
bool | etcpal_queue_send_from_isr (etcpal_queue_t *id, const void *data) |
Add an item to a queue from an interrupt context. More... | |
bool | etcpal_queue_receive (etcpal_queue_t *id, void *data) |
Retrieve the first item from a queue. More... | |
bool | etcpal_queue_timed_receive (etcpal_queue_t *id, void *data, int timeout_ms) |
Retrieve the first item from a queue, giving up after a timeout. More... | |
bool | etcpal_queue_is_empty (const etcpal_queue_t *id) |
Determine whether a queue is currently empty. More... | |
bool | etcpal_queue_is_empty_from_isr (const etcpal_queue_t *id) |
Determine whether a queue is currently empty from an interrupt context. More... | |
bool etcpal_queue_create | ( | etcpal_queue_t * | id, |
size_t | size, | ||
size_t | item_size | ||
) |
Create a new queue.
[out] | id | Queue identifier on which to create a queue. If this function returns true, id becomes valid for calls to other etcpal_queue API functions. |
[in] | size | The maximum number of items that can be held in the queue. |
[in] | item_size | The size in bytes of the item type to be held in the queue. |
void etcpal_queue_destroy | ( | etcpal_queue_t * | id | ) |
Destroy a queue.
Frees the queue's resources back to the operating system.
[in] | id | Identifier for the queue to destroy. |
bool etcpal_queue_is_empty | ( | const etcpal_queue_t * | id | ) |
Determine whether a queue is currently empty.
[in] | id | Identifier for the queue to check the status of. |
bool etcpal_queue_is_empty_from_isr | ( | const etcpal_queue_t * | id | ) |
Determine whether a queue is currently empty from an interrupt context.
This function is meaningful on platforms which have a different method for interacting with queues from an interrupt context.
[in] | id | Identifier for the queue to check the status of. |
bool etcpal_queue_receive | ( | etcpal_queue_t * | id, |
void * | data | ||
) |
Retrieve the first item from a queue.
Blocks until there is an item available to retrieve from the queue.
[in] | id | Identifier for the queue from which to retrieve an item. |
[out] | data | Pointer to a location to write the object's data. |
bool etcpal_queue_send | ( | etcpal_queue_t * | id, |
const void * | data | ||
) |
Add an item to a queue.
Blocks until there is room in the queue to add a new item.
[in] | id | Identifier for the queue to which to add an item. |
[in] | data | Pointer to item to add to the queue. |
bool etcpal_queue_send_from_isr | ( | etcpal_queue_t * | id, |
const void * | data | ||
) |
Add an item to a queue from an interrupt context.
This function is meaningful on platforms which have a different method for interacting with queues from an interrupt context. This function never blocks, i.e. the behavior is similar to calling etcpal_queue_timed_send() with a value of 0 for the timeout_ms parameter.
[in] | id | Identifier for the queue to which to add an item. |
[in] | data | Pointer to item to add to the queue. |
bool etcpal_queue_timed_receive | ( | etcpal_queue_t * | id, |
void * | data, | ||
int | timeout_ms | ||
) |
Retrieve the first item from a queue, giving up after a timeout.
[in] | id | Identifier for the queue from which to retrieve an item. |
[out] | data | Pointer to a location to write the object's data. |
[in] | timeout_ms | Maximum amount of time to wait for an item to be available, in milliseconds. If ETCPAL_WAIT_FOREVER is given, the result is the same as if etcpal_queue_receive() was called. |
bool etcpal_queue_timed_send | ( | etcpal_queue_t * | id, |
const void * | data, | ||
int | timeout_ms | ||
) |
Add an item to a queue, giving up after a timeout.
[in] | id | Identifier for the queue to which to add an item. |
[in] | data | Pointer to item to add to the queue. |
[in] | timeout_ms | Maximum amount of time to wait for space to be available, in milliseconds. If ETCPAL_WAIT_FOREVER is given, the result is the same as if etcpal_queue_send() was called. |