[LEFT]msg_obj.msgobj = 1; [B]msg_obj.mode_id = CAN_MSGOBJ_EXT[/B]; msg_obj.mask = 0x0;[/LEFT] (*rom)->pCAND->config_rxmsgobj(&msg_obj); |
[COLOR=Blue]#define LOOP_BACK //use CAN LOOPBACK //CAN TEST[/COLOR] [COLOR=Blue] #define SILENT 3 #define LBACK 4 //CAN Control #define TST 7[/COLOR] /* Initialize the CAN controller */ (*rom)->pCAND->init_can(&ClkInitTable[0], 1); /* Configure the CAN callback functions */ (*rom)->pCAND->config_calb(&callbacks); /* Enable the CAN Interrupt */ [COLOR=Blue]#ifdef LOOP_BACK LPC_CAN->CNTL |= (1<< TST); //enable test mode LPC_CAN->TEST |= (1<< LBACK); //set LOOP TEST //LPC_CAN->TEST |= (1<< SILENT); //set SILENT TEST #endif[/COLOR] NVIC_EnableIRQ(CAN_IRQn); |
#define CAN_MSGOBJ_EXT 0x20000000UL // CAN 2.0b 29-bit ID // Configure message object 1 to receive all 29-bit messages msg_obj.msgobj = 1; msg_obj.mode_id = 0x1FFFFFFF | CAN_MSGOBJ_EXT; msg_obj.mask = 0x000; (*rom)->pCAND->config_rxmsgobj(&msg_obj); |
// Send a simple one time CAN message msg_obj.msgobj = 0; msg_obj.mode_id = 0x345 | CAN_MSGOBJ_EXT; // CAN 2.0b 29-bit ID; msg_obj.mask = 0x0; msg_obj.dlc = 4; msg_obj.data[0] = 'T'; //0x54 msg_obj.data[1] = 'E'; //0x45 msg_obj.data[2] = 'S'; //0x53 msg_obj.data[3] = 'T'; //0x54 (*rom)->pCAND->can_transmit(&msg_obj); |
/* Configure message object 1 to receive all 11-bit messages 0x400-0x4FF */ msg_obj.msgobj = 1; msg_obj.mode_id = 0x400; msg_obj.mask = 0x700; |
msg_obj.id = 0x7FF; msg_obj.mask = 0x000; |