CANpie FD
CAN programming interface environment - Version 3.08
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Modules Pages
Data Structures | Functions
cp_fifo.h File Reference

Detailed Description

A CAN message FIFO can be assigned to every message message buffer by calling CpCoreFifoConfig(). This file defines the structure of a CAN message FIFO (CpFifo_s) and inline functions to access the FIFO.

+ Include dependency graph for cp_fifo.h:

Data Structures

struct  CpFifo_s
 

Functions

CpCanMsg_tsCpFifoDataInPtr (CpFifo_ts *ptsFifoV)
 
CpCanMsg_tsCpFifoDataOutPtr (CpFifo_ts *ptsFifoV)
 
uint32_t CpFifoFree (CpFifo_ts *ptsFifoV)
 
void CpFifoIncIn (CpFifo_ts *ptsFifoV)
 
void CpFifoIncOut (CpFifo_ts *ptsFifoV)
 
void CpFifoInit (CpFifo_ts *ptsFifoV, CpCanMsg_ts *ptsCanMsgV, uint32_t ulSizeV)
 
bool_t CpFifoIsEmpty (CpFifo_ts *ptsFifoV)
 
bool_t CpFifoIsFull (CpFifo_ts *ptsFifoV)
 
uint32_t CpFifoPending (CpFifo_ts *ptsFifoV)
 

Function Documentation

◆ CpFifoDataInPtr()

CpCanMsg_ts* CpFifoDataInPtr ( CpFifo_ts ptsFifoV)
Parameters
[in]ptsFifoV- Pointer to CAN message FIFO
Returns
Pointer to CAN message

This function returns a pointer to the next free CAN message entry inside the FIFO. Please make sure to call CpFifoIsFull() in advance. After writing to the FIFO the index has to adjusted by calling CpFifoIncIn(), like shown in this code example:

static CpFifo_ts tsCanFifoS;
CpCanMsg_ts * ptsCanNewMsgT;
CpCanMsg_ts * ptsCanInEntryT;
if (!(CpFifoIsFull(&tsCanFifoS)))
{
ptsCanInEntryT = CpFifoDataInPtr(&tsCanFifoS);
memcpy(ptsCanInEntryT, ptsCanNewMsgT, sizeof(CpCanMsg_ts));
CpFifoIncIn(&tsCanFifoS);
}

◆ CpFifoDataOutPtr()

CpCanMsg_ts* CpFifoDataOutPtr ( CpFifo_ts ptsFifoV)
Parameters
[in]ptsFifoV- Pointer to CAN message FIFO
Returns
Pointer to CAN message

This function returns a pointer to the first CAN message entry inside the FIFO. Please make sure to call CpFifoIsEmpty() in advance. After reading from the FIFO the index has to adjusted by calling CpFifoIncOut(), like shown in this code example:

static CpFifo_ts tsCanFifoS;
CpCanMsg_ts * ptsCanNewMsgT;
CpCanMsg_ts * ptsCanOutEntryT;
if (!(CpFifoIsEmpty(&tsCanFifoS)))
{
ptsCanOutEntryT = CpFifoDataOutPtr(&tsCanFifoS);
memcpy(ptsCanNewMsgT, ptsCanOutEntryT, sizeof(CpCanMsg_ts));
CpFifoIncout(&tsCanFifoS);
}

◆ CpFifoFree()

uint32_t CpFifoFree ( CpFifo_ts ptsFifoV)
Parameters
[in]ptsFifoV- Pointer to CAN message FIFO
Returns
Number of free elements

The function returns the number of free elements inside the FIFO given by pointer ptsFifoV.

◆ CpFifoIncIn()

void CpFifoIncIn ( CpFifo_ts ptsFifoV)
Parameters
[in]ptsFifoV- Pointer to CAN message FIFO

This function increments the CpFifo_ts::ulIndexIn element of the CAN message FIFO.

◆ CpFifoIncOut()

void CpFifoIncOut ( CpFifo_ts ptsFifoV)
Parameters
[in]ptsFifoV- Pointer to CAN message FIFO

This function increments the CpFifo_ts::ulIndexOut element of the CAN message FIFO.

◆ CpFifoInit()

void CpFifoInit ( CpFifo_ts ptsFifoV,
CpCanMsg_ts ptsCanMsgV,
uint32_t  ulSizeV 
)
Parameters
[in]ptsFifoV- Pointer to CAN message FIFO
[in]ptsCanMsgV- Pointer to array of CAN messages
[in]ulSizeV- Size if CAN message array

This function initialises a CAN message FIFO. The paramter ptsCanMsgV points to an array of CpCanMsg_ts elements. The number of messages which can be stored inside the array is determined by the paramter ulSizeV.

Here is an example for initialisation of a CAN message FIFO:

...
#define NUMBER_OF_FIFO_ENTRIES 20
static CpFifo_ts tsCanFifoS;
static CpCanMsg_ts atsCanMsgS[NUMBER_OF_FIFO_ENTRIES];
CpFifoInit(&tsCanFifoS, &atsCanMsgS, NUMBER_OF_FIFO_ENTRIES);

◆ CpFifoIsEmpty()

bool_t CpFifoIsEmpty ( CpFifo_ts ptsFifoV)
Parameters
[in]ptsFifoV- Pointer to CAN message FIFO
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.

◆ CpFifoIsFull()

bool_t CpFifoIsFull ( CpFifo_ts ptsFifoV)
Parameters
[in]ptsFifoV- Pointer to CAN message FIFO
Returns
true if FIFO is full, otherwise false
See also
CpFifoIsEmpty()

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

◆ CpFifoPending()

uint32_t CpFifoPending ( CpFifo_ts ptsFifoV)
Parameters
[in]ptsFifoV- Pointer to CAN message FIFO
Returns
Number of pending elements

The function returns the number of pending elements inside the FIFO given by ptsFifoV.

CpFifoDataInPtr
CpCanMsg_ts * CpFifoDataInPtr(CpFifo_ts *ptsFifoV)
CpFifoIsFull
bool_t CpFifoIsFull(CpFifo_ts *ptsFifoV)
CpFifo_s
Administration variables of a CAN message FIFO.
Definition: cp_fifo.h:89
CpFifoDataOutPtr
CpCanMsg_ts * CpFifoDataOutPtr(CpFifo_ts *ptsFifoV)
CpFifoIsEmpty
bool_t CpFifoIsEmpty(CpFifo_ts *ptsFifoV)
CpCanMsg_s
CAN message structure.
Definition: canpie.h:1003
CpFifoInit
void CpFifoInit(CpFifo_ts *ptsFifoV, CpCanMsg_ts *ptsCanMsgV, uint32_t ulSizeV)
CpFifoIncIn
void CpFifoIncIn(CpFifo_ts *ptsFifoV)