|
@@ -0,0 +1,571 @@
|
|
|
+/**
|
|
|
+ * @file giant_can.h
|
|
|
+ * @author Ye Jin
|
|
|
+ * @brief giant can protocol
|
|
|
+ * @version 0.1
|
|
|
+ * @date 2025-01-09
|
|
|
+ *
|
|
|
+ * @copyright Copyright (c) 2025
|
|
|
+ *
|
|
|
+ */
|
|
|
+
|
|
|
+/************************************************************************
|
|
|
+ Beginning of File, do not put anything above here except notes
|
|
|
+ Compiler Directives:
|
|
|
+*************************************************************************/
|
|
|
+#include "can.h"
|
|
|
+#include "giant_can.h"
|
|
|
+#include "canAppl.h"
|
|
|
+#include "string.h"
|
|
|
+#include "AssistCurve.h"
|
|
|
+#include "adc.h"
|
|
|
+#include "power.h"
|
|
|
+#include "CodePara.h"
|
|
|
+/******************************
|
|
|
+ *
|
|
|
+ * Parameter
|
|
|
+ *
|
|
|
+ ******************************/
|
|
|
+GiantStandardDataFrameID_Struct_t stGiantStandardDataFrameID_rx;
|
|
|
+GiantStandardRemoteFrameID_Struct_t stGiantStandardRemoteFrameID_rx;
|
|
|
+GiantControlParams_Struct_t stGiantControlParams;
|
|
|
+/***************************************************************
|
|
|
+ Function:
|
|
|
+ Description:
|
|
|
+ Call by:
|
|
|
+ Input Variables: N/A
|
|
|
+ Output/Return Variables: N/A
|
|
|
+ Subroutine Call: N/A;
|
|
|
+ Reference: N/A
|
|
|
+****************************************************************/
|
|
|
+void giant_10msTask(void)
|
|
|
+{
|
|
|
+ static UBYTE giant_10mscount = 0;
|
|
|
+
|
|
|
+ giant_10mscount++;
|
|
|
+ if(giant_10mscount >= 5)
|
|
|
+ {
|
|
|
+ giant_10mscount = 0;
|
|
|
+ for(int i=0;i<9;i++)
|
|
|
+ {
|
|
|
+ giant_SendDriveChainActiveData(FG_NORMALDATA, i);
|
|
|
+ }
|
|
|
+ giant_SendDriveChainActiveData(FG_NORMALDATA, 0xF);
|
|
|
+ }
|
|
|
+}
|
|
|
+void giant_DataProcess(void)
|
|
|
+{
|
|
|
+ if(pRxMsg2->rx_ft == CAN_FT_DATA)
|
|
|
+ {
|
|
|
+ stGiantStandardDataFrameID_rx.FunctionGroup = (UBYTE)((pRxMsg2->rx_sfid & 0x600)>>9);
|
|
|
+ stGiantStandardDataFrameID_rx.NodeGroup = (UBYTE)((pRxMsg2->rx_sfid & 0x1E0)>>5);
|
|
|
+ stGiantStandardDataFrameID_rx.DataBehaviors = (UBYTE)((pRxMsg2->rx_sfid & 0x010)>>4);
|
|
|
+ stGiantStandardDataFrameID_rx.DataAddress = (UBYTE)(pRxMsg2->rx_sfid & 0x00F);
|
|
|
+
|
|
|
+ switch (stGiantStandardDataFrameID_rx.NodeGroup)
|
|
|
+ {
|
|
|
+ case NODE_SERVICETOOL:
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case NODE_USERINTERFACE:
|
|
|
+ {
|
|
|
+ ulOBC_ComTimeOutCount = cp_ulSystickCnt;
|
|
|
+ stGiantControlParams.RefreshFlag = TRUE;
|
|
|
+ switch(stGiantStandardDataFrameID_rx.DataAddress)
|
|
|
+ {
|
|
|
+ case 0x0:
|
|
|
+ {
|
|
|
+ if(pRxMsg2->rx_dlen == 2)//error
|
|
|
+ {
|
|
|
+ stGiantControlParams.Error = (pRxMsg2->rx_data[0] & 0x01);//Error value
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x1:
|
|
|
+ {
|
|
|
+ if(pRxMsg2->rx_dlen == 7)//cmd1
|
|
|
+ {
|
|
|
+ stGiantControlParams.ManualSleepEn = ((pRxMsg2->rx_data[0] & 0x40)>>6);//Manual sleep
|
|
|
+ stGiantControlParams.AutomaticSleepEn = ((pRxMsg2->rx_data[0] & 0x20)>>5);//Automatic sleep
|
|
|
+
|
|
|
+ stGiantControlParams.InactivateErrorDetection = ((pRxMsg2->rx_data[1] & 0x80)>>7);//Inactivate the error detection
|
|
|
+
|
|
|
+ if((pRxMsg2->rx_data[1] & 0x10) == 0x10)//Reset fault history
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ stGiantControlParams.ThrottleEn = ((pRxMsg2->rx_data[1] & 0x08)>>3);//Throttle state
|
|
|
+
|
|
|
+ if((pRxMsg2->rx_data[1] & 0x04) == 0x04)//Reset trip distance and trip time
|
|
|
+ {
|
|
|
+ MC_RideLog.TRIP_Km = 0;
|
|
|
+ MC_RideLog.TRIP_Time = 0;
|
|
|
+ MC_RunInfo.Ride_Km = 0;
|
|
|
+ MC_RunInfo.Ride_Time = 0;
|
|
|
+ cp_stHistoryPara.ulTripSum = 0;
|
|
|
+ cp_stHistoryPara.ulTripSumTime = 0;
|
|
|
+ cp_stHistoryPara.ulODOTime = cp_stHistoryPara.ulODOTime + (cp_stBikeRunInfoPara.ulRiTime >> 10) / 60;
|
|
|
+ cp_stBikeRunInfoPara.ulRiTime = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ stGiantControlParams.BrakeleEn = ((pRxMsg2->rx_data[1] & 0x02)>>1);//Brake state
|
|
|
+ stGiantControlParams.WalkEn = (pRxMsg2->rx_data[1] & 0x01);//Walk
|
|
|
+
|
|
|
+ if(pRxMsg2->rx_data[2] > 100)
|
|
|
+ {
|
|
|
+ stGiantControlParams.ThrottlePowerPercentage = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ stGiantControlParams.ThrottlePowerPercentage = pRxMsg2->rx_data[2];//Throttle power percentage %,else 0%
|
|
|
+ }
|
|
|
+
|
|
|
+ stGiantControlParams.RidingModeEn = ((pRxMsg2->rx_data[3] & 0x80)>>7);//Riding mode
|
|
|
+ stGiantControlParams.AdjustingMode = (pRxMsg2->rx_data[3] & 0x1F);//Adjusting mode
|
|
|
+ if((stGiantControlParams.AdjustingMode >= 0x6) && (stGiantControlParams.AdjustingMode <= 0xA))//Service mode
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else if(stGiantControlParams.AdjustingMode == 0xB)//Check mode
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else if(stGiantControlParams.AdjustingMode == 0xC)//Off mode
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else if(stGiantControlParams.AdjustingMode == 0xD)//error state
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if((pRxMsg2->rx_data[4] & 0x04) == 0x04)//Reset odometer distance and odometer time
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ ass_stParaCong.uwStartMode = ((pRxMsg2->rx_data[6] & 0xC0) >> 6);//Start mode,1-soft,2-normal,3-strong
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x2:
|
|
|
+ {
|
|
|
+ if(pRxMsg2->rx_dlen == 7)//cmd2
|
|
|
+ {
|
|
|
+ if((pRxMsg2->rx_data[0] & 0x30) == 0x00)
|
|
|
+ {
|
|
|
+ MC_ControlCode.LightSwitch = MC_LightSwitch_OFF;//light off
|
|
|
+ }
|
|
|
+ else if((pRxMsg2->rx_data[0] & 0x30) == 0x10)
|
|
|
+ {
|
|
|
+ MC_ControlCode.LightSwitch = MC_LightSwitch_ON;//light on
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //rsv
|
|
|
+ }
|
|
|
+ MC_RunInfo.LightSwitch = MC_ControlCode.LightSwitch;
|
|
|
+
|
|
|
+ stGiantControlParams.WheelCircumference = (pRxMsg2->rx_data[2] + (pRxMsg2->rx_data[3]<<8));//Tire circumference,900-2500mm
|
|
|
+// if(stGiantControlParams.WheelCircumference < 900)
|
|
|
+// {
|
|
|
+// stGiantControlParams.WheelCircumference = 900;//default
|
|
|
+// }
|
|
|
+// else if(stGiantControlParams.WheelCircumference > 2500)
|
|
|
+// {
|
|
|
+// stGiantControlParams.WheelCircumference = 2500;//default
|
|
|
+// }
|
|
|
+
|
|
|
+ stGiantControlParams.MaximumTorque = ((pRxMsg2->rx_data[4] & 0xF0)>>4);//Maximum torque,*10Nm
|
|
|
+// if(0 == stGiantControlParams.MaximumTorque)
|
|
|
+// {
|
|
|
+// stGiantControlParams.MaximumTorque = 0;//default
|
|
|
+// }
|
|
|
+
|
|
|
+ stGiantControlParams.Acceleration = (pRxMsg2->rx_data[4] & 0x0F);//Acceleration,*30Nm/s
|
|
|
+// if(0 == stGiantControlParams.Acceleration)
|
|
|
+// {
|
|
|
+// stGiantControlParams.Acceleration = 0;//default
|
|
|
+// }
|
|
|
+
|
|
|
+ stGiantControlParams.AssistRatio = pRxMsg2->rx_data[5];;//Assist ratio, *10%
|
|
|
+
|
|
|
+ stGiantControlParams.MaximumPower = pRxMsg2->rx_data[6];//Maximum power, *10Watt
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x3:
|
|
|
+ {
|
|
|
+ if(pRxMsg2->rx_dlen == 8)//cmd3
|
|
|
+ {
|
|
|
+ stGiantControlParams.SpeedLimitation = (UWORD)(pRxMsg2->rx_data[5] + (pRxMsg2->rx_data[6]<<8));//speed limitation,0.01km/h
|
|
|
+// if(0 == stGiantControlParams.SpeedLimitation)
|
|
|
+// {
|
|
|
+// stGiantControlParams.SpeedLimitation = 2500;//DU default
|
|
|
+// }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case NODE_MOTINOVA:
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case NODE_ENERGYPACK:
|
|
|
+ {
|
|
|
+ ulBMS_ComTimeOutCount = cp_ulSystickCnt;
|
|
|
+ switch(stGiantStandardDataFrameID_rx.DataAddress)
|
|
|
+ {
|
|
|
+ case 0x1:
|
|
|
+ {
|
|
|
+ if(pRxMsg2->rx_dlen == 8)//Capacity
|
|
|
+ {
|
|
|
+ BMS_RunInfo.SOC = pRxMsg2->rx_data[0];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case NODE_GIANTAPP:
|
|
|
+ {
|
|
|
+ switch(stGiantStandardDataFrameID_rx.DataAddress)
|
|
|
+ {
|
|
|
+ case 0x4:
|
|
|
+ {
|
|
|
+ if(pRxMsg2->rx_dlen == 8)//Customized Version
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(pRxMsg2->rx_ft == CAN_FT_REMOTE)
|
|
|
+ {
|
|
|
+ stGiantStandardRemoteFrameID_rx.MotionGroup = (UBYTE)((pRxMsg2->rx_sfid & 0x700)>>8);
|
|
|
+ stGiantStandardRemoteFrameID_rx.RequireNodeGroup = (UBYTE)((pRxMsg2->rx_sfid & 0x0F0)>>4);
|
|
|
+ stGiantStandardRemoteFrameID_rx.ResponseNodeGroup = (UBYTE)(pRxMsg2->rx_sfid & 0x00F);
|
|
|
+
|
|
|
+ if((stGiantStandardRemoteFrameID_rx.ResponseNodeGroup == NODE_ALL) || (stGiantStandardRemoteFrameID_rx.ResponseNodeGroup == NODE_DRIVECHAIN))//
|
|
|
+ {
|
|
|
+ switch(stGiantStandardRemoteFrameID_rx.MotionGroup)
|
|
|
+ {
|
|
|
+ case MG_HEARTBEAT:
|
|
|
+ {
|
|
|
+ giant_SendDriveChainPassiveData(stGiantStandardRemoteFrameID_rx.MotionGroup,0xF);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case MG_CONFIRMATION:
|
|
|
+ {
|
|
|
+ giant_SendDriveChainPassiveData(stGiantStandardRemoteFrameID_rx.MotionGroup,0xF);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case MG_ACTIVEDATA1:
|
|
|
+ {
|
|
|
+ for(int i=0;i<8;i++)
|
|
|
+ {
|
|
|
+ giant_SendDriveChainActiveData(FG_RESPONSEDATA, i);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case MG_ACTIVEDATA2:
|
|
|
+ {
|
|
|
+ giant_SendDriveChainActiveData(FG_RESPONSEDATA, 0x8);
|
|
|
+ giant_SendDriveChainActiveData(FG_RESPONSEDATA, 0xF);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case MG_PASSIVEDATA1:
|
|
|
+ {
|
|
|
+ giant_SendDriveChainPassiveData(stGiantStandardRemoteFrameID_rx.MotionGroup,0x0);
|
|
|
+ giant_SendDriveChainPassiveData(stGiantStandardRemoteFrameID_rx.MotionGroup,0x1);
|
|
|
+ giant_SendDriveChainPassiveData(stGiantStandardRemoteFrameID_rx.MotionGroup,0x2);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case MG_PASSIVEDATA2:
|
|
|
+ {
|
|
|
+ giant_SendDriveChainPassiveData(stGiantStandardRemoteFrameID_rx.MotionGroup,0x3);
|
|
|
+ giant_SendDriveChainPassiveData(stGiantStandardRemoteFrameID_rx.MotionGroup,0x4);
|
|
|
+ giant_SendDriveChainPassiveData(stGiantStandardRemoteFrameID_rx.MotionGroup,0x5);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case MG_PASSIVEDATA3:
|
|
|
+ {
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case MG_PASSIVEDATA4:
|
|
|
+ {
|
|
|
+ giant_SendDriveChainPassiveData(stGiantStandardRemoteFrameID_rx.MotionGroup,0xB);
|
|
|
+ giant_SendDriveChainPassiveData(stGiantStandardRemoteFrameID_rx.MotionGroup,0xC);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void giant_SendDriveChainPassiveData(UBYTE remoteMG, UBYTE DataAddr)
|
|
|
+{
|
|
|
+ UBYTE len = 8;
|
|
|
+ UBYTE data[8] = {0,};
|
|
|
+ UWORD ID = 0;
|
|
|
+
|
|
|
+ ID = ((FG_RESPONSEDATA<<9)
|
|
|
+ |(NODE_DRIVECHAIN<<5)
|
|
|
+ |(DB_PASSIVEDATA<<4)
|
|
|
+ |DataAddr);
|
|
|
+
|
|
|
+ switch(DataAddr)
|
|
|
+ {
|
|
|
+ case 0x0:
|
|
|
+ {
|
|
|
+ memcpy(data, MC_VerInfo.Mode, 8);//Mode name
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x1:
|
|
|
+ {
|
|
|
+ memcpy(data, MC_VerInfo.FW_Version, 8);//FW1
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x2:
|
|
|
+ {
|
|
|
+ memcpy(data, &MC_VerInfo.FW_Version[8], 8);//FW2
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x3:
|
|
|
+ {
|
|
|
+ memcpy(data, MC_VerInfo.HW_Version, 8);//HW1
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x4:
|
|
|
+ {
|
|
|
+ memcpy(data, &MC_VerInfo.HW_Version[8], 8);//HW2
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x5:
|
|
|
+ {
|
|
|
+ //memcpy(data, MC_VerInfo., 8);//Customized Version
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0xB:
|
|
|
+ {
|
|
|
+ memcpy(data, MC_VerInfo.SN_Num, 8);//SN1
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0xC:
|
|
|
+ {
|
|
|
+ memcpy(data, &MC_VerInfo.SN_Num[8], 8);//SN2
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0xF:
|
|
|
+ {
|
|
|
+ len = 4;
|
|
|
+ data[0] = 0x1;//success
|
|
|
+ if(remoteMG == MG_HEARTBEAT)
|
|
|
+ {
|
|
|
+ data[1] = 0x00;
|
|
|
+ data[2] = 0x00;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ memcpy(&data[1], &ass_stParaCong.uwWheelPerimeter, 2);//circumference
|
|
|
+ }
|
|
|
+ data[3] = (UBYTE)ass_stParaCong.swDeltPerimeter;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ CAN_SendData(ID, data, len);
|
|
|
+}
|
|
|
+
|
|
|
+void giant_SendDriveChainActiveData(UBYTE functiongroup, UBYTE dataaddr)
|
|
|
+{
|
|
|
+ UBYTE len = 8;
|
|
|
+ UBYTE data[8] = {0,};
|
|
|
+ UWORD ID = 0;
|
|
|
+
|
|
|
+ ID = ((functiongroup<<9)
|
|
|
+ |(NODE_DRIVECHAIN<<5)
|
|
|
+ |(DB_ACTIVEDATA<<4)
|
|
|
+ |dataaddr);
|
|
|
+
|
|
|
+ switch(dataaddr)
|
|
|
+ {
|
|
|
+ case 0x0: //Error
|
|
|
+ {
|
|
|
+ len = 2;
|
|
|
+ if(0)
|
|
|
+ {
|
|
|
+ data[0] |= 0x01;// Corresponding error occurs
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data[0] &= 0xFE;// Corresponding error was gone
|
|
|
+ }
|
|
|
+ data[1] = 0x60;//Error code-Normal
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x1: //Cycling State
|
|
|
+ {
|
|
|
+ len = 5;
|
|
|
+ data[0] |= 0x00;//Communication sleep
|
|
|
+ if(MC_RunInfo.LightSwitch == MC_LightSwitch_ON)
|
|
|
+ {
|
|
|
+ data[2] |= (0x01<<6);
|
|
|
+ }
|
|
|
+ data[2] |= (ass_stParaCong.uwStartMode<<4);
|
|
|
+ data[2] |= (MC_RunInfo.CadenceDir<<2);
|
|
|
+ data[3] = (UBYTE)(stGiantControlParams.SpeedLimitation & 0xFF);// speed limitation,0.01km/h
|
|
|
+ data[4] = (UBYTE)((stGiantControlParams.SpeedLimitation & 0xFF00) >> 8);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x2: //Cycling data
|
|
|
+ {
|
|
|
+ len = 8;
|
|
|
+ data[0] = (UBYTE)(MC_RunInfo.BikeSpeed & 0xFF);// bike speed,0.1km/h
|
|
|
+ data[1] = (UBYTE)((MC_RunInfo.BikeSpeed & 0xFF00) >> 8);
|
|
|
+ data[2] = (UBYTE)((MC_RunInfo.Torque*10) & 0xFF);// pedal torque,0.1Nm
|
|
|
+ data[3] = (UBYTE)(((MC_RunInfo.Torque*10) & 0xFF00) >> 8);
|
|
|
+ data[4] = (UBYTE)((MC_RunInfo.Cadence*10) & 0xFF);// cadence,0.1RPM
|
|
|
+ data[5] = (UBYTE)(((MC_RunInfo.Cadence*10) & 0xFF00) >> 8);
|
|
|
+ data[6] = (UBYTE)((MC_RunInfo.BusCurrent/10) & 0xFF);// phase current,0.01A
|
|
|
+ data[7] = (UBYTE)(((MC_RunInfo.BusCurrent/10) & 0xFF00) >> 8);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x3: //cycling data 1
|
|
|
+ {
|
|
|
+ len = 8;
|
|
|
+ if(blBMSCommFault == TRUE)
|
|
|
+ {
|
|
|
+ data[1] = MC_RunInfo.SOC;//%
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data[1] = 0xFF;
|
|
|
+ }
|
|
|
+ data[2] = (UBYTE)(MC_RideLog.TRIP_Km & 0xFF);// trip distance,0.1km
|
|
|
+ data[3] = (UBYTE)((MC_RideLog.TRIP_Km & 0xFF00) >> 8);
|
|
|
+ data[4] = (UBYTE)(MC_RideLog.TRIP_Time & 0xFF);// trip time,min
|
|
|
+ data[5] = (UBYTE)((MC_RideLog.TRIP_Time & 0xFF00) >> 8);
|
|
|
+ data[6] = (UBYTE)((MC_RideLog.ODO_Km /10) & 0xFF);// odometer distance,km
|
|
|
+ data[7] = (UBYTE)(((MC_RideLog.ODO_Km /10) & 0xFF00) >> 8);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x4:
|
|
|
+ {
|
|
|
+ len = 8;
|
|
|
+ data[0] = (UBYTE)((MC_RideLog.ODO_Time/60) & 0xFF);// odometer time,h
|
|
|
+ data[1] = (UBYTE)(((MC_RideLog.ODO_Time/60) & 0xFF00) >> 8);
|
|
|
+ if(adc_stUpOut.PCBTemp>254)
|
|
|
+ {
|
|
|
+ data[2] = 127;
|
|
|
+ data[5] = 127;
|
|
|
+ }
|
|
|
+ else if(adc_stUpOut.PCBTemp>127)
|
|
|
+ {
|
|
|
+ data[2] = 127;
|
|
|
+ data[5] = (UBYTE)(adc_stUpOut.PCBTemp/2);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data[2] = (UBYTE)adc_stUpOut.PCBTemp;
|
|
|
+ data[5] = (UBYTE)(adc_stUpOut.PCBTemp/2);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x6:
|
|
|
+ {
|
|
|
+ len = 8;
|
|
|
+ data[0] = (UBYTE)(MC_RunInfo.BusVoltage & 0xFF);// bus input voltage,mV
|
|
|
+ data[1] = (UBYTE)((MC_RunInfo.BusVoltage & 0xFF00) >> 8);
|
|
|
+ data[2] = (UBYTE)((BMS_VoltEstimat.uwIbusLpf/10) & 0xFF);//bus input current,0.01A
|
|
|
+ data[3] = (UBYTE)(((BMS_VoltEstimat.uwIbusLpf/10) & 0xFF00) >> 8);
|
|
|
+ data[4] = (UBYTE)(MC_RunInfo.MotorSpeed & 0xFF);// motor rotor speed,RPM
|
|
|
+ data[5] = (UBYTE)((MC_RunInfo.MotorSpeed & 0xFF00) >> 8);
|
|
|
+// data[6] = (UBYTE)(MC_RunInfo.RemainDistance & 0xFF);// remaining range of drive chain system,km
|
|
|
+// data[7] = (UBYTE)((MC_RunInfo.RemainDistance & 0xFF00) >> 8);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x7:
|
|
|
+ {
|
|
|
+ len = 8;
|
|
|
+ data[0] = (UBYTE)(MC_RunInfo.Ride_Km & 0xFF);// ride distance after power on,0.1km
|
|
|
+ data[1] = (UBYTE)((MC_RunInfo.Ride_Km & 0xFF00) >> 8);
|
|
|
+ data[2] = (UBYTE)((MC_RunInfo.Ride_Time/60) & 0xFF);//ride time after power on,min
|
|
|
+ data[3] = (UBYTE)(((MC_RunInfo.Ride_Time/60) & 0xFF00) >> 8);
|
|
|
+// data[4] = (UBYTE)((MC_RideLog.ODO_Km/10) & 0xFF);// total ride distance Can’t be reset
|
|
|
+// data[5] = (UBYTE)(((MC_RideLog.ODO_Km/10) & 0xFF00) >> 8);
|
|
|
+// data[6] = (UBYTE)((MC_RideLog.ODO_Time/60) & 0xFF);// rtotal ride time Can’t be reset
|
|
|
+// data[7] = (UBYTE)(((MC_RideLog.ODO_Time/60) & 0xFF00) >> 8);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0x8:
|
|
|
+ {
|
|
|
+ len = 5;
|
|
|
+ data[0] = stGiantControlParams.AssistRatio;// Assist ratio state
|
|
|
+ data[1] = stGiantControlParams.MaximumPower;//Maximum power
|
|
|
+ data[2] = (stGiantControlParams.MaximumTorque<<4)|(stGiantControlParams.Acceleration);// rtotal ride time Can’t be reset
|
|
|
+ if(adc_stUpOut.PCBTemp>254)
|
|
|
+ {
|
|
|
+ data[3] = 127;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data[3] = (UBYTE)(adc_stUpOut.PCBTemp/2);
|
|
|
+ }
|
|
|
+ data[4] = MC_RunInfo.PowerPerKm;//Average power consumption ,0.01Ah/km
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 0xF:
|
|
|
+ {
|
|
|
+ len = 6;
|
|
|
+// data[4] = (UBYTE)(MC_RunInfo.RemainDistance & 0xFF);// human power
|
|
|
+// data[5] = (UBYTE)((MC_RunInfo.RemainDistance & 0xFF00) >> 8);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ CAN_SendData(ID, data, len);
|
|
|
+}
|
|
|
+
|
|
|
+void giant_CanProcess(void)
|
|
|
+{
|
|
|
+ if(stGiantControlParams.RefreshFlag)
|
|
|
+ {
|
|
|
+ stGiantControlParams.RefreshFlag = FALSE;
|
|
|
+
|
|
|
+ if((stGiantControlParams.AdjustingMode == 0xC) || (stGiantControlParams.ManualSleepEn) || (stGiantControlParams.AutomaticSleepEn) || ((cp_ulSystickCnt - ulOBC_ComTimeOutCount) < 3000))//Off state
|
|
|
+ {
|
|
|
+ power_stPowStateOut.powerstate = POWER_OFF;
|
|
|
+ power_stPowStateOut.blPowerStartupFlg = FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+/*************************************************************************
|
|
|
+ End of this File (EOF)!
|
|
|
+ Do not put anything after this part!
|
|
|
+*************************************************************************/
|