J1939 Documentation
Version 4.16.00
Loading...
Searching...
No Matches
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

void CpFifoClear (CpFifo_ts *ptsFifoV)
 
bool_t CpFifoCopy (CpFifo_ts *ptsDestFifoV, CpFifo_ts *ptsSrcFifoV)
 
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

◆ CpFifoClear()

void CpFifoClear ( CpFifo_ts * ptsFifoV)
Parameters
[in]ptsFifoVPointer to CAN message FIFO

This function clears all entries inside the FIFO.

◆ CpFifoCopy()

bool_t CpFifoCopy ( CpFifo_ts * ptsDestFifoV,
CpFifo_ts * ptsSrcFifoV )
Parameters
[in]ptsDestFifoVPointer to CAN message FIFO destination
[in]ptsSrcFifoVPointer to CAN message FIFO source
Returns
true if FIFO contents has been copied, otherwise false

This function copies the contents from ptsSrcFifoV to ptsDestFifoV. The function checks if the destination FIFO has the same size as the source FIFO. Both FIFOs have to be initialised by CpFifoInit() in advance.

◆ 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);
}
void CpFifoIncIn(CpFifo_ts *ptsFifoV)
CpCanMsg_ts * CpFifoDataInPtr(CpFifo_ts *ptsFifoV)
bool_t CpFifoIsFull(CpFifo_ts *ptsFifoV)
CAN message structure.
Definition canpie.h:1005
Administration variables of a CAN message FIFO.
Definition cp_fifo.h:79

◆ 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);
}
CpCanMsg_ts * CpFifoDataOutPtr(CpFifo_ts *ptsFifoV)
bool_t CpFifoIsEmpty(CpFifo_ts *ptsFifoV)

◆ 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);
void CpFifoInit(CpFifo_ts *ptsFifoV, CpCanMsg_ts *ptsCanMsgV, uint32_t ulSizeV)

◆ 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.