瀏覽代碼

模式转化加入

CHENJIE-PC\QiXiang_CHENJIE 2 年之前
父節點
當前提交
c24f0f9a86

+ 1 - 3
Global/SysConf.h

@@ -28,7 +28,5 @@
 #define _SAMPLE_CODE_
 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
-//#define _APP_TEST_CODE
-#define _APP_RELEASE_CODE
-//#define _APP_TEST_MOTOR_CODE
+
 #endif

+ 78 - 544
System/Vehicle/AppFunc.c

@@ -23,21 +23,23 @@ void LockAndUnlockCtrl()
 	static uint16 LockDelay = 0;
 	static uint16 UnlockDelay = 0;
 	static uint8 CtrlFlg = 0;
+	static uint16 BleConCounter = 0;
+	static uint16 battSwpeModeCounter = 0;
 	if (ebcd_flg_ebcManCtrlEn) //手动控制使能
 	{
-		if (ebcd_flg_ebcManCtrlMode==1)
+		if (ebcd_flg_ebcManCtrlMode==1)//循环控制模式
 		{
-			if(ebcd_st_lockSensor==1)//处于锁紧状态
+			if(ebcd_st_lockSensor==1)//处于锁紧状态,传感器判定一个
 			{
 				LockDelay = LockDelay + 10;
 				if(LockDelay>LockDelayTime)//锁紧状态超时就解锁
 				{
-					Control_Times++;
+					ManuControlTimes++;
 					LockDelay = 0;
 					CtrlFlg = Unlock;
 				}
 			}
-			else if(ebcd_st_unlockSensor==1)//处于解锁状态
+			else if(ebcd_st_unlockSensor==1)//处于解锁状态,传感器判定一个
 			{
 				UnlockDelay = UnlockDelay + 10;
 				if(UnlockDelay>UnlockDelayTime)
@@ -47,20 +49,89 @@ void LockAndUnlockCtrl()
 				}
 			}
 		}
-		else if(ebcd_flg_ebcManCtrlMode==2)
+		else if(ebcd_flg_ebcManCtrlMode==2)//控制锁紧
 		{
 			CtrlFlg = Lock;
 		}
-		else if(ebcd_flg_ebcManCtrlMode==3)
+		else if(ebcd_flg_ebcManCtrlMode==3)//控制解锁
 		{
 			CtrlFlg = Unlock;
 		}
-
 	}
 	else //正常工作模式,暂时为空
 	{
+		switch(ebcd_st_ebcWork)
+		{
+		case 0://行车状态,自动进入,默认状态
+		{
+			PSwtDrv_Interface(_PSWT_INDEX_EBCLEDCONTROL,0);//行车状态换电指示灯关闭
+			if(bled_flg_handShake==1)
+			{
+				ebcd_st_ebcWork = 1;
+				bled_flg_handShake = 0;
+				break;
+			}
+			break;
+		}
+		case 1://通讯状态,握手才能进入
+		{
+			BleConCounter = BleConCounter + 10;
+			if((BleConCounter%1000)<500)//换电指示灯闪烁
+			{
+				PSwtDrv_Interface(_PSWT_INDEX_EBCLEDCONTROL,1);
+			}
+			else
+			{
+				PSwtDrv_Interface(_PSWT_INDEX_EBCLEDCONTROL,0);
+			}
 
+			if(BleConCounter>=60*1000||bled_flg_backToDrv == 1)
+			{
+				ebcd_st_ebcWork = 0;//切换到行车状态
+				BleConCounter = 0;
+				bled_flg_backToDrv = 0;
+				break;
+			}
+			else if(BattCD_stWakeupU.B.bLogic==0&&(bled_flg_toSwapMod==1 || BattCD_stWakeupU.B.bWkpSig1==1))
+			{
+				ebcd_st_ebcWork = 2;//切换到换电状态
+				BleConCounter = 0;
+				bled_flg_toSwapMod = 0;
+				break;
+			}
+			if(bled_st_dataTrans==1)
+			{
+				BleConCounter = 0;
+				bled_st_dataTrans = 0;
+			}
+			break;
+		}
+		case 2://换电状态
+		{
+			PSwtDrv_Interface(_PSWT_INDEX_EBCLEDCONTROL,1);//换电状态换电指示灯常亮
+			battSwpeModeCounter = battSwpeModeCounter + 10;
+			if(bled_flg_swapBattDone==1)
+			{
+				bled_flg_swapBattDone = 0;
+				ebcd_st_ebcWork = 1; //切换到通讯状态
+				break;
+			}
+			else if(battSwpeModeCounter>=60*1000)
+			{
+				battSwpeModeCounter = 0;//切换到行车状态
+				ebcd_st_ebcWork = 0;
+				break;
+			}
+			if(bled_st_dataTrans==1)
+			{
+				battSwpeModeCounter = 0;
+				bled_st_dataTrans = 0;
+			}
+			break;
+		}
+		}
 	}
