/////////////////////////////////////////////////////////////// // I-87120 firmware demo5 -- Use binary 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) { if (CmdLength); switch (UserCmd[1]){ } } void UserDefBinaryFunc(unsigned int CmdLength, char * UserCmd) { int Ret,i; unsigned int len; unsigned int id; unsigned char data[8]; // Process user-defined command for binary code, the UserCmd[0] must be '|' if (CmdLength<3){ ToCom1Str(">CmdErr\r"); return; } len = ((UserCmd[2]*256) + UserCmd[1]); if((len<2)||(len>10)){ ToCom1Str(">CmdErr\r"); return; } id = ((UserCmd[4]*256) + UserCmd[3]); memset(data,0,8); for(i=0;iSendFaile\r"); } void UserLoopFunc(void) { // The function will be excuted in while loop after the I-87120 has be configured }