nRF51 SDK - S130 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
FIFO implementation

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_fifoPointer to the FIFO.
Return values
NRF_SUCCESSIf 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_fifoPointer to the FIFO.
[out]p_byteByte fetched from the FIFO.
Return values
NRF_SUCCESSIf an element was returned.
NRF_ERROR_NOT_FOUNDIf 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_fifoFIFO object.
[in]p_bufFIFO buffer for storing data. The buffer size has to be a power of two.
[in]buf_sizeSize of the FIFO buffer provided, has to be a power of 2.
Return values
NRF_SUCCESSIf initialization was successful.
NRF_ERROR_NULLIf a NULL pointer is provided as buffer.
NRF_ERROR_INVALID_LENGTHIf 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_fifoPointer to the FIFO.
[in]byteData byte to add to the FIFO.
Return values
NRF_SUCCESSIf an element has been successfully added to the FIFO.
NRF_ERROR_NO_MEMIf the FIFO is full.