Mailbox for safely queuing items.
More...
|
#define | APP_MAILBOX_DEF(name, QUEUE_SZ, ITEM_SZ) |
| Macro to statically allocate memory for a given mailbox queue. More...
|
|
Mailbox for safely queuing items.
#define APP_MAILBOX_DEF |
( |
|
name, |
|
|
|
QUEUE_SZ, |
|
|
|
ITEM_SZ |
|
) |
| |
Value:
{ \
.queue_sz = (uint8_t)(QUEUE_SZ), \
.item_sz = (uint16_t)(ITEM_SZ), \
}
Macro to statically allocate memory for a given mailbox queue.
Supported overflow modes.
Enumerator |
---|
APP_MAILBOX_MODE_NO_OVERFLOW |
If the mailbox is full, app_mailbox_put does not add a new element.
|
APP_MAILBOX_MODE_OVERFLOW |
If the mailbox is full, the oldest element is lost and a new one is added.
|
Function for creating a mailbox queue.
This function creates and initializes a mailbox queue.
- Parameters
-
[in] | p_mailbox | Pointer to the mailbox. |
- Return values
-
NRF_SUCCESS | If the queue was successfully created. |
Function for getting an item from the mailbox queue.
- Parameters
-
[in] | p_mailbox | Pointer to the mailbox. |
[out] | p_item | Pointer to the output location for the dequeued item. |
- Return values
-
NRF_SUCCESS | If the item was retrieved successfully. |
NRF_ERROR_NO_MEM | If the queue is empty. |
uint32_t app_mailbox_length_get |
( |
const app_mailbox_t * |
p_mailbox | ) |
|
Function for getting the current length of the mailbox queue.
- Parameters
-
[in] | p_mailbox | Pointer to the mailbox. |
- Returns
- Current number of elements in the queue.
Function for changing the mode of overflow handling.
- Parameters
-
[in] | p_mailbox | Pointer to the mailbox. |
| mode | New mode to set. |
Function for putting an item in the mailbox queue.
- Parameters
-
[in] | p_mailbox | Pointer to the mailbox. |
[in] | p_item | Pointer to the item to be queued. |
- Return values
-
NRF_SUCCESS | If the item was enqueued. |
NRF_ERROR_NO_MEM | If the queue is full. |
Function for getting an item and its size from the mailbox queue.
- Parameters
-
[in] | p_mailbox | Pointer to the mailbox. |
[out] | p_item | Pointer to the output location for the dequeued item. |
[out] | p_size | Pointer to the item size. |
- Return values
-
NRF_SUCCESS | If the item was retrieved successfully. |
NRF_ERROR_NO_MEM | If the queue is empty. |
Function for putting an item with a specified size in the mailbox queue.
- Parameters
-
[in] | p_mailbox | Pointer to the mailbox. |
[in] | p_item | Pointer to the item to be queued. |
[in] | size | Size of the item. |
- Return values
-
NRF_SUCCESS | If the item was enqueued. |
NRF_ERROR_NO_MEM | If the queue is full. |