/////////////////////////////////////////////////////////////// // I-87120 firmware demo3 -- CAN message to ASCII code // /////////////////////////////////////////////////////////////// #include "..\..\c87s110.h" #include #include #include unsigned char InterruptFlag=0; void UserIrqFunc(char INTT) { // If CPU is interrupted by the CAN controller, the function will be excuted if (INTT); } void UserInitFunc(void) { int ret; // The function will be excuted first after I-87120 is power on ret = SetCANBaud(1000000UL, 0, 0); // Set CAN Baud to 1M bps if(ret) ToCom1Str(">SetCANBaudFaile\r"); ret = SetCANMask(0x00000000, 0xFFFFFFFF); // Set CAN Mask if(ret) ToCom1Str(">SetCANMaskFaile\r"); } void UserDefCmdFunc(unsigned int CmdLength, char * UserCmd) { // Process user-defined command, the UserCmd[0] must be '_' if (CmdLength); switch (UserCmd[1]){ } } void UserDefBinaryFunc(unsigned int CmdLength, char * UserCmd) { // Process user-defined command for binary code, the UserCmd[0] must be '|' if (CmdLength); switch (UserCmd[1]){ } } void UserLoopFunc(void) { int ret,i; unsigned char Mode,RTR,DataLen,Data[8]; unsigned long ID; char strtemp[100],cattemp[20]; // The function will be excuted in while loop after the I-87120 has be configured ret = GetCANMsg(&Mode,&ID,&RTR,&DataLen,Data); if(!ret){ if((!Mode)&&(ID == 0x123)){ if(DataLen){ sprintf(strtemp,"Message:"); for(i=0;i