+
 	//锁紧解锁执行
 	if(CtrlFlg)
 	{
@@ -281,540 +352,3 @@ uint16 Look1_u32u8(uint32 u0, uint32 *bp0, uint8 *table, uint16 MaxLen)
 	}
 	return y;
 }
-#ifdef _APP_TEST_CODE
-void TestDeviceFun(void)
-{
-	uint8 ManuEnable = 0;
-	//控制算法
-	AccPedCD_Update();
-	AccPedCD_Monitor();
-
-	PulseAcqDrv_GetChanFreq(_PULSEACQ_INDEX_CP_CHAN, &VehCo_fInputUIA[0], &VehCo_rInputUWA[0]);
-
-	// DODrv_SetChanState(_DO_INDEX_CPCTL_CHAN,(uint8)VehCo_bTestCPCtrlUW_C);
-
-	uint16 DistenceBufferV[2] = {0, 0}, DistenceBufferR[2] = {0, 0};
-	//开关1采集
-	DINDrv_SetChanThres(_DIN_INDEX_BAK1_CHAN, 1, 4095U);
-	Switch1 = !DINDrv_GetChanState(_DIN_INDEX_BAK1_CHAN);
-	//手动控制采集
-	DINDrv_SetChanThres(_DIN_INDEX_BAK2_CHAN, 1, 4095U);
-	ManuEnable = !DINDrv_GetChanState(_DIN_INDEX_BAK2_CHAN);
-	//位移量采集
-	DistenceBufferV[0] = ATDDrv_GetChanResult(_ATD_INDEX_BAK3_CHAN);
-	DistenceBufferR[0] = (uint16)((DistenceBufferV[0] / (5.0 * 4095 - DistenceBufferV[0])) * 1000.0);
-	Distence1 = (uint16)((2132 - DistenceBufferR[0]) * (0.1219));
-	//压力采集
-	PressureValueBuffer = ATDDrv_GetChanResult(_ATD_INDEX_ACCPED1_CHAN);
-	PressureValue = (uint32)(PressureValueBuffer * 1000 / 4095.0);
-	//控制输出
-	VehCo_ctEEPTestUI += 10;
-	VehCo_ctEEPTestUB += 10;
-	if (VehCo_ctEEPTestUI >= 4 * 1000)
-	{
-		PSwtDrv_Interface(_PSWT_INDEX_HBAK1_CHAN, 1); //输出 解锁持续9-4s
-		ControlState = 1;							  //解锁
-	}
-	else
-	{
-		PSwtDrv_Interface(_PSWT_INDEX_HBAK1_CHAN, 0); //不输出
-		ControlState = 2;							  //锁定 4 秒
-	}
-	if (VehCo_ctEEPTestUI >= 9 * 1000)
-	{
-		Control_Times++;
-		VehCo_ctEEPTestUI = 0;
-	}
-	if (ManuEnable == 0)
-	{
-		Control_Times = 0;
-		VehCo_ctEEPTestUI = 0;
-	}
-}
-#endif
-#ifdef _APP_TEST_MOTOR_CODE
-void MotorTestFun(void)
-{
-	static uint32 MotorRunTimer = 0;
-	static uint16 MotorLockReadyTimer = 0;
-	static sint8 LockMotorNum = -1;
-	static sint8 unLockMotorNum = -1;
-	static uint32 testTimer = 0;
-	GetDIOState();
-	GetAIOValue();
-	testTimer = testTimer + 10;
-	MotorControlLockNum = LockMotorNum;
-	MotorControlunLockNum = unLockMotorNum;
-	if (MotorControlCmd == 0) //可进入调试模式
-	{
-		if (MotorDebugCmd == 1)
-		{
-			if (getbit(MotorControlEnable, 0) == 1)
-			{
-				MotorControlFunc(0, 1);
-				return;
-			}
-			else if (getbit(MotorControlEnable, 1) == 1)
-			{
-				MotorControlFunc(1, 1);
-				return;
-			}
-			else if (getbit(MotorControlEnable, 2) == 1)
-			{
-				MotorControlFunc(2, 1);
-				return;
-			}
-			else if (getbit(MotorControlEnable, 3) == 1)
-			{
-				MotorControlFunc(3, 1);
-				return;
-			}
-			else
-			{
-				return;
-			}
-		}
-		else if (MotorDebugCmd == 2)
-		{
-			if (getbit(MotorControlEnable, 0) == 1)
-			{
-				MotorControlFunc(0, 2);
-				return;
-			}
-			else if (getbit(MotorControlEnable, 1) == 1)
-			{
-				MotorControlFunc(1, 2);
-				return;
-			}
-			else if (getbit(MotorControlEnable, 2) == 1)
-			{
-				MotorControlFunc(2, 2);
-				return;
-			}
-			else if (getbit(MotorControlEnable, 3) == 1)
-			{
-				MotorControlFunc(3, 2);
-				return;
-			}
-			else
-			{
-				return;
-			}
-		}
-		else
-		{
-			if (MotorLifeTestCmd == 1)
-			{
-				if (LockMotorNum < 4 && testTimer > 5000)
-				{
-					MotorControlCmd = 1;
-				}
-				else if (unLockMotorNum < 5 && LockMotorNum == 4 && testTimer > 5000)
-				{
-					MotorControlCmd = 2;
-				}
-			}
-			else
-			{
-				MotorControlFunc(0, 0xF1);
-				LockMotorNum = -1;
-				unLockMotorNum = -1;
-				return;
-			}
-		}
-	}
-	else if (MotorControlCmd == 1) //控制锁紧的自动流程
-	{
-		switch (LockMotorNum)
-		{
-		case -1:
-		{
-			MotorControlFunc(0, 0xF1);
-			LockMotorNum = 0;
-			break;
-		}
-		case 0:
-		{
-			if ((MotorRunTimer >= RunFailedDelay) || (MotorLockReadyTimer >= LockDelay) || getbit(MotorControlEnable, LockMotorNum) != 1)
-			{
-				MotorControlFunc(LockMotorNum, 0xF1);
-				LockMotorNum = 1;
-				MotorRunTimer = 0;
-				MotorLockReadyTimer = 0;
-			}
-			else
-			{
-				if (getbit(ebcd_st_lockSensor, LockMotorNum) == 1)
-				{
-					MotorLockReadyTimer = MotorLockReadyTimer + 10;
-				}
-				MotorControlFunc(LockMotorNum, 1);
-				MotorRunTimer = MotorRunTimer + 10;
-			}
-			break;
-		}
-		case 1:
-		{
-			if ((MotorRunTimer >= RunFailedDelay) || (MotorLockReadyTimer >= LockDelay) || getbit(MotorControlEnable, LockMotorNum) != 1)
-			{
-				MotorControlFunc(LockMotorNum, 0xF1);
-				LockMotorNum = 2;
-				MotorRunTimer = 0;
-				MotorLockReadyTimer = 0;
-			}
-			else
-			{
-				if (getbit(ebcd_st_lockSensor, LockMotorNum) == 1)
-				{
-					MotorLockReadyTimer = MotorLockReadyTimer + 10;
-				}
-				MotorControlFunc(LockMotorNum, 1);
-				MotorRunTimer = MotorRunTimer + 10;
-			}
-			break;
-		}
-		case 2:
-		{
-			if ((MotorRunTimer >= RunFailedDelay) || (MotorLockReadyTimer >= LockDelay) || getbit(MotorControlEnable, LockMotorNum) != 1)
-			{
-				MotorControlFunc(LockMotorNum, 0xF1);
-				LockMotorNum = 3;
-				MotorRunTimer = 0;
-				MotorLockReadyTimer = 0;
-			}
-			else
-			{
-				if (getbit(ebcd_st_lockSensor, LockMotorNum) == 1)
-				{
-					MotorLockReadyTimer = MotorLockReadyTimer + 10;
-				}
-				MotorControlFunc(LockMotorNum, 1);
-				MotorRunTimer = MotorRunTimer + 10;
-			}
-			break;
-		}
-		case 3:
-		{
-			if ((MotorRunTimer >= RunFailedDelay) || (MotorLockReadyTimer >= LockDelay) || getbit(MotorControlEnable, LockMotorNum) != 1)
-			{
-				MotorControlFunc(LockMotorNum, 0xF1);
-				LockMotorNum = 4;
-				unLockMotorNum = -1;
-				MotorRunTimer = 0;
-				MotorLockReadyTimer = 0;
-				testTimer = 0;
-			}
-			else
-			{
-				if (getbit(ebcd_st_lockSensor, LockMotorNum) == 1)
-				{
-					MotorLockReadyTimer = MotorLockReadyTimer + 10;
-				}
-				MotorControlFunc(LockMotorNum, 1);
-				MotorRunTimer = MotorRunTimer + 10;
-			}
-			break;
-		}
-		default:
-			break;
-		}
-	}
-	else if (MotorControlCmd == 2) //控制解锁的自动流程
-	{
-		switch (unLockMotorNum)
-		{
-		case -1:
-		{
-			MotorControlFunc(0, 0xF2);
-			unLockMotorNum = 0;
-			break;
-		}
-		case 0:
-		{
-			if ((MotorRunTimer >= RunFailedDelay) || (MotorLockReadyTimer >= 1) || getbit(MotorControlEnable, unLockMotorNum) != 1)
-			{
-				MotorControlFunc(unLockMotorNum, 0xF2);
-				unLockMotorNum = 1;
-				MotorRunTimer = 0;
-				MotorLockReadyTimer = 0;
-			}
-			else
-			{
-				if (getbit(ebcd_st_unlockSensor, unLockMotorNum) == 1)
-				{
-					MotorLockReadyTimer = MotorLockReadyTimer + 10;
-				}
-				MotorControlFunc(unLockMotorNum, 2);
-				MotorRunTimer = MotorRunTimer + 10;
-			}
-			break;
-		}
-		case 1:
-		{
-			if ((MotorRunTimer >= RunFailedDelay) || (MotorLockReadyTimer >= 1) || getbit(MotorControlEnable, unLockMotorNum) != 1)
-			{
-				MotorControlFunc(unLockMotorNum, 0xF2);
-				unLockMotorNum = 2;
-				MotorRunTimer = 0;
-				MotorLockReadyTimer = 0;
-			}
-			else
-			{
-				if (getbit(ebcd_st_unlockSensor, unLockMotorNum) == 1)
-				{
-					MotorLockReadyTimer = MotorLockReadyTimer + 10;
-				}
-				MotorControlFunc(unLockMotorNum, 2);
-				MotorRunTimer = MotorRunTimer + 10;
-			}
-			break;
-		}
-		case 2:
-		{
-			if ((MotorRunTimer >= RunFailedDelay) || (MotorLockReadyTimer >= 1) || getbit(MotorControlEnable, unLockMotorNum) != 1)
-			{
-				MotorControlFunc(unLockMotorNum, 0xF2);
-				unLockMotorNum = 3;
-				MotorRunTimer = 0;
-				MotorLockReadyTimer = 0;
-			}
-			else
-			{
-				if (getbit(ebcd_st_unlockSensor, unLockMotorNum) == 1)
-				{
-					MotorLockReadyTimer = MotorLockReadyTimer + 10;
-				}
-				MotorControlFunc(unLockMotorNum, 2);
-				MotorRunTimer = MotorRunTimer + 10;
-			}
-			break;
-		}
-		case 3:
-		{
-			if ((MotorRunTimer >= RunFailedDelay) || (MotorLockReadyTimer >= 1) || getbit(MotorControlEnable, unLockMotorNum) != 1)
-			{
-				MotorControlFunc(unLockMotorNum, 0xF2);
-				unLockMotorNum = 4;
-				MotorRunTimer = 0;
-				MotorLockReadyTimer = 0;
-			}
-			else
-			{
-				if (getbit(ebcd_st_unlockSensor, unLockMotorNum) == 1)
-				{
-					MotorLockReadyTimer = MotorLockReadyTimer + 10;
-				}
-				MotorControlFunc(unLockMotorNum, 2);
-				MotorRunTimer = MotorRunTimer + 10;
-			}
-			break;
-		}
-		case 4:
-		{
-			MotorControlFunc(0, 0xF1);
-			unLockMotorNum = 5;
-			LockMotorNum = -1;
-			if (MotorLifeTestCmd == 1)
-			{
-				LifeTestCounter++;
-				testTimer = 0;
-				EEPROMDrv_bSaveInstantUB = 1;
-			}
-			break;
-		}
-		default:
-			break;
-		}
-	}
-}
-void MotorControlFunc(UINT8 MotorIdx, UINT8 RotateDirec) // MotorIdx 0-3 表示四个电机,RotateDirec F1停止正转,F2表示反转停止,1表示正转,2表示反转
-{
-	switch (MotorIdx)
-	{
-	case 0:
-	{
-		switch (RotateDirec)
-		{
-		case 0xF1:
-		{
-			PSwtDrv_Interface(_M1_C, 0);
-			PSwtDrv_Interface(_M2_C, 0);
-			PSwtDrv_Interface(_M3_C, 0);
-			PSwtDrv_Interface(_M4_C, 0);
-			PSwtDrv_Interface(_M_D_C, 0);
-			break;
-		}
-		case 0xF2:
-		{
-			PSwtDrv_Interface(_M1_C, 1);
-			PSwtDrv_Interface(_M2_C, 1);
-			PSwtDrv_Interface(_M3_C, 1);
-			PSwtDrv_Interface(_M4_C, 1);
-			PSwtDrv_Interface(_M_D_C, 1);
-			break;
-		}
-		case 1:
-		{
-			PSwtDrv_Interface(_M1_C, 0);
-			PSwtDrv_Interface(_M_D_C, 0);
-			PSwtDrv_Interface(_M1_C, 1);
-			break;
-		}
-		case 2:
-		{
-			PSwtDrv_Interface(_M1_C, 1);
-			PSwtDrv_Interface(_M_D_C, 1);
-			PSwtDrv_Interface(_M1_C, 0);
-			break;
-		}
-		default:
-			break;
-		}
-		break;
-	}
-	case 1:
-	{
-		switch (RotateDirec)
-		{
-		case 0xF1:
-		{
-			PSwtDrv_Interface(_M1_C, 0);
-			PSwtDrv_Interface(_M2_C, 0);
-			PSwtDrv_Interface(_M3_C, 0);
-			PSwtDrv_Interface(_M4_C, 0);
-			PSwtDrv_Interface(_M_D_C, 0);
-			break;
-		}
-		case 0xF2:
-		{
-			PSwtDrv_Interface(_M1_C, 1);
-			PSwtDrv_Interface(_M2_C, 1);
-			PSwtDrv_Interface(_M3_C, 1);
-			PSwtDrv_Interface(_M4_C, 1);
-			PSwtDrv_Interface(_M_D_C, 1);
-			break;
-		}
-		case 0:
-		{
-			PSwtDrv_Interface(_M2_C, 0);
-			PSwtDrv_Interface(_M_D_C, 0);
-			break;
-		}
-		case 1:
-		{
-			PSwtDrv_Interface(_M2_C, 0);
-			PSwtDrv_Interface(_M_D_C, 0);
-			PSwtDrv_Interface(_M2_C, 1);
-			break;
-		}
-		case 2:
-		{
-			PSwtDrv_Interface(_M2_C, 1);
-			PSwtDrv_Interface(_M_D_C, 1);
-			PSwtDrv_Interface(_M2_C, 0);
-			break;
-		}
-		default:
-			break;
-		}
-		break;
-	}
-	case 2:
-	{
-		switch (RotateDirec)
-		{
-		case 0xF1:
-		{
-			PSwtDrv_Interface(_M1_C, 0);
-			PSwtDrv_Interface(_M2_C, 0);
-			PSwtDrv_Interface(_M3_C, 0);
-			PSwtDrv_Interface(_M4_C, 0);
-			PSwtDrv_Interface(_M_D_C, 0);
-			break;
-		}
-		case 0xF2:
-		{
-			PSwtDrv_Interface(_M1_C, 1);
-			PSwtDrv_Interface(_M2_C, 1);
-			PSwtDrv_Interface(_M3_C, 1);
-			PSwtDrv_Interface(_M4_C, 1);
-			PSwtDrv_Interface(_M_D_C, 1);
-			break;
-		}
-		case 0:
-		{
-			PSwtDrv_Interface(_M3_C, 0);
-			PSwtDrv_Interface(_M_D_C, 0);
-			break;
-		}
-		case 1:
-		{
-			PSwtDrv_Interface(_M3_C, 0);
-			PSwtDrv_Interface(_M_D_C, 0);
-			PSwtDrv_Interface(_M3_C, 1);
-			break;
-		}
-		case 2:
-		{
-			PSwtDrv_Interface(_M3_C, 1);
-			PSwtDrv_Interface(_M_D_C, 1);
-			PSwtDrv_Interface(_M3_C, 0);
-			break;
-		}
-		default:
-			break;
-		}
-		break;
-	}
-	case 3:
-	{
-		switch (RotateDirec)
-		{
-		case 0xF1:
-		{
-			PSwtDrv_Interface(_M1_C, 0);
-			PSwtDrv_Interface(_M2_C, 0);
-			PSwtDrv_Interface(_M3_C, 0);
-			PSwtDrv_Interface(_M4_C, 0);
-			PSwtDrv_Interface(_M_D_C, 0);
-			break;
-		}
-		case 0xF2:
-		{
-			PSwtDrv_Interface(_M1_C, 1);
-			PSwtDrv_Interface(_M2_C, 1);
-			PSwtDrv_Interface(_M3_C, 1);
-			PSwtDrv_Interface(_M4_C, 1);
-			PSwtDrv_Interface(_M_D_C, 1);
-			break;
-		}
-		case 0:
-		{
-			PSwtDrv_Interface(_M4_C, 0);
-			PSwtDrv_Interface(_M_D_C, 0);
-			break;
-		}
-		case 1:
-		{
-			PSwtDrv_Interface(_M4_C, 0);
-			PSwtDrv_Interface(_M_D_C, 0);
-			PSwtDrv_Interface(_M4_C, 1);
-			break;
-		}
-		case 2:
-		{
-			PSwtDrv_Interface(_M4_C, 1);
-			PSwtDrv_Interface(_M_D_C, 1);
-			PSwtDrv_Interface(_M4_C, 0);
-			break;
-		}
-		default:
-			break;
-		}
-		break;
-	}
-	default:
-		break;
-	}
-}
-#endif

