Hi, Thomas,
The MSCAN example based on FRDM-KE06Z in ksdk package uses interrupt mechanism, when the CAN module receives ONE frame, the RXF flag is set, the ISR void MSCAN_TransferHandleIRQ(MSCAN_Type *base, mscan_handle_t *handle) is called automatically.
In the ISR,check the RXF flag, if it is set, read the received frame to a buffer, clear the RXF flag, call the handle->callback(base, handle, status, handle->userData); callback function which you defined.
Hope it can help you
BR
XiangJun Rong
//in fsl_mscan.c file
void MSCAN_TransferHandleIRQ(MSCAN_Type *base, mscan_handle_t *handle)
{
/* Assertion. */
assert(handle);
status_t status = kStatus_MSCAN_UnHandled;
/* Get current State of Message Buffer. */
if (MSCAN_GetRxBufferFullFlag(base))
{
switch (handle->mbStateRx)
{
/* Solve Rx Data Frame. */
case kMSCAN_StateRxData:
status = MSCAN_ReadRxMb(base, handle->mbFrameBuf);
if (kStatus_Success == status)
{
status = kStatus_MSCAN_RxIdle;
}
MSCAN_TransferAbortReceive(base, handle, kMSCAN_RxFullInterruptEnable);
break;
/* Solve Rx Remote Frame. */
case kMSCAN_StateRxRemote:
status = MSCAN_ReadRxMb(base, handle->mbFrameBuf);
if (kStatus_Success == status)
{
status = kStatus_MSCAN_RxIdle;
}
MSCAN_TransferAbortReceive(base, handle, kMSCAN_RxFullInterruptEnable);
break;
}
MSCAN_ClearRxBufferFullFlag(base);
}
else
{
switch (handle->mbStateTx)
{
/* Solve Tx Data Frame. */
case kMSCAN_StateTxData:
status = kStatus_MSCAN_TxIdle;
MSCAN_TransferAbortSend(base, handle, kMSCAN_TxEmptyInterruptEnable);
break;
/* Solve Tx Remote Frame. */
case kMSCAN_StateTxRemote:
handle->mbStateRx = kMSCAN_StateRxRemote;
status = kStatus_MSCAN_TxSwitchToRx;
break;
default:
status = kStatus_MSCAN_UnHandled;
break;
}
}
handle->callback(base, handle, status, handle->userData);
}