Selaa lähdekoodia

V2r1r0_20220620
1 增加GPIO口PB13和PB14,PB13控制航顺单片上电,PB14与最新板兼容;
2 解决自动关机时不等待电机Ready指令而直接关机;
3 通讯检测时间延长为5s,通讯故障可恢复;
4 版本号更新为V2r1r0_20220620;

white.xu 3 vuotta sitten
vanhempi
sitoutus
1093466b84
7 muutettua tiedostoa jossa 26 lisäystä ja 9 poistoa
  1. 8 2
      Inc/gpio.h
  2. 2 0
      Inc/main.h
  3. 1 1
      MDK-ARM/ZB002B20190430.uvprojx
  4. 2 2
      Src/gpio.c
  5. 5 0
      Src/usart.c
  6. 7 3
      Src_app/tasks.c
  7. 1 1
      Src_app/var.c

+ 8 - 2
Inc/gpio.h

@@ -53,8 +53,14 @@
 /* USER CODE END Includes */
 
 /* USER CODE BEGIN Private defines */
-#define SYS_POWER_ON() {HAL_GPIO_WritePin(VIN_EN1_GPIO_Port, VIN_EN1_Pin, GPIO_PIN_SET);HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_RESET);}
-#define SYS_POWER_OFF()	{HAL_GPIO_WritePin(VIN_EN1_GPIO_Port, VIN_EN1_Pin, GPIO_PIN_RESET);HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_SET);}
+#define SYS_POWER_ON() {HAL_GPIO_WritePin(VIN_EN1_GPIO_Port, VIN_EN1_Pin, GPIO_PIN_SET);\
+												HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_RESET);\
+												HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13, GPIO_PIN_SET);\
+												HAL_GPIO_WritePin(POWER_EN_GPIO_Port, POWER_EN_Pin, GPIO_PIN_SET);}
+#define SYS_POWER_OFF()	{HAL_GPIO_WritePin(VIN_EN1_GPIO_Port, VIN_EN1_Pin, GPIO_PIN_RESET);\
+												 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_SET);\
+												 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13, GPIO_PIN_RESET);\
+												 HAL_GPIO_WritePin(POWER_EN_GPIO_Port, POWER_EN_Pin, GPIO_PIN_RESET);}
 
 #define LED_INIT() {HAL_GPIO_WritePin(OFF_GPIO_Port, OFF_Pin, GPIO_PIN_SET);\
 HAL_GPIO_WritePin(ECO_GPIO_Port, ECO_Pin, GPIO_PIN_SET);HAL_GPIO_WritePin(NORM_GPIO_Port, NORM_Pin, GPIO_PIN_SET);\

+ 2 - 0
Inc/main.h

@@ -61,6 +61,8 @@
 
 #define VIN_EN1_Pin               GPIO_PIN_1
 #define VIN_EN1_GPIO_Port         GPIOA
+#define POWER_EN_Pin              GPIO_PIN_14
+#define POWER_EN_GPIO_Port        GPIOB
 #define BUS_VOLTAGE_Pin           GPIO_PIN_2
 #define BUS_VOLTAGE_GPIO_Port     GPIOA
 #define KEY_ON_OFF_Pin            GPIO_PIN_3

+ 1 - 1
MDK-ARM/ZB002B20190430.uvprojx

@@ -15,7 +15,7 @@
         <TargetCommonOption>
           <Device>STM32F103C8</Device>
           <Vendor>STMicroelectronics</Vendor>
-          <PackID>Keil.STM32F1xx_DFP.1.1.0</PackID>
+          <PackID>Keil.STM32F1xx_DFP.2.3.0</PackID>
           <PackURL>http://www.keil.com/pack/</PackURL>
           <Cpu>IRAM(0x20000000-0x20004FFF) IROM(0x8000000-0x800FFFF)  CLOCK(8000000) CPUTYPE("Cortex-M3")</Cpu>
           <FlashUtilSpec></FlashUtilSpec>

+ 2 - 2
Src/gpio.c

@@ -69,7 +69,7 @@ void MX_GPIO_Init(void)
   /*Configure GPIO pin Output Level */
   HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1|GPIO_PIN_4, GPIO_PIN_RESET);
 	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_SET);
-	
+  HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13|GPIO_PIN_14, GPIO_PIN_RESET);	
   /*Configure GPIO pin Output Level */
   HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6 
                           |GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10
