iLLD_TC27xD  1.0
Collaboration diagram for FIFO:

Files

file  Ifx_Fifo.h
 FIFO buffer functions.
 

Data Structures

struct  _Fifo
 

Typedefs

typedef struct _Fifo Ifx_Fifo
 

Functions

IFX_EXTERN boolean Ifx_Fifo_canReadCount (Ifx_Fifo *fifo, Ifx_SizeT count, Ifx_TickTime timeout)
 Indicates if the required number of bytes are available in the buffer. More...
 
IFX_EXTERN boolean Ifx_Fifo_canWriteCount (Ifx_Fifo *fifo, Ifx_SizeT count, Ifx_TickTime timeout)
 Indicates if there is enough free space to write the data in the buffer. More...
 
IFX_EXTERN void Ifx_Fifo_clear (Ifx_Fifo *fifo)
 Clear fifo contents. More...
 
IFX_EXTERN Ifx_FifoIfx_Fifo_create (Ifx_SizeT size, Ifx_SizeT elementSize)
 Create a Fifo object. More...
 
IFX_EXTERN void Ifx_Fifo_destroy (Ifx_Fifo *fifo)
 Destroy the FIFO object. More...
 
IFX_EXTERN Ifx_FifoIfx_Fifo_init (void *buffer, Ifx_SizeT size, Ifx_SizeT elementSize)
 Initialize the FIFO buffer object. More...
 
IFX_EXTERN Ifx_SizeT Ifx_Fifo_read (Ifx_Fifo *fifo, void *data, Ifx_SizeT count, Ifx_TickTime timeout)
 Read data from a fifo and remove them from the buffer. More...
 
IFX_EXTERN Ifx_SizeT Ifx_Fifo_write (Ifx_Fifo *fifo, const void *data, Ifx_SizeT count, Ifx_TickTime timeout)
 Write data into a fifo. More...
 
IFX_INLINE boolean Ifx_Fifo_flush (Ifx_Fifo *fifo, Ifx_TickTime timeout)
 Empty the fifo. More...
 
IFX_INLINE Ifx_SizeT Ifx_Fifo_readCount (Ifx_Fifo *fifo)
 Returns the size of the data in the buffer in bytes. More...
 
IFX_INLINE Ifx_SizeT Ifx_Fifo_writeCount (Ifx_Fifo *fifo)
 Returns the free size in bytes. More...
 
IFX_INLINE boolean Ifx_Fifo_isEmpty (Ifx_Fifo *fifo)
 Indicates if the fifo is empty. More...
 

Detailed Description

This module implements the FIFO buffer functionality.


Data Structure Documentation

struct _Fifo

Fifo object

Definition at line 53 of file Ifx_Fifo.h.

Collaboration diagram for _Fifo:
Data Fields
void * buffer aligned on 64 bit boundary
Ifx_SizeT elementSize minimum number of bytes (block) added / removed to / from the buffer
Ifx_SizeT endIndex buffer valid data end index
volatile boolean eventReader event set by the writer to signal the reader that the required data are available in the buffer
volatile boolean eventWriter event set by the reader to signal the writer that the required free space are available in the buffer
Ifx_Fifo_Shared shared data shared between reader / writer
Ifx_SizeT size multiple of 8 bit, max 0xFFF8
Ifx_SizeT startIndex buffer valid data start index

Typedef Documentation

typedef struct _Fifo Ifx_Fifo

Fifo object

Function Documentation

IFX_EXTERN boolean Ifx_Fifo_canReadCount ( Ifx_Fifo fifo,
Ifx_SizeT  count,
Ifx_TickTime  timeout 
)

Indicates if the required number of bytes are available in the buffer.

Should not be called from an interrupt as this function may wait forever

Parameters
fifoPointer on the Fifo object
countin bytes
timeoutin system timer ticks
Returns
TRUE if at least count bytes can be read from the buffer, else the Event is armed to be set when the buffer count is bigger or equal to the requested count

Definition at line 119 of file Ifx_Fifo.c.

Referenced by IfxAsclin_Asc_canReadCount().

IFX_EXTERN boolean Ifx_Fifo_canWriteCount ( Ifx_Fifo fifo,
Ifx_SizeT  count,
Ifx_TickTime  timeout 
)

Indicates if there is enough free space to write the data in the buffer.

Should not be called from an interrupt as this function may wait forever

Parameters
fifoPointer on the Fifo object
countin bytes
timeoutin system timer ticks
Returns
TRUE if at least count bytes can be written to the buffer, if not the Event is armed to be set when the buffer free count is bigger or equal to the requested count

Definition at line 277 of file Ifx_Fifo.c.

Referenced by Ifx_Fifo_flush(), and IfxAsclin_Asc_canWriteCount().

IFX_EXTERN void Ifx_Fifo_clear ( Ifx_Fifo fifo)

Clear fifo contents.

Parameters
fifoPointer on the Fifo object
Returns
void

Definition at line 240 of file Ifx_Fifo.c.

Referenced by IfxAsclin_Asc_clearRx(), and IfxAsclin_Asc_clearTx().

IFX_EXTERN Ifx_Fifo* Ifx_Fifo_create ( Ifx_SizeT  size,
Ifx_SizeT  elementSize 
)

