FIFO implementation

nRF5 SDK v9.0.0

nRF51 SDK v9.0.0

FIFO implementation. More...

Data Structures

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...

Functions

uint32_t app_fifo_init ( app_fifo_t *p_fifo, uint8_t *p_buf, uint16_t buf_size)
Function for initializing the FIFO. More...
uint32_t app_fifo_put ( app_fifo_t *p_fifo, uint8_t byte)
Function for adding an element to the FIFO. More...
uint32_t app_fifo_get ( app_fifo_t *p_fifo, uint8_t *p_byte)
Function for getting the next element from the FIFO. More...
uint32_t app_fifo_flush ( app_fifo_t *p_fifo)
Function for flushing the FIFO. More...

Detailed Description

FIFO implementation.

Function Documentation

uint32_t app_fifo_flush ( app_fifo_t * p_fifo )

Function for flushing the FIFO.

Parameters
[in] p_fifo Pointer to the FIFO.
Return values
NRF_SUCCESS If the FIFO flushed successfully.
uint32_t app_fifo_get ( app_fifo_t * p_fifo ,
uint8_t * p_byte
)

Function for getting the next element from the FIFO.

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.
uint32_t app_fifo_init ( app_fifo_t * p_fifo ,
uint8_t * p_buf ,
uint16_t buf_size
)

Function for initializing the FIFO.

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
)

Function for adding an element to the FIFO.

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.

Please send us your feedback about the documentation! For technical questions, visit the Nordic Developer Zone .