FIFO implementation.
More...
|
struct | app_fifo_t |
| A FIFO instance structure. Keeps track of which bytes to read and write next. Also it keeps the information about which memory is allocated for the buffer and its size. This needs to be initialized by app_fifo_init() before use. More...
|
|
The size of the FIFO buffer has to be a power of two.
- Note
- The FIFO implementation only guarantees correct behaviour when having one producer and one consumer. If more than one interrupt level writes to the FIFO data might be lost or over-written.
uint32_t app_fifo_init |
( |
app_fifo_t * |
p_fifo, |
|
|
uint8_t * |
p_buf, |
|
|
uint16_t |
buf_size |
|
) |
| |
- Parameters
-
[out] | p_fifo | FIFO object. |
[in] | p_buf | FIFO buffer for storing data. The buffer size has to be a power of two. |
[in] | buf_size | Size of the FIFO buffer provided, has to be a power of 2. |
- Return values
-
NRF_SUCCESS | If initialization was successful. |
NRF_ERROR_NULL | If a NULL pointer is provided as buffer. |
NRF_ERROR_INVALID_LENGTH | If size of buffer provided is not a power of two. |
uint32_t app_fifo_put |
( |
app_fifo_t * |
p_fifo, |
|
|
uint8_t |
byte |
|
) |
| |
- Parameters
-
[in] | p_fifo | Pointer to the FIFO. |
[in] | byte | Data byte to add to the FIFO. |
- Return values
-
NRF_SUCCESS | If an element has been successfully added to the FIFO. |
NRF_ERROR_NO_MEM | If the FIFO is full. |
uint32_t app_fifo_get |
( |
app_fifo_t * |
p_fifo, |
|
|
uint8_t * |
p_byte |
|
) |
| |
- Parameters
-
[in] | p_fifo | Pointer to the FIFO. |
[out] | p_byte | Byte fetched from the FIFO. |
- Return values
-
NRF_SUCCESS | If an element was returned. |
NRF_ERROR_NOT_FOUND | If there is no more elements in the queue. |
- Parameters
-
[in] | p_fifo | Pointer to the FIFO. |
- Return values
-
NRF_SUCCESS | If the FIFO flushed successfully. |