Content originally posted in LPCWare by sposnjak on Fri Mar 27 06:00:13 MST 2015
Hi all!
I need to spy on CAN bus. What I did is:
Chip_CCAN_Init(LPC_C_CAN0);
Chip_CCAN_EnableTestMode(LPC_C_CAN0);
Chip_CCAN_ConfigTestMode(LPC_C_CAN0, CCAN_TEST_SILENT_MODE);
Chip_CCAN_SetBitRate(LPC_C_CAN0, 250000);
Chip_CCAN_EnableInt(LPC_C_CAN0, (CCAN_CTRL_IE | CCAN_CTRL_SIE | CCAN_CTRL_EIE));
NVIC_EnableIRQ(C_CAN0_IRQn);
and then in the interrupt I do:
while ( (can_int = Chip_CCAN_GetIntID(LPC_C_CAN0)) != 0 )
{
if (can_int & CCAN_INT_STATUS)
{
can_stat = Chip_CCAN_GetStatus(LPC_C_CAN0);
// some stuff...
}
}
I can see that can_int is set to CCAN_INT_STATUS and can_stat is set to CCAN_STAT_RXOK => So we have received something, but I do not understand how I can retrieve the message content. I tried with Chip_CCAN_GetMsgObject but messages does not look correct.
Is there a way to get all received messages without setting ID (with the use of Chip_CCAN_AddReceiveID) for all?
Thank you.