I am writing a driver to send SDO & PDO CAN packages. I started out with the flexcan loopback example and then adapted it. Now I can not get my head around the “void BOARD_FLEXCAN_HANDLER(void)” function. Where can I find documentation for it?
What am I allowed to do in this function?
How does it get executed? → I’ve put a PRINTF command inside the function but this command does not seem to get executed. If I put the command in the if() condition it gets executed.
Am I supposed to just leave the code how it is in this “BOARD_FLEXCAN_HANDLER” ?
I wonder how i can then specifically make a read operation. Writing to the CAN bus works, I simply add data to the struct and then set the “flexcanTxDataOrRemte” flag. But reading … how do I know that new data has been read? I mean I can send the data but then I need to get feedback when it was sent (which I would know in the function below) but then I need to implement synchronization functions to get the feedback back up?
So yea… if you could answer only a few of my questions I think it would help already a lot.
Here is the Code of the function:
// This BOARD_FLEXCAN_HANDLER should probably not be touched????
void BOARD_FLEXCAN_HANDLER(void)
{
PRINTF("Handling stuff \n\r");
// Solve Tx interrupt
if (FLEXCAN_GetMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, TX_MSG_BUF_NUM))
{
PRINTF("A CAN MESSAGE WAS SENT \n\r");
FLEXCAN_ClearMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, TX_MSG_BUF_NUM);
}
// Solve Rx interrupt
if (FLEXCAN_GetMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, RX_MSG_BUF_NUM))
{
PRINTF("A CAN MESSAGE WAS RECEIVED \n\r");
// Lock message buffer for receive data.
FLEXCAN_LockRxMsgBuf(BOARD_FLEXCAN_BASEADDR, RX_MSG_BUF_NUM);
rxBuffer = *rxMsgBufPtr;
FLEXCAN_UnlockAllRxMsgBuf(BOARD_FLEXCAN_BASEADDR);
FLEXCAN_ClearMsgBufStatusFlag(BOARD_FLEXCAN_BASEADDR, RX_MSG_BUF_NUM);
rxCanReceive = true;
}
}