#include "..\..\..\MCU_Lib\8000.h" #include "..\..\..\87CANLib\ver_103\I87KCAN.h" void main(void) { unsigned char Mode=1,RTR=0,DataLen=8,Data[8]={0x12,0x23,0x34,0x45,0x56,0x67,0x78,0x89}; int Ret,i,SlotNo; unsigned long ID=0x12345678UL; //Initiate host InitLib(); //Open COM 0 InstallCom0(115200UL,8,0,1); //Select the slot where the I-87KCAN is plugged. Print("Input the slot (0~7) where the I-87KCAN is plugged: "); Scanf("%d",&SlotNo); if (SlotNo<0 || SlotNo>7){ Print("Slot number error, default to slot 0.\n\r"); SlotNo=0; } Print("Baud is set to 125K\n\r"); ChangeToSlot(SlotNo); //Initiate the I-87KCAN module I87KCANInit(125000UL,0,0,0x00000000UL,0xffffffffUL,0,0); Print("Start to send CAN messages.(any key to exit...)\n\r"); while(!Kbhit()){ //Send CAN message per second Ret=SendCANMsg(Mode,ID,RTR,DataLen,Data); if (Ret){ Print("Send Message Error, Error Code=%d.\n\r",Ret); break; } DelayMs(1000); if (Kbhit()) break; } //Recover the COM 0 setting RestoreCom0(); Print("Exit Program.\n\r"); }