+ 9 - 5
System/Vehicle/Communication/BleCanProtocolFunc.c

@@ -605,6 +605,8 @@ void Can2ProtocolDecode(uint32 Can2ID,uint8 Data[])
     {
         Can2DataDecode(Data);
         bled_flg_bleConn = 1;
+        bled_flg_bleDisconn = 0;
+        bled_st_dataTrans = 1;
         break;
     }
     case 0x1CEF0001:
@@ -614,13 +616,15 @@ void Can2ProtocolDecode(uint32 Can2ID,uint8 Data[])
     }
     case 0x1CEF0002:
     {
-        if (Data[0] != 0xFF)
+        if (Data[0] == 0x01 && Data[1]==0x01)
         {
             bled_flg_bleConn = 1;
+            bled_flg_bleDisconn = 0;
         }
-        else
+        else if(Data[0] == 0x01 && Data[1]==0x02)
         {
             bled_flg_bleConn = 0;
+            bled_flg_bleDisconn = 1;
         }
         break;
     }
@@ -757,7 +761,7 @@ void Can2DataDecode(uint8 Data[])
         break;
     }
 }
-uint8 udsMode = 0;//uds ģʽ
+static uint8 udsMode = 0;//uds ģʽ
 uint32 EbcAppSw = 0x00000101;
 void Uds_Service(uint8 *Data)
 {
@@ -873,8 +877,8 @@ void Uds_Service(uint8 *Data)
 			case 0x08://Ëø½ô´ÎÊý²éѯ
 			{
 				UdsAns.Seq = 0;
-				UdsAns.Data1 = Test_LockPressure>>8;
-				UdsAns.Data2 = Test_LockPressure;
+				UdsAns.Data1 = ManuControlTimes>>8;
+				UdsAns.Data2 = ManuControlTimes;
 				UdsAns.Data3 = 0x00;
 				UdsAns.Data4 = 0x00;
 				UdsPosAns(UdsAns);

+ 1 - 0
System/Vehicle/Communication/BleCanProtocolFunc.h

@@ -28,6 +28,7 @@ typedef struct
 	uint8 Data4;
 } UdsAnsType;
 void UdsPosAns(UdsAnsType UdsAnsData);
+void UdsNegAns(UdsAnsType UdsAnsData);
 void Can2ProtocolCode(uint8 CmdIdx,uint8 DataIdx,uint8 Byte0Num,uint32 *InnerCanID,uint8 *Data);
 void Can2ProtocolDecode(uint32 Can2ID,uint8 Data[]);
 void Can2DataCode(uint8 DataIdx, uint8 Byte0Num,uint8 Data[]);

+ 12 - 49
System/Vehicle/Communication/CanVar.c

@@ -695,20 +695,21 @@ uint32 bled_Nr_softVer = 0;			   // BLE
 uint8 bled_flg_role = 0;			   // ble的主从模式 01-主,02-从
 uint8 bled_flg_bleConn = 0;			   // ble蓝牙连接状态
 uint8 bled_flg_bleDisconn = 0;		   // ble蓝牙断开状态
+uint8 bled_st_dataTrans = 0;//蓝牙数据传输状态
 /*
 ebc应用层变量
 */
-uint8 ebcd_flg_Can2SendEnbale = 0;
-uint8 ebcd_st_toBleAns = 0;
-uint8 ebcd_P_airSensor = 0;
+uint8 ebcd_flg_Can2SendEnbale = 0;	//应答BLE的使能
+uint8 ebcd_st_toBleAns = 0;			//应答BLE的指令序号
+uint8 ebcd_P_airSensor = 0;			//压力传感器气压值:单位Mpa,精度0.01Mpa
 uint8 ebcd_T_plugin[4] = {0};		 //四个接插件温度
-uint8 ebcd_flg_forbidHVOn = 0;		 //禁止高压上电
-uint8 ebcb_flg_reqHvOff = 0;		 //请求高压下电
+uint8 ebcd_flg_forbidHVOn = 0;		 //禁止高压上电 BMS
+uint8 ebcb_flg_reqHvOff = 0;		 //请求高压下电 BMS
 uint8 ebcd_flg_LockErr = 0;			 //锁紧机构故障状态,0-异常,1-正常
 uint8 ebcd_flg_dChrgLockErr = 0;	 //放电互锁故障状态
 uint8 ebcd_flg_chrgLockErr = 0;		 //充电互锁故障状态
 uint8 ebcd_flg_dChgCnctOverTemp = 0; //放电连接器过温标志
-uint8 ebcd_st_ebcWork = 0;			 // Ebc当前状态 0-行车,1-通讯,2-换电
+uint8 ebcd_st_ebcWork = 0;			 // Ebc当前状态 0-行车,1-通讯(握手才进入通讯状态),2-换电
 uint8 ebcd_Nr_errMax;				 //故障等级:当前故障最大等级
 uint8 ebcd_Num_faultCode;			 // ebc故障码,未定义
 uint8 ebcd_st_chargingMod;			 //充电模式,1-车载充电,2-换电站充电
@@ -733,12 +734,13 @@ uint8 ebcd_st_unlockSucJug;			 //
 uint8 m_flg_HVlock1 = 0;//互锁状态1
 uint8 m_flg_HVlock2 = 0;//互锁状态2
 uint16 Test_LockPressure = 0;//锁紧力测试
+uint8 ebcd_flg_ebcManCtrlEn = 0;		 // EBC手动控制使能
+uint8 ebcd_flg_ebcManCtrlMode = 0;		 // EBC手动控制模式
+
 
 #define EEPDATA_START_SEC_VAR
 #include "MemMap.h"
-uint32 Control_Times = 0;
-uint8 ebcd_flg_ebcManCtrlEn = 0;		 // EBC手动控制使能
-uint8 ebcd_flg_ebcManCtrlMode = 0;		 // EBC手动控制模式
+uint16 ManuControlTimes = 0;
 uint16 LockDelayTime = 0;//锁定延时时间(传感器到位以后延时多少时间确定为锁定成功
 uint16 UnlockDelayTime = 0;//解锁延时时间(传感器到位以后延时多少时间确定为解锁成功
 #define EEPDATA_STOP_SEC_VAR
@@ -775,43 +777,4 @@ const uint8 DataPackCounter[21] = {1, 1, 7, 5, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 const uint8 DataPackBegin[21] = {0, 0x11, 0x21, 0x31, 0x40, 0x51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 #define APPLAYERVER_STOP_SEC_VAR
 #include "MemMap.h"
-/*************************************************************
- *测试变量存放区
- ************************************************************/
-#ifdef _APP_TEST_CODE
-uint32 PressureValue = 0;
-uint16 Distence1 = 0;
-uint16 Distence2 = 0;
-uint8 Switch1 = 0;
-uint8 Switch2 = 0;
-uint8 ControlState = 0;
-uint32 PressureValueBuffer = 0;
-uint32 VehCo_fInputUIA[2];
-uint16 VehCo_rInputUWA[2];
-uint16 VehCo_uADChanUWA[_ATD_NUM_CHAN];
-uint8 VehCo_bDINChanUBA[_DIN_NUM_CHAN];
-float32 VehCo_uBattF;
-uint16 VehCo_uAccPedUW;
-#define EEPDATA_START_SEC_VAR
-#include "MemMap.h"
-uint32 VehCo_ctEEPTestUB = 0;
-uint32 VehCo_ctEEPTestUI = 0; //在定义时给EEPROM里的变量赋初值
-uint32 Control_Times = 0;
-#define EEPDATA_STOP_SEC_VAR
-#include "MemMap.h"
-#endif
-#ifdef _APP_TEST_MOTOR_CODE
-uint8 MotorControlCmd = 0;	   //电机自动控制模式,0-不控制,1-控制锁紧,2-控制解锁
-uint8 MotorDebugCmd = 0;	   //电机调试模式。0-不控制,1-持续锁紧,2-持续解锁
-uint8 MotorControlEnable = 0;  //电机控制使能,每bit代表一个电机从低位开始, 0-不控制,1-控制
-uint8 MotorControlLockNum = 0; //调试参数
-uint8 MotorControlunLockNum = 0;
-uint8 MotorLifeTestCmd = 0;
-#define EEPDATA_START_SEC_VAR
-#include "MemMap.h"
-uint16 RunFailedDelay = 30000; //电机最大运动时间,超时则取消控制
-uint16 LockDelay = 1000;	   //电机传感器到位后,延时锁紧时间
-uint16 LifeTestCounter = 0;
-#define EEPDATA_STOP_SEC_VAR
-#include "MemMap.h"
-#endif
+

+ 2 - 40
System/Vehicle/Communication/CanVar.h

@@ -540,6 +540,7 @@ extern uint32 bled_Nr_softVer;            // BLE
 extern uint8 bled_flg_role;               // ble的主从模式 01-主,02-从
 extern uint8 bled_flg_bleConn;            // ble蓝牙连接状态
 extern uint8 bled_flg_bleDisconn;         // ble蓝牙断开状态
+extern uint8 bled_st_dataTrans;			  //蓝牙数据传输状态
 //正式变量
 extern uint8 ebcd_flg_Can2SendEnbale;
 extern uint8 ebcd_st_toBleAns;
@@ -567,50 +568,11 @@ extern uint8 ebcd_flg_ebcManCtrlEn;		 // EBC
 extern uint8 ebcd_flg_ebcManCtrlMode;		 // EBC手动控制模式
 extern uint16 LockDelayTime;//锁定延时时间(传感器到位以后延时多少时间确定为锁定成功
 extern uint16 UnlockDelayTime;//解锁延时时间(传感器到位以后延时多少时间确定为解锁成功
-extern uint32 Control_Times;
+extern uint16 ManuControlTimes;
 #define EEPDATA_STOP_SEC_VAR
 #include "MemMap.h"
 extern const uint8 T_table[240];
 extern const uint32 R_table[240];
 extern const uint8 DataPackCounter[21];
 extern const uint8 DataPackBegin[21];
-#ifdef _APP_TEST_CODE
-extern uint16 CANNet_rAccPedUW;
-extern uint32 PressureValue;
-extern uint16 Distence1;
-extern uint16 Distence2;
-extern uint8 Switch1;
-extern uint8 Switch2;
-extern uint8 ControlState;
-extern uint32 Control_Times;
-extern uint32 PressureValueBuffer;
-extern uint32 VehCo_fInputUIA[2];
-extern uint16 VehCo_rInputUWA[2];
-extern uint16 VehCo_uADChanUWA[_ATD_NUM_CHAN];
-extern uint8 VehCo_bDINChanUBA[_DIN_NUM_CHAN];
-extern float32 VehCo_uBattF;
-extern uint16 VehCo_uAccPedUW;
-#define EEPDATA_START_SEC_VAR
-#include "MemMap.h"
-extern uint32 VehCo_ctEEPTestUB;
-extern uint32 VehCo_ctEEPTestUI; //在定义时给EEPROM里的变量赋初值
-extern uint32 Control_Times;
-#define EEPDATA_STOP_SEC_VAR
-#include "MemMap.h"
-#endif
-#ifdef _APP_TEST_MOTOR_CODE
-extern uint8 MotorControlCmd;     //电机自动控制模式,0-不控制,1-控制锁紧,2-控制解锁
-extern uint8 MotorDebugCmd;       //电机调试模式。0-不控制,1-持续锁紧,2-持续解锁
-extern uint8 MotorControlEnable;  //电机控制使能,每bit代表一个电机从低位开始, 0-不控制,1-控制
-extern uint8 MotorControlLockNum; //调试参数
-extern uint8 MotorControlunLockNum;
-extern uint8 MotorLifeTestCmd;
-#define EEPDATA_START_SEC_VAR
-#include "MemMap.h"
-extern uint16 RunFailedDelay; //电机最大运动时间,超时则取消控制
-extern uint16 LockDelay;      //电机传感器到位后,延时锁紧时间
-extern uint16 LifeTestCounter;
-#define EEPDATA_STOP_SEC_VAR
-#include "MemMap.h"
-#endif
 #endif /* SYSTEM_VEHICLE_COMMUNICATION_CANVAR_H_ */

+ 2 - 2
System/Vehicle/Communication/VcuCanProtocolFunc.c

@@ -728,8 +728,8 @@ void VcuEncodeFunction(UINT32 ID, UINT8 *rawData)
 		Life = Life + 1;
 		EBC_LockupSts = ebdc_st_lockUpState;
 		EBC_ConnectorSts = ebdc_st_ConnecState;
-		EBC_DischgConnectorSts = 2; // 淇濈暀淇″彿锛屽畾涔変负鏃犳晥
-		EBC_ChgConnectorSts = 2;	// 淇濈暀淇″彿锛屽畾涔変负鏃犳晥
+		EBC_DischgConnectorSts = 0; // 淇濈暀淇″彿锛屽畾涔変负鏃犳晥
+		EBC_ChgConnectorSts = 0;	// 淇濈暀淇″彿锛屽畾涔変负鏃犳晥
 		EBC_FaultLevel = ebcd_Nr_errMax;
 		EBC_FaultCode = ebcd_Num_faultCode;
 		*(UINT8 *)(rawData + 0) = *(UINT8 *)(rawData + 0) | ((Life << 0) & 0xFF);

+ 0 - 12
System/Vehicle/VehCo.c

@@ -105,12 +105,9 @@ void VehCo_Manage10ms(void)
 //整车管理1ms基准运行任务
 void VehCo_Manage1ms(void)
 {
-#ifdef _APP_RELEASE_CODE
     CAN0Net_Manage1ms();
     CAN1Net_Manage1ms();
     CAN2Net_Manage1ms();
-#endif
-    //CAN2Net_Manage1ms();
 }
 
 //停机准备状态操作,10ms运行一次
@@ -156,20 +153,11 @@ void VehCo_Ctrl(void)
             BattCD_stWakeupU.B.bCAN = 0;
         }
     }
-#ifdef _APP_TEST_CODE
-    TestDeviceFun();
-    VehCo_uBattF = (float32)BattCD_uFltUW / 100.0F;
-#endif
-#ifdef _APP_TEST_MOTOR_CODE
-    MotorTestFun();
-#endif
-#ifdef _APP_RELEASE_CODE
     /*正式程序开始*/
     GetHVLockState();
     GetDIOState();
     GetAIOValue();
     LockAndUnlockCtrl();
-#endif
 }
 #endif //_SAMPLE_CODE_
 /*********************************************************************************************/

+ 1 - 3
System/Vehicle/VehCo.h

@@ -52,9 +52,7 @@ extern const uint8 AppLayer_idxVerUBA[64]; //Ó¦
 /*********************************************************************************************/
 /*ÑùÀý´úÂë*/
 #ifdef _SAMPLE_CODE_
-/*app¶¨Òå*********************************************************************************************/
-extern uint32 Control_Times;
-/*********************************************************************************************/
+
 void VehCo_Ctrl(void);
 #define EEPDATA_START_SEC_VAR
 #include "MemMap.h"