Create a Fifo object.

The memory required for the object is allocated dynamically.

Parameters
sizeSpecifies the FIFO buffer size in bytes
elementSizeSpecifies data element size in bytes. size must be bigger or equal to elemenntSize.
Returns
returns a pointer to the FIFO object
See Also
Ifx_Fifo_destroy()

Definition at line 51 of file Ifx_Fifo.c.

Referenced by IfxAsclin_Asc_initModule().

IFX_EXTERN void Ifx_Fifo_destroy ( Ifx_Fifo fifo)

Destroy the FIFO object.

This function must be called to destroy the fifo object when created with Ifx_Fifo_create()

Parameters
fifoPointer on the Fifo object
Returns
void
See Also
Ifx_Fifo_create()

Definition at line 68 of file Ifx_Fifo.c.

IFX_INLINE boolean Ifx_Fifo_flush ( Ifx_Fifo fifo,
Ifx_TickTime  timeout 
)

Empty the fifo.

Parameters
fifoPointer on the Fifo object
timeoutin system timer ticks
Returns
TRUE if the buffer is emptied.

Definition at line 169 of file Ifx_Fifo.h.

Referenced by IfxAsclin_Asc_flushTx().

IFX_EXTERN Ifx_Fifo* Ifx_Fifo_init ( void *  buffer,
Ifx_SizeT  size,
Ifx_SizeT  elementSize 
)

Initialize the FIFO buffer object.

Parameters
bufferSpecifies the FIFO object address.
sizeSpecifies the FIFO buffer size in bytes
elementSizeSpecifies data element size in bytes. size must be bigger or equal to elemenntSize.
Returns
Returns a pointer on the FIFO object
Note
: The buffer parameter must point on a free memory location where the buffer object will be initialised. The size of this area must be at least equals to "size + sizeof(Ifx_Fifo) + 8". Not taking this in account may result in unpredictable behavior.

Definition at line 74 of file Ifx_Fifo.c.

Referenced by Ifx_Fifo_create(), and IfxAsclin_Asc_initModule().

IFX_INLINE boolean Ifx_Fifo_isEmpty ( Ifx_Fifo fifo)

Indicates if the fifo is empty.

Parameters
fifoPointer on the Ifx_Fifo object
Return values
TRUEis the buffer is empty
FALSEis the buffer is not empty

Definition at line 215 of file Ifx_Fifo.h.

Referenced by IfxAsclin_Asc_initiateTransmission().

IFX_EXTERN Ifx_SizeT Ifx_Fifo_read ( Ifx_Fifo fifo,
void *  data,
Ifx_SizeT  count,
Ifx_TickTime  timeout 
)

Read data from a fifo and remove them from the buffer.

Only complete elements are returned, if count is not a multiple of elementSize then the incomplete element is not read/removed from the buffer.

Parameters
fifoPointer on the Fifo object
dataPointer to the data buffer for storing values
countin bytes
timeoutin system timer ticks
Returns
return the number of byte that could not be read

Definition at line 191 of file Ifx_Fifo.c.

Referenced by IfxAsclin_Asc_initiateTransmission(), IfxAsclin_Asc_isrTransmit(), and IfxAsclin_Asc_read().

IFX_INLINE Ifx_SizeT Ifx_Fifo_readCount ( Ifx_Fifo fifo)

Returns the size of the data in the buffer in bytes.

Parameters
fifoPointer on the Fifo object

Note as the Ifx_Fifo_write / Ifx_Fifo_read function does only write blocks which are a multiple of fifo->elementSize, the Ifx_Fifo_readCount / Ifx_Fifo_writeCount return a multiple of fifo->elementSize

Returns
Returns the size of the data in the buffer in bytes

Definition at line 186 of file Ifx_Fifo.h.

Referenced by Ifx_Fifo_canReadCount(), Ifx_Fifo_canWriteCount(), Ifx_Fifo_isEmpty(), Ifx_Fifo_writeCount(), and IfxAsclin_Asc_getReadCount().

IFX_EXTERN Ifx_SizeT Ifx_Fifo_write ( Ifx_Fifo fifo,
const void *  data,
Ifx_SizeT  count,
Ifx_TickTime  timeout 
)

Write data into a fifo.

Only complete elements are written to the buffer, if count is not a multiple of elementSize then the incomplete element are not written to the buffer.

Parameters
fifoPointer on the Fifo object
dataPointer to the data buffer to write into the Fifo
countin bytes
timeoutin system timer ticks

Definition at line 345 of file Ifx_Fifo.c.

Referenced by IfxAsclin_Asc_isrReceive(), and IfxAsclin_Asc_write().

IFX_INLINE Ifx_SizeT Ifx_Fifo_writeCount ( Ifx_Fifo fifo)

Returns the free size in bytes.

Parameters
fifoPointer on the Fifo object

Note as the Ifx_Fifo_write / Ifx_Fifo_read function does only write blocks which are a multiple of fifo->elementSize, the Ifx_Fifo_readCount / Ifx_Fifo_writeCount return a multiple of fifo->elementSize

Returns
Returns the free size in bytes

Definition at line 202 of file Ifx_Fifo.h.

Referenced by IfxAsclin_Asc_getWriteCount().