Fifo Module


Data Structures

struct  KFifo

Defines

#define FIFOEMPTY(fifo)   (fifo->mem_avail==fifo->size)
#define FIFOPRNTSTATS(fifo)   {GENDEBUG("top = %d\r\n",(long)fifo->top);GENDEBUG("bottom = %d\r\n",(long)fifo->bottom); GENDEBUG("mem_avail = %d\r\n",(long)fifo->mem_avail);GENDEBUG("size = %d\r\n",(long)fifo->size);}

Typedefs

typedef KFifo KFifo

Functions

int InitFifo (KFifo *Fifo, size_t size, u8 *array)
int FifoPush (KFifo *Fifo, const char data)
ssize_t FifoPushBlock (KFifo *Fifo, const char *buffer, size_t count)
char FifoPull (KFifo *Fifo)
ssize_t FifoPullBlock (KFifo *Fifo, char *buffer, size_t count)
int DestroyFifo (KFifo *Fifo)

Detailed Description

This module creates simple fifos for storing data in a locking circular queue. It is used internally by many of the other modules. These fifo's use locks to prevent concurrent access. If concurrent access occurs(via and interrupt or scheduled event) the fifo will fail to store/retrieve the data in question and will return 0 to indicate as such.

Function Documentation

int DestroyFifo KFifo Fifo  ) 
 

Destroy a fifo Since this fifo implementation used static memory for everything this function is just an empty shell If you want to clear a fifo just re-initialize it.

Parameters:
Fifo pointer to the fifo to destroy
Returns:
SUCCESS

char FifoPull KFifo Fifo  ) 
 

Pull a byte from a fifo This function doesn't give any indication of success or failure, it simply returns 0 if no data is available (of course zero could be a valid data byte in the fifo) If you need to know if it succeeded or not use FifoPullBlock and just pull 1 byte

Parameters:
Fifo pointer to the fifo to pull from
Returns:
the byte pulled from the fifo
See also:
FifoPullBlock

ssize_t FifoPullBlock KFifo Fifo,
char *  buffer,
size_t  count
 

Pull a block of data from a fifo

Parameters:
Fifo pointer to the fifo to pull from pointer to an array to store the data in number of bytes to pull
Returns:
number of bytes pulled

int FifoPush KFifo Fifo,
const char  data
 

Push a byte into a fifo

Parameters:
Fifo pointer to the fifo to use
data the byte to push
Returns:
SUCCESS

ssize_t FifoPushBlock KFifo Fifo,
const char *  buffer,
size_t  count
 

Push a block of data into a fifo

Parameters:
Fifo pointer to the fifo to push data into
buffer pointer to the data to push into the fifo
count the number of bytes to push into the fifo from buffer
Returns:
the number of bytes stored in the fifo

int InitFifo KFifo Fifo,
size_t  size,
u8 *  array
 

Create Initialize a new Fifo structure around an array InitFifo takes an existing array and wraps a fifo structure around it. Once this has been done the other fifo functions can be used to push and pull data out of it.

Parameters:
Fifo pointer to the fifo structure to initialize
size the size of the fifo (for most cases this should be sizeof(array)
array the array the fifo will be using for storing/retrieving data


Generated on Fri Mar 3 17:25:46 2006 for EMAC-HCS12-SDK by  doxygen 1.4.6