@@ -86,7 +86,7 @@ void MX_GPIO_Init(void)
                           PB10 PB11 PB12 PB15*/
   GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6 
                           |GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10
-													|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_15;
+													|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_15|GPIO_PIN_14|GPIO_PIN_13;
   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
   GPIO_InitStruct.Pull = GPIO_NOPULL;
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

+ 5 - 0
Src/usart.c

@@ -446,6 +446,11 @@ void Data_Process(uint16_t ID, uint8_t Mode, uint16_t Cmd, uint8_t* Data)
       case 0xc502://×îºóÒ»Ö¡Êý¾Ý
       {
         PBU_TE_Status = UPDATE_FINISH;  
+				if(PBU_RunMode != PBU_RunMode_PowerOff)
+				{
+				PBU_PowerOff_Process.DelayTimeCnt = SysTime_5ms;
+				PBU_PowerOff_Process.SendCodeTimeCnt = 0;					
+				}
 				PBU_RunMode   = PBU_RunMode_PowerOff;
 				HAL_Delay(20);
         break;

+ 7 - 3
Src_app/tasks.c

@@ -567,7 +567,7 @@ void PBU_RunMode_Process(PBU_RunMode_t RunMode)
 			if((PowerOn_flag==1)&&(PBU_AssitMode_Status.PBU_AssistMode_Flag!=PBU_AssistMode_Flag_WalkSby))
 			
 			{			
-				if(TimeCntDiff_5ms(MC_Online_TimeCnt) >=400)
+				if(TimeCntDiff_5ms(MC_Online_TimeCnt) >=1000)
 				{
 					MC_Online_Flag = 0;
 					PBU_commErrorCode.ERROR_Bit.Communication_MC_Fault =1;			
@@ -575,12 +575,13 @@ void PBU_RunMode_Process(PBU_RunMode_t RunMode)
         if(MC_Online_Flag == 1)
 			  {
 				  PBU_commErrorCode.ERROR_Bit.Communication_MC_Fault = 0;
+				  PBU_ErrorCode.ERROR_Bit.Communication_MC_Fault = 0;
 			  }
 			}
 			
 			if(PowerOn_flag==1)
 			{			
-				if(TimeCntDiff_5ms(BMS_Online_TimeCnt) >=400)
+				if(TimeCntDiff_5ms(BMS_Online_TimeCnt) >=1000)
 				{
 					BMS_Online_Flag = 0;
 		//		PBU_commErrorCode.ERROR_Bit.Communication_Fault =1;		
@@ -785,7 +786,7 @@ void PBU_Error_Process(void)
 
 	if(PBU_RunMode != PBU_RunMode_Updating)
 	{
-		PBU_ErrorCode.Code=(PBU_ErrorCode.Code|PBU_hardwareErrorCode.Code|PBU_commErrorCode.Code|PBU_TE_ErrorCode.Code);
+		PBU_ErrorCode.Code=(PBU_ErrorCode.Code|PBU_hardwareErrorCode.Code|PBU_commErrorCode.Code);//|PBU_TE_ErrorCode.Code);
 		PBU_Error_senddata=PBU_ErrorCode.Code;
 		if(PBU_Error_senddata != 0)
 		{
@@ -837,7 +838,10 @@ void AutoPowerOff_Process(void)
 	{
 	  if((TimeCntDiff_5ms(DelayTimeCnt) > 60000)) // 超时60000 * 5ms = 300s
 		{
+			DelayTimeCnt = SysTime_5ms;
 		  PBU_RunMode = PBU_RunMode_PowerOff;
+			PBU_PowerOff_Process.DelayTimeCnt = SysTime_5ms;
+			PBU_PowerOff_Process.SendCodeTimeCnt = 0;			
 		}
 	}
 	KeySate = KeySate_Temp;

+ 1 - 1
Src_app/var.c

@@ -78,7 +78,7 @@ void Var_Init(void)
 	
 	//PBU版本信息,Mode和SN从EEPROM读取
 	strcpy(PBU_VerInfo.HW_Version, (char*)"ZB002D_20190905.");//长度为16bytes
-	strcpy(PBU_VerInfo.FW_Version, (char*)"V2r0r6_20211027.");//长度为16bytes
+	strcpy(PBU_VerInfo.FW_Version, (char*)"V2r1r0_20220620.");//长度为16bytes
 
   //PBU校验信息,校验码从EEPROM读取
 	PBU_CheckInfo.MAC_ID[0] = *(__IO uint32_t*)(0x1FFFF7AC);