#include "..\..\..\MCU_Lib\8000e.h" #include "..\..\..\I8120Lib\ver_100\I8120.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(); //Select the slot where the I-8120 is plugged. Print("Input the slot (0~3) where the I-8120 is plugged: "); Scanf("%d",&SlotNo); if (SlotNo<0 || SlotNo>7){ Print("Slot number error, default to slot 0.\n\r"); SlotNo=0; } //Initiate the I-8120 module Ret=I8120Init(SlotNo,125000UL,0,0,0x00000000UL,0xffffffffUL); if (Ret){ Print("Initiate I-8120 error, error code=%d\n\r",Ret); return; } Print("Baud is set to 125K\n\r"); Print("Start to send CAN messages.(any key to exit...)\n\r"); while(!Kbhit()){ //Send CAN message per second Ret=SendCANMsg(SlotNo,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 system resource RecoverI8120(); Print("Exit Program.\n\r"); }