Microchip® Advanced Software Framework

fifo.h File Reference

This file controls the software FIFO management.

These functions manages FIFOs thanks to simple a API. The FIFO can be 100% full thanks to a double-index range implementation. For example, a FIFO of 4 elements can be implemented: the FIFO can really hold up to 4 elements. This is particularly well suited for any kind of application needing a lot of small FIFO.

Copyright (c) 2010-2018 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"

Data Structures

struct  fifo_desc
 FIFO descriptor used by FIFO driver. More...
 

Typedefs

typedef struct fifo_desc fifo_desc_t
 

Enumerations

enum  {
  FIFO_OK = 0,
  FIFO_ERROR_OVERFLOW,
  FIFO_ERROR_UNDERFLOW,
  FIFO_ERROR
}
 Error codes used by FIFO driver. More...
 

Functions

static void fifo_flush (fifo_desc_t *fifo_desc)
 Flushes a software FIFO. More...
 
static uint8_t fifo_get_free_size (fifo_desc_t *fifo_desc)
 Returns the remaining free spaces of the FIFO (in number of elements). More...
 
static uint8_t fifo_get_used_size (fifo_desc_t *fifo_desc)
 Returns the number of elements in the FIFO. More...
 
int fifo_init (fifo_desc_t *fifo_desc, void *buffer, uint8_t size)
 Initializes a new software FIFO for a certain 'size'. More...
 
static bool fifo_is_empty (fifo_desc_t *fifo_desc)
 Tests if a FIFO is empty. More...
 
static bool fifo_is_full (fifo_desc_t *fifo_desc)
 Tests if a FIFO is full. More...
 
static uint16_t fifo_peek_uint16 (fifo_desc_t *fifo_desc)
 Gets a 16-bits element from the FIFO but does not remove it from the FIFO. More...
 
static uint32_t fifo_peek_uint32 (fifo_desc_t *fifo_desc)
 Gets a 32-bits element from the FIFO but does not remove it from the FIFO. More...
 
static uint8_t fifo_peek_uint8 (fifo_desc_t *fifo_desc)
 Gets a 8-bits element from the FIFO but does not remove it from the FIFO. More...
 
static int fifo_pull_uint16 (fifo_desc_t *fifo_desc, uint16_t *item)
 Gets a 16-bits element from the FIFO and checks for a possible underflow. More...
 
static uint16_t fifo_pull_uint16_nocheck (fifo_desc_t *fifo_desc)
 Gets a 16-bits element from the FIFO. More...
 
static int fifo_pull_uint32 (fifo_desc_t *fifo_desc, uint32_t *item)
 Gets a 32-bits element from the FIFO and checks for a possible underflow. More...
 
static uint32_t fifo_pull_uint32_nocheck (fifo_desc_t *fifo_desc)
 Gets a 32-bits element from the FIFO. More...
 
static int fifo_pull_uint8 (fifo_desc_t *fifo_desc, uint8_t *item)
 Gets a 8-bits element from the FIFO and checks for a possible underflow. More...
 
static uint8_t fifo_pull_uint8_nocheck (fifo_desc_t *fifo_desc)
 Gets a 8-bits element from the FIFO. More...
 
static int fifo_push_uint16 (fifo_desc_t *fifo_desc, uint32_t item)
 Puts a new 16-bits element into the FIFO and checks for a possible overflow. More...
 
static void fifo_push_uint16_nocheck (fifo_desc_t *fifo_desc, uint32_t item)
 Puts a new 16-bits element into the FIFO. More...
 
static int fifo_push_uint32 (fifo_desc_t *fifo_desc, uint32_t item)
 Puts a new 32-bits element into the FIFO and checks for a possible overflow. More...
 
static void fifo_push_uint32_nocheck (fifo_desc_t *fifo_desc, uint32_t item)
 Puts a new 32-bits element into the FIFO. More...
 
static int fifo_push_uint8 (fifo_desc_t *fifo_desc, uint32_t item)
 Puts a new 8-bits element into the FIFO and checks for a possible overflow. More...
 
static void fifo_push_uint8_nocheck (fifo_desc_t *fifo_desc, uint32_t item)
 Puts a new 8-bits element into the FIFO. More...