| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Modules | Data Structures | Functions
FIFO implementation
SDK common libraries

FIFO implementation. More...

## Modules
| Software FIFO implementation configuration

## Data Structures
struct | app_fifo_t
| A FIFO instance structure. 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_peek (app_fifo_t *p_fifo, uint16_t index, uint8_t *p_byte)
| Function for looking at an element in the FIFO, without consuming it. More...
uint32_t | app_fifo_flush (app_fifo_t *p_fifo)
| Function for flushing the FIFO. More...
uint32_t | app_fifo_read (app_fifo_t *p_fifo, uint8_t *p_byte_array, uint32_t *p_size)
| Function for reading bytes from the FIFO. More...
uint32_t | app_fifo_write (app_fifo_t *p_fifo, uint8_t const *p_byte_array, uint32_t *p_size)
| Function for writing bytes to 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 was 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 are 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 must be a power of two.
  [in] | buf_size | Size of the FIFO buffer provided. This size must be a power of two.

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_peek | ( | app_fifo_t * | p_fifo,
|  | uint16_t | index,
|  | uint8_t * | p_byte
| ) |  |

Function for looking at an element in the FIFO, without consuming it.

Parameters

  [in] | p_fifo | Pointer to the FIFO.
  [in] | index | Which element to look at. The lower the index, the earlier it was put.
  [out] | p_byte | Byte fetched from the FIFO.

Return values

  NRF_SUCCESS | If an element was returned.
  NRF_ERROR_NOT_FOUND | If there are no more elements in the queue, or the index was too large.

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.

uint32_t app_fifo_read | ( | app_fifo_t * | p_fifo,
|  | uint8_t * | p_byte_array,
|  | uint32_t * | p_size
| ) |  |

Function for reading bytes from the FIFO.

This function can also be used to get the number of bytes in the FIFO.

Parameters

  [in] | p_fifo | Pointer to the FIFO. Must not be NULL.
  [out] | p_byte_array | Memory pointer where the read bytes are fetched from the FIFO. Can be NULL. If NULL, the number of bytes that can be read in the FIFO are returned in the p_size parameter.
  [in,out] | p_size | Address to memory indicating the maximum number of bytes to be read. The provided memory is overwritten with the actual number of bytes read if the procedure was successful. This field must not be NULL. If p_byte_array is set to NULL by the application, this parameter returns the number of bytes in the FIFO.

Return values

  NRF_SUCCESS | If the procedure is successful. The actual number of bytes read might be less than the requested maximum, depending on how many elements exist in the FIFO. Even if less bytes are returned, the procedure is considered successful.
  NRF_ERROR_NULL | If a NULL parameter was passed for a parameter that must not be NULL.
  NRF_ERROR_NOT_FOUND | If the FIFO is empty.

uint32_t app_fifo_write | ( | app_fifo_t * | p_fifo,
|  | uint8_t const * | p_byte_array,
|  | uint32_t * | p_size
| ) |  |

Function for writing bytes to the FIFO.

This function can also be used to get the available size on the FIFO.

Parameters

  [in] | p_fifo | Pointer to the FIFO. Must not be NULL.
  [in] | p_byte_array | Memory pointer containing the bytes to be written to the FIFO. Can be NULL. If NULL, this function returns the number of bytes that can be written to the FIFO.
  [in,out] | p_size | Address to memory indicating the maximum number of bytes to be written. The provided memory is overwritten with the number of bytes that were actually written if the procedure is successful. This field must not be NULL. If p_byte_array is set to NULL by the application, this parameter returns the number of bytes available in the FIFO.

Return values

  NRF_SUCCESS | If the procedure is successful. The actual number of bytes written might be less than the requested maximum, depending on how much room there is in the FIFO. Even if less bytes are written, the procedure is considered successful. If the write was partial, the application should use subsequent calls to attempt writing the data again.
  NRF_ERROR_NULL | If a NULL parameter was passed for a parameter that must not be NULL.
  NRF_ERROR_NO_MEM | If the FIFO is full.