CANopen Slave Documentation
Version 6.16.04
Loading...
Searching...
No Matches
mc_fifo.h File Reference

Detailed Description

This FIFO implementation is using inline functions and is optimized for embedded implementation. The FIFO can store data elements of arbitrary size.

+ Include dependency graph for mc_fifo.h:

Data Structures

struct  McFifoCtrl_s
 

Functions

void * McFifoDataInPtr (McFifoCtrl_ts *ptsFifoV)
 
void * McFifoDataOutPtr (McFifoCtrl_ts *ptsFifoV)
 
uint32_t McFifoFree (McFifoCtrl_ts *ptsFifoV)
 
void McFifoIncIn (McFifoCtrl_ts *ptsFifoV)
 
void McFifoIncOut (McFifoCtrl_ts *ptsFifoV)
 
void McFifoInit (McFifoCtrl_ts *ptsFifoV, void *pvdDataV, uint32_t ulDataSizeV, uint32_t ulFifoSizeV)
 
bool_t McFifoIsEmpty (McFifoCtrl_ts *ptsFifoV)
 
bool_t McFifoIsFull (McFifoCtrl_ts *ptsFifoV)
 
uint32_t McFifoPending (McFifoCtrl_ts *ptsFifoV)
 

Function Documentation

◆ McFifoDataInPtr()

void * McFifoDataInPtr ( McFifoCtrl_ts ptsFifoV)
Parameters
[in]ptsFifoVPointer to FIFO control structure
Returns
Pointer to next free data element inside FIFO for push operation
See also
McFifoDataOutPtr()

The function returns a pointer to the next free data element inside the FIFO defined by ptsFifoV for push operation.

◆ McFifoDataOutPtr()

void * McFifoDataOutPtr ( McFifoCtrl_ts ptsFifoV)
Parameters
[in]ptsFifoVPointer to FIFO control structure
Returns
Pointer to first data element inside FIFO for pop operation
See also
McFifoDataInPtr()

The function returns a pointer to the first data element inside the FIFO defined by ptsFifoV for pop operation.

◆ McFifoFree()

uint32_t McFifoFree ( McFifoCtrl_ts ptsFifoV)
Parameters
[in]ptsFifoVPointer to FIFO control structure

This function returns the number of data elements which can be stored inside the FIFO defined by ptsFifoV.

◆ McFifoIncIn()

void McFifoIncIn ( McFifoCtrl_ts ptsFifoV)
Parameters
[in]ptsFifoVPointer to FIFO control structure

This function increments the pointer for the input data element (push operation) inside the FIFO defined by ptsFifoV. This operation is done after McFifoDataInPtr() has been called.

static McFifoCtrl_ts tsDataFifoS;
uint32_t ulDataElementT;
if (McFifoIsFull(&tsDataFifoS) == false)
{
memcpy(McFifoDataInPtr(&tsDataFifoS), &ulDataElementT, sizeof(ulDataElementT));
McFifoIncIn(&tsDataFifoS);
}
void * McFifoDataInPtr(McFifoCtrl_ts *ptsFifoV)
void McFifoIncIn(McFifoCtrl_ts *ptsFifoV)
bool_t McFifoIsFull(McFifoCtrl_ts *ptsFifoV)
Definition mc_fifo.h:66

◆ McFifoIncOut()

void McFifoIncOut ( McFifoCtrl_ts ptsFifoV)
Parameters
[in]ptsFifoVPointer to FIFO control structure

This function decrements the pointer for the output data element (pop operation) inside the FIFO defined by ptsFifoV. This operation is done after McFifoDataOutPtr() has been called.

static McFifoCtrl_ts tsDataFifoS;
uint32_t ulDataElementT;
if (McFifoIsEmpty(&tsDataFifoS) == false)
{
memcpy(&ulDataElementT, McFifoDataOutPtr(&tsDataFifoS), sizeof(ulDataElementT));
McFifoIncOut(&tsDataFifoS);
}
void * McFifoDataOutPtr(McFifoCtrl_ts *ptsFifoV)
bool_t McFifoIsEmpty(McFifoCtrl_ts *ptsFifoV)
void McFifoIncOut(McFifoCtrl_ts *ptsFifoV)

◆ McFifoInit()

void McFifoInit ( McFifoCtrl_ts ptsFifoV,
void *  pvdDataV,
uint32_t  ulDataSizeV,
uint32_t  ulFifoSizeV 
)
Parameters
[in]ptsFifoVPointer to FIFO control structure
[in]pvdDataVPointer to array of data elements
[in]ulDataSizeVSize of one single data element in bytes
[in]ulFifoSizeVMaximum number of data elements in FIFO

This function initialises a FIFO defined by the control structure ptsFifoV with a maximum size of ulFifoSizeV data elements. The application must guarantee that the pointer pvdDataV points to an array of ulFifoSizeV data elements. The size in bytes of the arbitrary data element is defined by ulDataSizeV.

Here is an example for initialisation of a FIFO:

...
#define NUMBER_OF_FIFO_ENTRIES 20
static McFifoCtrl_ts tsDataFifoS;
static uint32_t aulDataElementS[NUMBER_OF_FIFO_ENTRIES];
McFifoInit(&tsDataFifoS, &aulDataElementS[0], sizeof(uint32_t), NUMBER_OF_FIFO_ENTRIES);
void McFifoInit(McFifoCtrl_ts *ptsFifoV, void *pvdDataV, uint32_t ulDataSizeV, uint32_t ulFifoSizeV)

◆ McFifoIsEmpty()

bool_t McFifoIsEmpty ( McFifoCtrl_ts ptsFifoV)
Parameters
[in]ptsFifoVPointer to FIFO control structure
Returns
true if FIFO is empty, otherwise false
See also
CpFifoIsFull()

The function returns true if the FIFO is empty, otherwise it will return false.

◆ McFifoIsFull()

bool_t McFifoIsFull ( McFifoCtrl_ts ptsFifoV)
Parameters
[in]ptsFifoVPointer to FIFO control structure
Returns
true if FIFO is empty, otherwise false
See also
CpFifoIsFull()

The function returns true if the FIFO is full, otherwise it will return false.

◆ McFifoPending()

uint32_t McFifoPending ( McFifoCtrl_ts ptsFifoV)
Parameters
[in]ptsFifoVPointer to FIFO control structure
Returns
Number of data elements inside FIFO

The function returns the number of data elements which are stored inside the FIFO defined by ptsFifoV.