Quellcode durchsuchen

修改bootloader 升级不能超过16块板子的问题,三相4线增加开关检测,匹配双火线。

liyi vor 1 Jahr
Ursprung
Commit
3266a7f5f9

+ 5 - 4
control/bootloader64k_dc/boot/HARDWARE/Key/Key.c

@@ -56,12 +56,12 @@ static  void  ConfigKeyGPIO(void)
 {
   //使能RCU相关时钟
   rcu_periph_clock_enable(KEY_RCU); //使能GPIOB的时钟
-  
+  rcu_periph_clock_enable(RCU_GPIOA); 
   gpio_mode_set(KEY_IO, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, KEY1);   //配置PF7为上拉输入K1
   gpio_mode_set(KEY_IO, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, KEY2);   //配置PF6为上拉输入K2
   gpio_mode_set(KEY_IO, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, KEY3);   //配置PA12为上拉输入K3
 	gpio_mode_set(KEY_IO, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, KEY4);   //配置PA12为上拉输入K3
-	
+	gpio_mode_set(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, KEY5);   //配置PA12为上拉输入K3
 }
 
 /*********************************************************************************************************
@@ -122,7 +122,8 @@ unsigned char ReadKeyValue(void)
 	s_arrKeyDownLevel[1]=ScanKey(KEY_IO,KEY2);
 	s_arrKeyDownLevel[2]=ScanKey(KEY_IO,KEY3);
 	s_arrKeyDownLevel[3]=ScanKey(KEY_IO,KEY4);
-	SlaveAddress=(~((s_arrKeyDownLevel[0]<<0)|(s_arrKeyDownLevel[1]<<1)|(s_arrKeyDownLevel[2]<<2)|(s_arrKeyDownLevel[3]<<3)))& 0x0f;
-	
+	s_arrKeyDownLevel[4]=ScanKey(GPIOA,KEY5);
+	SlaveAddress=(~((s_arrKeyDownLevel[0]<<0)|(s_arrKeyDownLevel[1]<<1)|(s_arrKeyDownLevel[2]<<2)|(s_arrKeyDownLevel[3]<<3)|(s_arrKeyDownLevel[4]<<4)))& 0x1f;
+
 	return SlaveAddress;
 }

+ 2 - 1
control/bootloader64k_dc/boot/HARDWARE/Key/Key.h

@@ -32,11 +32,12 @@
 #define KEY2 GPIO_PIN_5
 #define KEY3 GPIO_PIN_6
 #define KEY4 GPIO_PIN_7
+#define KEY5 GPIO_PIN_15
 
 #define KEY_ON 0
 #define KEY_OFF 1
 
-#define KEY_NAME_MAX 4
+#define KEY_NAME_MAX 5
 
 //#define KEY_A_RCU   RCU_GPIOA
 //#define KEY_A_IO		GPIOA

+ 34 - 18
truing_control/PDU-Triphasic_IO/USER/main.c

@@ -465,6 +465,7 @@ static void LimiT_enable_check(uint8_t ch_x,uint32_t Lt_v)
 	if(ch_x > 3)
 	{
 		return;
+	}
 #endif
 	//ͨµÀ×î´óµçѹ
 	if((temp0 & AC3PPDU_Vmax_LT_enable) == AC3PPDU_Vmax_LT_enable)
@@ -555,11 +556,14 @@ static void RL_Over_Func()
 
 static void key_io_control()
 {
+#if SUPPORT_DETECTION
 	AC3PPDU_Modbus_Reg[Mb_Dbuff_Detection] = detection_value;
+#endif
 }
 
 void switch_recode()
 {
+#if SUPPORT_DETECTION
 #if SUPPORT_DETECT_REMENBER
 	#if SUPPORT_DOUBLE_FIRE
 	if(detection_value != 0x3)
@@ -600,7 +604,9 @@ void switch_recode()
 				orderFlag[i]=true;
 			}
 		#if SUPPORT_ZERO_LINE
-					handle_status_N = (AC3PPDU_Modbus_Reg[Mb_Dbuff_CHNLT_ST_Addr] & 0x1);
+				handle_status_N = (AC3PPDU_Modbus_Reg[Mb_Dbuff_CHNLT_ST_Addr] & 0x1);
+				AC3PPDU_RL_N_time.LT_state &= 0xffffff7e;
+				orderFlag_N = true;
 		#endif
 			handle_detection[0] = 0;
 		}
@@ -617,15 +623,16 @@ void switch_recode()
 			}
 			#if SUPPORT_ZERO_LINE
 					uint32_t data = (AC3PPDU_RL_N_time.LT_state & (~0x40));
-					AC3PPDU_RL_time[i + CH1_out].LT_state  = (data & 0x40);
-					AC3PPDU_RL_time[i + CH1_out].LT_state |= handle_status[i];
-						orderFlag_N = true;
+					AC3PPDU_RL_N_time.LT_state  = (data & 0x40);
+					AC3PPDU_RL_N_time.LT_state |= handle_status_N;
+					orderFlag_N = true;
 			#endif
 			handle_detection[0] = 1;			
 		}
 	}
 	#endif
 #endif
+#endif
 }
 
 
@@ -776,7 +783,7 @@ int main(void)
 #endif
 
 	// switch_recode();
-
+#if SUPPORT_DETECTION
 #if SUPPORT_DOUBLE_FIRE
 	if(detection_value != 0x3)
 #else
@@ -798,7 +805,7 @@ int main(void)
 		}
 	}
 	
-
+#endif
 
 	for(int i = 0;i < Output_ChN_default;i++)
 	{
@@ -1011,10 +1018,12 @@ static void MODbus_CMD_New(void)
 				break;
 			case Mb_Dbuff_RL_Allon_Addr:																					//relay all on
 			{
-#if SUPPORT_DOUBLE_FIRE
-				if(detection_value == 0x3)
-#else
-				if(detection_value == 1)
+#if SUPPORT_DETECTION
+	#if SUPPORT_DOUBLE_FIRE
+					if(detection_value == 0x3)
+	#else
+					if(detection_value == 1)
+	#endif
 #endif
 				{
 					RL_Allon_flag = true;
@@ -1037,10 +1046,12 @@ static void MODbus_CMD_New(void)
 				break;
 			case Mb_Dbuff_RL_Alloff_Addr:																					//relay all off
 			{
-#if SUPPORT_DOUBLE_FIRE
-				if(detection_value == 0x3)
-#else
-				if(detection_value == 1)
+#if SUPPORT_DETECTION
+	#if SUPPORT_DOUBLE_FIRE
+					if(detection_value == 0x3)
+	#else
+					if(detection_value == 1)
+	#endif
 #endif
 				{	
 					RL_Alloff_flag = true;
@@ -1081,16 +1092,18 @@ static void MODbus_CMD_New(void)
 					AC3PPDU_RL_N_time.LT_state = data;
 					orderFlag_N = true;
 					temp_addr = temp_addr << 1;
-					temp_addr +=ERom_CHNLT_ST_Addr;
+					temp_addr +=ERom_CH1LT_ST_Addr;
 					Eeprom_Rbuf[temp_addr] = data;
 					AT24CxxWriteOneByte(temp_addr,Eeprom_Rbuf[temp_addr]);
 #endif
 				}else{
+#if SUPPORT_DETECTION
 	#if SUPPORT_DOUBLE_FIRE
 					if(detection_value == 0x3)
-	#else
+	#else 
 					if(detection_value == 1)
-	#endif					
+	#endif	
+#endif					
 					{
 						if(AC3PPDU_Modbus_Reg[Mb_Dbuff_VLit1_max_Addr + temp_addr] <= THRESHOULD_JUDGMENT)
 						{
@@ -1127,7 +1140,9 @@ static void MODbus_CMD_New(void)
 			case Mb_Dbuff_OUTCH1_ST_Addr ... Mb_Dbuff_OUTCH4_ST_Addr:							//set output channel relay's status
 			{
 #if SUPPORT_DOUBLE_FIRE
+		#if SUPPORT_DETECTION
 					if(detection_value == 0x3)
+		#endif
 					{
 						temp_addr = base_addr - Mb_Dbuff_OUTCH1_ST_Addr;
 						for(int i = temp_addr; i < Output_ChN_default; i += 4)
@@ -1164,8 +1179,9 @@ static void MODbus_CMD_New(void)
 						}
 					}
 #else
+	#if SUPPORT_DETECTION
 				if(detection_value == 1)
-	
+	#endif
 				{
 					temp_addr = base_addr - Mb_Dbuff_OUTCH1_ST_Addr;
 					//OutUnit_control_flag[temp_addr] = 1;

BIN
truing_control/PDU-Triphasic_IO/tools/bootloader.bin


BIN
truing_control/PDU_AC_OLD/tools/bootloader.bin