/////////////////////////////////////////////////////////////// // I-87120 firmware demo4 -- Use ascii command // /////////////////////////////////////////////////////////////// #include "..\..\c87s110.h" #include #include #include 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) { int Ret; unsigned char data[8]; // Process user-defined command, the UserCmd[0] must be '_' if (CmdLength<2){ ToCom1Str(">CmdErr\r"); return; } switch (UserCmd[1]){ case 'A': { data[0]=0x11; data[1]=0x22; data[2]=0x33; data[3]=0x44; data[4]=0x55; data[5]=0x66; data[6]=0x77; data[7]=0x88; Ret=SendCANMsg(0,0x123,0,8,data); if(Ret) ToCom1Str(">SendFaile\r"); break; } case 'q': { return; } default: ToCom1Str(">CmdNoSupport\r"); } } 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) { // The function will be excuted in while loop after the I-87120 has be configured }