소스 검색

add doc&software

terry 2 년 전
부모
커밋
0d4d6ec966

+ 0 - 3
Core/Inc/dataHandling.h

@@ -46,7 +46,4 @@ void Set_normal_Flag(void);
 
 
 
-
-
-
 #endif

+ 6 - 3
Core/Inc/iap.h

@@ -46,7 +46,8 @@ extern uint32_t update_flag;
 extern uint16_t packTotalNum;
 extern uint16_t packIndex ;
 
-
+extern uint16_t addrIndex ;
+extern uint32_t AddrToWrite;
 extern uint32_t nowcurAddr;
 extern uint32_t nowcurAddr1;
 extern uint16_t nowcurpack;
@@ -54,12 +55,14 @@ extern uint16_t curaddr[2];
 extern uint16_t curapack[1];
 
 
+
+
+void jump_to_app(uint32_t app_addr);
+
 extern int lenindex;
 extern uint16_t iapbinMd5[8] ;
 void Process_CMD_IAP_Update(void);
 void Start_BootLoader(void);
 extern uint16_t FileBuffArray[512];
-void iap_load_app(uint32_t appxaddr);
-extern uint16_t FileBuffArray1[512];
 #endif
 

+ 42 - 0
Core/Inc/main.h

@@ -86,6 +86,48 @@ uint32_t read_flash_32(uint32_t addr);
 /* USER CODE END EFP */
 
 /* Private defines -----------------------------------------------------------*/
+#define adc0_Pin GPIO_PIN_0
+#define adc0_GPIO_Port GPIOC
+#define adc1_Pin GPIO_PIN_1
+#define adc1_GPIO_Port GPIOC
+#define adc2_Pin GPIO_PIN_2
+#define adc2_GPIO_Port GPIOC
+#define input0_Pin GPIO_PIN_0
+#define input0_GPIO_Port GPIOA
+#define input1_Pin GPIO_PIN_1
+#define input1_GPIO_Port GPIOA
+#define input2_Pin GPIO_PIN_2
+#define input2_GPIO_Port GPIOA
+#define input3_Pin GPIO_PIN_3
+#define input3_GPIO_Port GPIOA
+#define input4_Pin GPIO_PIN_4
+#define input4_GPIO_Port GPIOA
+#define input5_Pin GPIO_PIN_5
+#define input5_GPIO_Port GPIOA
+#define input6_Pin GPIO_PIN_6
+#define input6_GPIO_Port GPIOA
+#define input7_Pin GPIO_PIN_7
+#define input7_GPIO_Port GPIOA
+#define kmg_Pin GPIO_PIN_0
+#define kmg_GPIO_Port GPIOB
+#define usart3_tx_Pin GPIO_PIN_10
+#define usart3_tx_GPIO_Port GPIOB
+#define usart3_rx_Pin GPIO_PIN_11
+#define usart3_rx_GPIO_Port GPIOB
+#define led_Pin GPIO_PIN_12
+#define led_GPIO_Port GPIOB
+#define usart1_tx_Pin GPIO_PIN_9
+#define usart1_tx_GPIO_Port GPIOA
+#define usart1_rx_Pin GPIO_PIN_10
+#define usart1_rx_GPIO_Port GPIOA
+#define output0_Pin GPIO_PIN_3
+#define output0_GPIO_Port GPIOB
+#define output1_Pin GPIO_PIN_4
+#define output1_GPIO_Port GPIOB
+#define output2_Pin GPIO_PIN_5
+#define output2_GPIO_Port GPIOB
+#define output3_Pin GPIO_PIN_6
+#define output3_GPIO_Port GPIOB
 
 /* USER CODE BEGIN Private defines */
 #define FILTER_LENGTH 10

+ 1 - 1
Core/Inc/usart.h

@@ -68,7 +68,7 @@ void MX_USART3_UART_Init(void);
 void update_baudrate(uint16_t temp);
 void update_sysVersion(uint32_t addr);
 void update_iaplength(uint32_t addr);
-void updateiapMd5(uint32_t addr);
+void updateiapMd5(void);
 void updatecuraddr(uint32_t addr);
 int compareArrays(uint16_t arr1[], uint16_t arr2[], int size) ;
 void updatecurpack(uint32_t addr);

+ 2 - 2
Core/Src/adc.c

@@ -106,7 +106,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle)
     PC1     ------> ADC1_IN11
     PC2     ------> ADC1_IN12
     */
-    GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2;
+    GPIO_InitStruct.Pin = adc0_Pin|adc1_Pin|adc2_Pin;
     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
     HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 
@@ -135,7 +135,7 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle)
     PC1     ------> ADC1_IN11
     PC2     ------> ADC1_IN12
     */
-    HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2);
+    HAL_GPIO_DeInit(GPIOC, adc0_Pin|adc1_Pin|adc2_Pin);
 
     /* ADC1 interrupt Deinit */
     HAL_NVIC_DisableIRQ(ADC1_2_IRQn);

+ 2 - 2
Core/Src/dataHandling.c

@@ -118,10 +118,10 @@ void Flash_WriteBytes(uint16_t* sorBuf, uint32_t FlashAddr, uint16_t len)
     f.NbPages = 1;
 	
     // 读取Flash缓冲区数据
-    Flash_ReadBytes(Flashbuf, Page_StartAddr, 0x400);//写一半先1024字节
+    Flash_ReadBytes(Flashbuf, Page_StartAddr, 0x400);
     // 将源缓冲区数据写入Flash缓冲区
     for (i = 0; i < len; i++)
-        Flashbuf[Offset_ADDR / 2 + i] = sorBuf[i];	 //后一半也存入缓存中
+        Flashbuf[Offset_ADDR / 2 + i] = sorBuf[i];	
     // 解锁FLASH
     HAL_FLASH_Unlock();
     // 擦除FLASH

+ 4 - 2
Core/Src/freertos.c

@@ -149,6 +149,8 @@ void StartiapTask(void const * argument)
 	if(USART_IAP_FLAG == 1 && USART_PUB_LENGTH == 142 && USART_MODBUS_RX[0] == (uint8_t)initial_address && USART_MODBUS_RX[1] == 0x10 && \
 		(calculate_crc(USART_IAP_RX,140) == (USART_MODBUS_RX[141] << 8 | USART_MODBUS_RX[140]))){
 			
+
+
 			Process_CMD_IAP_Update();
 			
 
@@ -175,9 +177,9 @@ void StartTask02(void const * argument)
   for(;;)
   {
     osDelay(1);
-	HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET);
+	HAL_GPIO_WritePin(kmg_GPIO_Port, kmg_Pin, GPIO_PIN_SET);
 	HAL_Delay(1);  
-	HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
+	HAL_GPIO_WritePin(kmg_GPIO_Port, kmg_Pin, GPIO_PIN_RESET);
 	
 	gpioaStatus = GetPaInputStatus();
 	gpiobStatus = GetPbOutputStatus();

+ 26 - 26
Core/Src/gpio.c

@@ -55,8 +55,8 @@ void MX_GPIO_Init(void)
   __HAL_RCC_GPIOB_CLK_ENABLE();
 
   /*Configure GPIO pin Output Level */
-  HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0|GPIO_PIN_12|GPIO_PIN_3|GPIO_PIN_4
-                          |GPIO_PIN_5|GPIO_PIN_6, GPIO_PIN_RESET);
+  HAL_GPIO_WritePin(GPIOB, kmg_Pin|led_Pin|output0_Pin|output1_Pin
+                          |output2_Pin|output3_Pin, GPIO_PIN_RESET);
 
   /*Configure GPIO pins : PC13 PC14 PC15 PC3
                            PC4 PC5 PC6 PC7
@@ -69,18 +69,18 @@ void MX_GPIO_Init(void)
   GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
   HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 
-  /*Configure GPIO pins : PA0 PA1 PA2 PA3
-                           PA4 PA5 PA6 PA7 */
-  GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
-                          |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
+  /*Configure GPIO pins : PAPin PAPin PAPin PAPin
+                           PAPin PAPin PAPin PAPin */
+  GPIO_InitStruct.Pin = input0_Pin|input1_Pin|input2_Pin|input3_Pin
+                          |input4_Pin|input5_Pin|input6_Pin|input7_Pin;
   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
   GPIO_InitStruct.Pull = GPIO_NOPULL;
   HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 
-  /*Configure GPIO pins : PB0 PB12 PB3 PB4
-                           PB5 PB6 */
-  GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_12|GPIO_PIN_3|GPIO_PIN_4
-                          |GPIO_PIN_5|GPIO_PIN_6;
+  /*Configure GPIO pins : PBPin PBPin PBPin PBPin
+                           PBPin PBPin */
+  GPIO_InitStruct.Pin = kmg_Pin|led_Pin|output0_Pin|output1_Pin
+                          |output2_Pin|output3_Pin;
   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
   GPIO_InitStruct.Pull = GPIO_NOPULL;
   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
@@ -113,14 +113,14 @@ typedef struct {
 } GPIO_Pin_t;
 // 定义8个需要处理的引脚
 const GPIO_Pin_t GPIO_PINS[8] = {
-    {GPIOA, GPIO_PIN_0},
-    {GPIOA, GPIO_PIN_1},
-    {GPIOA, GPIO_PIN_2},
-    {GPIOA, GPIO_PIN_3},
-    {GPIOA, GPIO_PIN_4},
-    {GPIOA, GPIO_PIN_5},
-    {GPIOA, GPIO_PIN_6},
-    {GPIOA, GPIO_PIN_7}
+    {input0_GPIO_Port, input0_Pin},
+    {input1_GPIO_Port, input1_Pin},
+    {input2_GPIO_Port, input2_Pin},
+    {input3_GPIO_Port, input3_Pin},
+    {input4_GPIO_Port, input4_Pin},
+    {input5_GPIO_Port, input5_Pin},
+    {input6_GPIO_Port, input6_Pin},
+    {input7_GPIO_Port, input7_Pin}
 };
 // 读取引脚状态的函数
 uint8_t ReadPinStatus(GPIO_TypeDef* port, uint16_t pin) {
@@ -156,15 +156,15 @@ uint8_t GetPbOutputStatus(void)
 void updatePbStatus(uint16_t temp)
 {
     if(temp == UINT16_MAX) {
-        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET);
-        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, GPIO_PIN_RESET);
-        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_RESET);
-        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET);
+        HAL_GPIO_WritePin(output0_GPIO_Port, output0_Pin, GPIO_PIN_RESET);
+        HAL_GPIO_WritePin(output1_GPIO_Port, output1_Pin, GPIO_PIN_RESET);
+        HAL_GPIO_WritePin(output2_GPIO_Port, output2_Pin, GPIO_PIN_RESET);
+        HAL_GPIO_WritePin(output3_GPIO_Port, output3_Pin, GPIO_PIN_RESET);
     } else {
-        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, ((temp & 0x01) == 0x01) ? GPIO_PIN_SET : GPIO_PIN_RESET);
-        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, ((temp & 0x02) == 0x02) ? GPIO_PIN_SET : GPIO_PIN_RESET);
-        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, ((temp & 0x04) == 0x04) ? GPIO_PIN_SET : GPIO_PIN_RESET);
-        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, ((temp & 0x08) == 0x08) ? GPIO_PIN_SET : GPIO_PIN_RESET);
+        HAL_GPIO_WritePin(output0_GPIO_Port, output0_Pin, ((temp & 0x01) == 0x01) ? GPIO_PIN_SET : GPIO_PIN_RESET);
+        HAL_GPIO_WritePin(output1_GPIO_Port, output1_Pin, ((temp & 0x02) == 0x02) ? GPIO_PIN_SET : GPIO_PIN_RESET);
+        HAL_GPIO_WritePin(output2_GPIO_Port, output2_Pin, ((temp & 0x04) == 0x04) ? GPIO_PIN_SET : GPIO_PIN_RESET);
+        HAL_GPIO_WritePin(output3_GPIO_Port, output3_Pin, ((temp & 0x08) == 0x08) ? GPIO_PIN_SET : GPIO_PIN_RESET);
     }
 }
 

+ 70 - 58
Core/Src/iap.c

@@ -5,6 +5,7 @@
 #include "iap.h"
 #include "dataHandling.h"
 #include "md5c.h"
+#include "stdbool.h"
 
 typedef  void (*iapfun)(void);	
 iapfun jump2app;
@@ -49,7 +50,7 @@ uint16_t packTotalNum = 0;
 uint16_t packIndexbak = 0; 
 uint16_t crcIAP = 0;
 uint16_t crcTerminal = 0;
-uint32_t AddrToWrite = Application_Buffer_Addr;
+uint32_t AddrToWrite ;
 int FileLength_IAP; 
 uint32_t update_flag = 0;
 
@@ -63,7 +64,8 @@ uint16_t curaddr[2] = {0};
 uint16_t curapack[1] = {0};
 uint16_t curaddr_pack[3] = {0};
 int sameIndex;
-	
+bool Trindex;
+
 void Process_CMD_IAP_Update(void)
 {
 	int lenRx1;
@@ -75,13 +77,13 @@ void Process_CMD_IAP_Update(void)
 	
 	lenRx1 = USART_PUB_LENGTH;
 
-	uint8_t ERR_Arr[8] = "error\r\n";
+	uint8_t ERR_Arr[8] = "error";
 	
 	YmodemID = USART_IAP_RX[7];
+	
 	memset(FileBuffArray, 0, sizeof(FileBuffArray));
 	memset(FileBuffArray1, 0, sizeof(FileBuffArray1));
 	
-	updatecuraddr(CURaddr_PACKAGE_ADDR);
 	
 	switch (YmodemID)
 	{
@@ -181,6 +183,7 @@ void Process_CMD_IAP_Update(void)
 			
 			memset(FileBuffArray, 0, sizeof(FileBuffArray));
 			memset(FileBuffArray1, 0, sizeof(FileBuffArray1));
+
 			break;
 			
 /***
@@ -188,67 +191,84 @@ void Process_CMD_IAP_Update(void)
  */			
 			
 		case 0x02:														//有效载荷帧数据处理
+			
+			updatecuraddr(CURaddr_PACKAGE_ADDR);
+			updatecurpack(CURaddr_PACKAGE_ADDR);
+		
 			crcIAP = crc16_xmodem(&USART_IAP_RX[10], 128); 
 			crcTerminal = (USART_IAP_RX[lenRx1 - 4] << 8) + USART_IAP_RX[lenRx1 - 3];
+			
+//			nowcurAddr1 += 128;
 		
-		
-			if(nowcurAddr1 == 0xFFFFFFFF)
+
+			if((nowcurAddr1&0xFFFF) == addrIndex+128)
 			{
-				AddrToWrite = Application_Buffer_Addr;
+				Trindex = 1;
 			}
-			else{
-				int addr = nowcurAddr1;
-				int base_addr = Application_Buffer_Addr;
-				int step_size = 0x80;
-				int index = (addr - base_addr) / step_size;//算出包索引
+			else
+			{
+				Trindex = 0;
 				
-				AddrToWrite = addr;
-				packIndex = index;
 			}
 		
+			if(((nowcurAddr1&0xFFFF) != addrIndex)  && Trindex)
+				
+			{
+				addrIndex-=128;
+				nowcurAddr1 = (nowcurAddr1 &0xFFFF0000) | addrIndex;
+				AddrToWrite = nowcurAddr1;
+
+			}
+			
+
+			
+					
 			if (crcIAP == crcTerminal)
 			{
+				HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET);
+				HAL_Delay(1);  
+				HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
+
 				for (i = 0; i < 64; i++)
 				{
 					FileBuffArray[i] = (uint16_t)(USART_IAP_RX[i * 2 + 11] << 8 | USART_IAP_RX[i * 2 + 10]);
 				}
-
-				Flash_WriteBytes(FileBuffArray, AddrToWrite, 64);
-				AddrToWrite += 128;
-				
-				
-				HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET);
-				HAL_Delay(1);  
-				HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
 				
+				Flash_WriteBytes(FileBuffArray, AddrToWrite, 64);//init 08040000
+				AddrToWrite += 128;								 // +128
+				nowcurAddr = AddrToWrite;
+				curaddr_pack[0] = (nowcurAddr >> 16) & 0xFFFF;
+				curaddr_pack[1] = nowcurAddr & 0xFFFF;
+				curaddr_pack[2] = packIndex;
+				Flash_WriteBytes(curaddr_pack, CURaddr_PACKAGE_ADDR, 3);
 				
-				if((AddrToWrite & 0xffff) != (USART_IAP_RX[2] << 8 | USART_IAP_RX[3]))
-				{
-					HAL_UART_Transmit(&huart1, ERR_Arr, strlen((char *)ERR_Arr), 100);
-					break;
-				}
 				
 				
 				memset(USART_IAP_RX, 0, sizeof(USART_IAP_RX));	
 				
 				//CURPACKAGE_ADDR
 				//CURADDRESS_ADDR
-				nowcurAddr = AddrToWrite;
-				
-				curaddr_pack[0] = (nowcurAddr >> 16) & 0xFFFF;;
-				curaddr_pack[1] = nowcurAddr & 0xFFFF;
-				curaddr_pack[2] = packIndex+1;
+
+//				if((nowcurAddr-128) != addrIndex)
+//				{
+//					
+//					HAL_UART_Transmit(&huart1, ERR_Arr, strlen((char *)ERR_Arr), 100);
+//					return;
+//				}
+//				else
+//				{
+					
+				HAL_GPIO_WritePin(kmg_GPIO_Port, kmg_Pin, GPIO_PIN_SET);
+				HAL_Delay(1);  
+				HAL_GPIO_WritePin(kmg_GPIO_Port, kmg_Pin, GPIO_PIN_RESET);
+//				}
 				
+				receive_modbus_9_1(initial_address, USART_MODBUS_RX[1], ((uint16_t)USART_MODBUS_RX[2] << 8) | USART_MODBUS_RX[3], \
+									((uint16_t)USART_MODBUS_RX[4] << 8) | USART_MODBUS_RX[5], USART_MODBUS_RX[6]);		
 
 			}	
-
-				HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET);
-				HAL_Delay(1);  
-				HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
-			Flash_WriteBytes(curaddr_pack, CURaddr_PACKAGE_ADDR, 3);
-			
-			receive_modbus_9_1(initial_address, USART_MODBUS_RX[1], ((uint16_t)USART_MODBUS_RX[2] << 8) | USART_MODBUS_RX[3], \
-								((uint16_t)USART_MODBUS_RX[4] << 8) | USART_MODBUS_RX[5], USART_MODBUS_RX[6]);			
+	
+	
 			break;
 			
 			
@@ -323,7 +343,6 @@ void Start_BootLoader(void)
 	int txLen;
 	memset(USART_IAP_RX, 0, sizeof(USART_IAP_RX));	
 	
-	
     update_iaplength(LENGTH_ADDR);
 	
 	switch (ModeStart)
@@ -333,7 +352,6 @@ void Start_BootLoader(void)
 			break;
 		}
 		
-		
 		case Startup_Update: /*启动最新的程序 */
 
 			all_len = FileLength_IAP;
@@ -344,13 +362,13 @@ void Start_BootLoader(void)
 				iap_write_appbin(ADD_UPDATE_PROG,Application_Buffer_Addr,all_len);
 
 				HAL_Delay(80);
-				txLen = sprintf((char *)USART_IAP_RX, "updating");
+				txLen = sprintf((char *)USART_IAP_RX, "Upgrade completed");
 				HAL_UART_Transmit_IT(&huart1,USART_IAP_RX,txLen);		
 				while (huart1.gState == HAL_UART_STATE_BUSY_TX)
 				{
 					HAL_Delay(1);
-				}	
-				
+				}		
+				Set_App2_Flag();
 				
 			}
 			else
@@ -364,22 +382,11 @@ void Start_BootLoader(void)
 				}
 				return ;
 			}	
-			
-			if (App2_MD5_Check(ADD_UPDATE_PROG,all_len))
-			{		
-				txLen = sprintf((char *)USART_IAP_RX, "checkok");
-				HAL_UART_Transmit_IT(&huart1,USART_IAP_RX,txLen);			
-				while (huart1.gState == HAL_UART_STATE_BUSY_TX)
-				{
-					HAL_Delay(1);
-				}
-				
-				Set_App2_Flag();
-			}
+
 
 		case Startup_APP2: /*启动最新的程序 */
 		
-			if ((all_len<0x20000) && App2_MD5_Check(ADD_UPDATE_PROG,all_len))
+			if (App2_MD5_Check(ADD_UPDATE_PROG,all_len))
 			{
 				__set_FAULTMASK(0);			   //先关闭全局中断
 				jump_to_app(ADD_UPDATE_PROG);
@@ -387,6 +394,11 @@ void Start_BootLoader(void)
 			break;
 		default: // 启动失败
 		{
+			if (App2_MD5_Check(ADD_UPDATE_PROG,all_len))
+			{
+				__set_FAULTMASK(0);			   //先关闭全局中断
+				jump_to_app(ADD_UPDATE_PROG);
+			}	
 			return;
 		}
 	}

+ 40 - 5
Core/Src/main.c

@@ -52,7 +52,7 @@ uint8_t  data_to_send[50];
 uint16_t CRC_value 		 = 0;
 uint16_t initial_address = 0x00C1;
 uint16_t BaudrateValue 	 = 0x0000;
-uint32_t System_version  = 0x23080800;
+uint32_t System_version  = 0x23081000;
 uint8_t  bufMain[128] 	= {0};
 
 /* USER CODE END PV */
@@ -114,18 +114,23 @@ int main(void)
 
 //更新标定数据  
   AdcCalibration_init();
-  updateiapMd5(StartMode_Addr);
+  updateiapMd5();
   update_sysVersion(StartMode_Addr+14);
   read_new_address(addr_FLASH_ADDR); 
   updatePbStatus(read_flash_16(pbstatus_FLASH_ADDR));
   update_baudrate(read_flash_16(baudrate_FLASH_ADDR));
 //更新结束  
 
-
-	int txLen = sprintf((char *)USART_IAP_RX, "app1");
-	HAL_UART_Transmit_IT(&huart1,USART_IAP_RX,txLen);	
+  int txLen = sprintf((char *)USART_IAP_RX, "app2");
+  HAL_UART_Transmit_IT(&huart1,USART_IAP_RX,txLen);	
   HAL_UART_Receive_DMA(&huart1,USART_PUB_RX,RX_BUF_SIZE); 
   __HAL_UART_ENABLE_IT(&huart1, UART_IT_IDLE); 
+  
+	if (App2_MD5_Check(ADD_UPDATE_PROG,all_len))
+	{
+		__set_FAULTMASK(0);			   //先关闭全局中断
+		jump_to_app(ADD_UPDATE_PROG);
+	}	
   /* USER CODE END 2 */
 
   /* Call init function for freertos objects (in freertos.c) */
@@ -393,6 +398,7 @@ void receive_modbus_15(uint16_t addr, uint8_t funcode, uint8_t byteNum, uint16_t
 	uint16_t CRC_value = calculate_crc(data_to_send, (byteSize - 2));
 	data_to_send[(byteSize - 2)] = (uint8_t)(CRC_value & 0xFF);
 	data_to_send[(byteSize - 1)] = (uint8_t)(CRC_value >> 8);
+		
 	HAL_UART_Transmit(&huart1, data_to_send, byteSize, (byteSize - 1));
 	clear_buf();
 	re_receive();
@@ -515,9 +521,16 @@ void ModBus(void) {
 		else if(USART_MODBUS_RX[0] == (uint8_t)initial_address && USART_MODBUS_RX[1] == 0x03 && USART_MODBUS_RX[2] == 0x50 \
 			&& USART_MODBUS_RX[3] == 0x02 && USART_MODBUS_RX[4] == 0x00 && USART_MODBUS_RX[5] == 0x02){//断点地址
 
+				
 			updatecuraddr(CURaddr_PACKAGE_ADDR);
+
 			receive_modbus_9(initial_address, 0x03, 0x04,  ((nowcurAddr1 >> 16) & 0xFFFF), (nowcurAddr1 & 0xFFFF), 9);
 				
+			addrIndex = (nowcurAddr1 & 0xFFFF) << 8 | (nowcurAddr1 & 0xFFFF);
+			addrIndex-=128;
+			AddrToWrite = nowcurAddr1 -128;
+
+
 
 		}
 			
@@ -525,11 +538,33 @@ void ModBus(void) {
 			&& USART_MODBUS_RX[3] == 0x04 && USART_MODBUS_RX[4] == 0x00 && USART_MODBUS_RX[5] == 0x01){//断点包索引
 				
 			updatecurpack(CURaddr_PACKAGE_ADDR);
+				
 			receive_modbus_7(initial_address, 0x03, 0x02, nowcurpack, 7);
 				
 
 		}
 			
+		else if(USART_MODBUS_RX[0] == (uint8_t)initial_address && USART_MODBUS_RX[1] == 0x03 && USART_MODBUS_RX[2] == 0x50 \
+			&& USART_MODBUS_RX[3] == 0x05 && USART_MODBUS_RX[4] == 0x00 && USART_MODBUS_RX[5] == 0x08){//断点包索引
+				
+			data_to_send[0] = (uint8_t)initial_address;
+			data_to_send[1] = 0x03;
+			data_to_send[2] = 0x10;
+			for (int i = 0; i < 8; i++) {
+				data_to_send[3 + i * 2] = (uint8_t)(iapbinMd5[i] >> 8); // 高位字节
+				data_to_send[3 + i * 2 + 1] = (uint8_t)(iapbinMd5[i] & 0xFF); // 低位字节
+			}
+	
+			uint16_t CRC_value = calculate_crc(data_to_send, 19);
+			data_to_send[19] = (uint8_t)(CRC_value & 0xFF);
+			data_to_send[20] = (uint8_t)(CRC_value >> 8);
+				
+			HAL_UART_Transmit(&huart1, data_to_send, 21, 25);
+			clear_buf();
+			re_receive();
+
+		}
+			
 		else if(USART_MODBUS_RX[0] == (uint8_t)initial_address && USART_MODBUS_RX[1] == 0x06 && USART_MODBUS_RX[2] == 0x00 \
 			&& USART_MODBUS_RX[3] == 0x02 && USART_MODBUS_RX[4] == 0x00){
 			

+ 0 - 27
Core/Src/md5c.c

@@ -1,34 +1,7 @@
-/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm 
- */ 
- 
-/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All 
-rights reserved. 
- 
-License to copy and use this software is granted provided that it 
-is identified as the "RSA Data Security, Inc. MD5 Message-Digest 
-Algorithm" in all material mentioning or referencing this software 
-or this function. 
- 
-License is also granted to make and use derivative works provided 
-that such works are identified as "derived from the RSA Data 
-Security, Inc. MD5 Message-Digest Algorithm" in all material 
-mentioning or referencing the derived work. 
- 
-RSA Data Security, Inc. makes no representations concerning either 
-the merchantability of this software or the suitability of this 
-software for any particular purpose. It is provided "as is" 
-without express or implied warranty of any kind. 
- 
-These notices must be retained in any copies of any part of this 
-documentation and/or software. 
- */ 
 #include "md5c.h" 
 #include <string.h> 
 #include <stdio.h> 
  
-/* Constants for MD5Transform routine. 
-*/ 
- 
  
 #define S11 7 
 #define S12 12 

+ 1 - 1
Core/Src/stm32f1xx_it.c

@@ -232,7 +232,7 @@ void ADC1_2_IRQHandler(void)
 void TIM2_IRQHandler(void)
 {
   /* USER CODE BEGIN TIM2_IRQn 0 */
-  HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_12);
+  HAL_GPIO_TogglePin(led_GPIO_Port, led_Pin);
   /* USER CODE END TIM2_IRQn 0 */
   HAL_TIM_IRQHandler(&htim2);
   /* USER CODE BEGIN TIM2_IRQn 1 */

+ 21 - 11
Core/Src/usart.c

@@ -128,15 +128,15 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
     PA9     ------> USART1_TX
     PA10     ------> USART1_RX
     */
-    GPIO_InitStruct.Pin = GPIO_PIN_9;
+    GPIO_InitStruct.Pin = usart1_tx_Pin;
     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
-    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+    HAL_GPIO_Init(usart1_tx_GPIO_Port, &GPIO_InitStruct);
 
-    GPIO_InitStruct.Pin = GPIO_PIN_10;
+    GPIO_InitStruct.Pin = usart1_rx_Pin;
     GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
     GPIO_InitStruct.Pull = GPIO_NOPULL;
-    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+    HAL_GPIO_Init(usart1_rx_GPIO_Port, &GPIO_InitStruct);
 
     /* USART1 DMA Init */
     /* USART1_RX Init */
@@ -191,15 +191,15 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
     PB10     ------> USART3_TX
     PB11     ------> USART3_RX
     */
-    GPIO_InitStruct.Pin = GPIO_PIN_10;
+    GPIO_InitStruct.Pin = usart3_tx_Pin;
     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
-    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+    HAL_GPIO_Init(usart3_tx_GPIO_Port, &GPIO_InitStruct);
 
-    GPIO_InitStruct.Pin = GPIO_PIN_11;
+    GPIO_InitStruct.Pin = usart3_rx_Pin;
     GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
     GPIO_InitStruct.Pull = GPIO_NOPULL;
-    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+    HAL_GPIO_Init(usart3_rx_GPIO_Port, &GPIO_InitStruct);
 
     /* USART3 DMA Init */
     /* USART3_RX Init */
@@ -242,7 +242,7 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
     PA9     ------> USART1_TX
     PA10     ------> USART1_RX
     */
-    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
+    HAL_GPIO_DeInit(GPIOA, usart1_tx_Pin|usart1_rx_Pin);
 
     /* USART1 DMA DeInit */
     HAL_DMA_DeInit(uartHandle->hdmarx);
@@ -266,7 +266,7 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
     PB10     ------> USART3_TX
     PB11     ------> USART3_RX
     */
-    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11);
+    HAL_GPIO_DeInit(GPIOB, usart3_tx_Pin|usart3_rx_Pin);
 
     /* USART3 DMA DeInit */
     HAL_DMA_DeInit(uartHandle->hdmarx);
@@ -345,7 +345,7 @@ void update_iaplength(uint32_t addr)
 	}
 }
 
-void updateiapMd5(uint32_t addr)
+void updateiapMd5(void)
 {
 	Flash_ReadBytes(iapbinMd5, MD5_ADDR, 16);
 	for (int i = 0; i < 8; i++) {
@@ -357,6 +357,16 @@ void updatecuraddr(uint32_t addr)
 {
 	Flash_ReadBytes(&curaddr[0], addr, 4);
 	nowcurAddr1 =  ((uint32_t)curaddr[0] << 16) | curaddr[1];
+	if(nowcurAddr1 == 0xFFFFFFFF)
+	{
+		nowcurAddr1 = 0;
+	}
+	else
+	{
+		
+		nowcurAddr1 += 128;
+	}
+	
 }
 
 void updatecurpack(uint32_t addr)

BIN
Doc/IAP升级2.0及底板程序设计方案.docx


BIN
Doc/IAP升级2.0及底板程序设计方案.pdf


BIN
Doc/iocollect软件功能说明及操作说明书.docx


BIN
Doc/iocollect软件功能说明及操作说明书.pdf


BIN
Doc/~$collect软件功能说明及操作说明书.docx


+ 26 - 76
MDK-ARM/iocollect.uvoptx

@@ -158,73 +158,23 @@
         <Ww>
           <count>0</count>
           <WinNumber>1</WinNumber>
-          <ItemText>FileLength_IAP</ItemText>
+          <ItemText>nowcurAddr1</ItemText>
         </Ww>
         <Ww>
           <count>1</count>
           <WinNumber>1</WinNumber>
-          <ItemText>tag</ItemText>
+          <ItemText>addrIndex</ItemText>
         </Ww>
         <Ww>
           <count>2</count>
           <WinNumber>1</WinNumber>
-          <ItemText>iapbuf</ItemText>
+          <ItemText>Trindex</ItemText>
         </Ww>
         <Ww>
           <count>3</count>
           <WinNumber>1</WinNumber>
-          <ItemText>FileLength_IAP</ItemText>
-        </Ww>
-        <Ww>
-          <count>4</count>
-          <WinNumber>1</WinNumber>
-          <ItemText>ModeStart</ItemText>
-        </Ww>
-        <Ww>
-          <count>5</count>
-          <WinNumber>1</WinNumber>
-          <ItemText>ModeStart</ItemText>
-        </Ww>
-        <Ww>
-          <count>6</count>
-          <WinNumber>1</WinNumber>
-          <ItemText>pagesize</ItemText>
-        </Ww>
-        <Ww>
-          <count>7</count>
-          <WinNumber>1</WinNumber>
-          <ItemText>packIndex</ItemText>
-        </Ww>
-        <Ww>
-          <count>8</count>
-          <WinNumber>1</WinNumber>
-          <ItemText>all_len</ItemText>
-        </Ww>
-        <Ww>
-          <count>9</count>
-          <WinNumber>1</WinNumber>
-          <ItemText>nowcurAddr</ItemText>
-        </Ww>
-        <Ww>
-          <count>10</count>
-          <WinNumber>1</WinNumber>
-          <ItemText>nowcurAddr1</ItemText>
-        </Ww>
-        <Ww>
-          <count>11</count>
-          <WinNumber>1</WinNumber>
           <ItemText>AddrToWrite</ItemText>
         </Ww>
-        <Ww>
-          <count>12</count>
-          <WinNumber>1</WinNumber>
-          <ItemText>nowcurpack</ItemText>
-        </Ww>
-        <Ww>
-          <count>13</count>
-          <WinNumber>1</WinNumber>
-          <ItemText>sameIndex</ItemText>
-        </Ww>
       </WatchWindow1>
       <WatchWindow2>
         <Ww>
@@ -247,7 +197,7 @@
         <Mm>
           <WinNumber>1</WinNumber>
           <SubType>0</SubType>
-          <ItemText>0x8075000</ItemText>
+          <ItemText>0x8073000</ItemText>
           <AccSizeX>0</AccSizeX>
         </Mm>
       </MemoryWindow1>
@@ -255,7 +205,7 @@
         <Mm>
           <WinNumber>2</WinNumber>
           <SubType>0</SubType>
-          <ItemText>0x807F07A</ItemText>
+          <ItemText>0x8040400</ItemText>
           <AccSizeX>0</AccSizeX>
         </Mm>
       </MemoryWindow2>
@@ -384,6 +334,18 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
+      <PathWithFileName>..\Core\Src\md5c.c</PathWithFileName>
+      <FilenameWithoutPath>md5c.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>2</GroupNumber>
+      <FileNumber>5</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
       <PathWithFileName>../Core/Src/main.c</PathWithFileName>
       <FilenameWithoutPath>main.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
@@ -391,7 +353,7 @@
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
-      <FileNumber>5</FileNumber>
+      <FileNumber>6</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -403,7 +365,7 @@
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
-      <FileNumber>6</FileNumber>
+      <FileNumber>7</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -415,7 +377,7 @@
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
-      <FileNumber>7</FileNumber>
+      <FileNumber>8</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -427,7 +389,7 @@
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
-      <FileNumber>8</FileNumber>
+      <FileNumber>9</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -439,7 +401,7 @@
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
-      <FileNumber>9</FileNumber>
+      <FileNumber>10</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -451,7 +413,7 @@
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
-      <FileNumber>10</FileNumber>
+      <FileNumber>11</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -463,7 +425,7 @@
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
-      <FileNumber>11</FileNumber>
+      <FileNumber>12</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -475,7 +437,7 @@
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
-      <FileNumber>12</FileNumber>
+      <FileNumber>13</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -487,7 +449,7 @@
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
-      <FileNumber>13</FileNumber>
+      <FileNumber>14</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -497,18 +459,6 @@
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
-    <File>
-      <GroupNumber>2</GroupNumber>
-      <FileNumber>14</FileNumber>
-      <FileType>1</FileType>
-      <tvExp>0</tvExp>
-      <tvExpOptDlg>0</tvExpOptDlg>
-      <bDave2>0</bDave2>
-      <PathWithFileName>..\Core\Src\md5c.c</PathWithFileName>
-      <FilenameWithoutPath>md5c.c</FilenameWithoutPath>
-      <RteFlg>0</RteFlg>
-      <bShared>0</bShared>
-    </File>
   </Group>
 
   <Group>

+ 7 - 7
MDK-ARM/iocollect.uvprojx

@@ -49,7 +49,7 @@
             <InvalidFlash>1</InvalidFlash>
           </TargetStatus>
           <OutputDirectory>..\Output\</OutputDirectory>
-          <OutputName>iocollect_23080800</OutputName>
+          <OutputName>iocollect_23081000</OutputName>
           <CreateExecutable>1</CreateExecutable>
           <CreateLib>0</CreateLib>
           <CreateHexFile>1</CreateHexFile>
@@ -82,7 +82,7 @@
           <AfterMake>
             <RunUserProg1>1</RunUserProg1>
             <RunUserProg2>0</RunUserProg2>
-            <UserProg1Name>fromelf.exe --bin --output ..\Output\iocollect_23080800.bin ..\Output\*.axf</UserProg1Name>
+            <UserProg1Name>fromelf.exe --bin --output ..\Output\iocollect_23081000.bin ..\Output\*.axf</UserProg1Name>
             <UserProg2Name></UserProg2Name>
             <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
             <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
@@ -404,6 +404,11 @@
               <FileType>1</FileType>
               <FilePath>..\Core\Src\dataHandling.c</FilePath>
             </File>
+            <File>
+              <FileName>md5c.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Core\Src\md5c.c</FilePath>
+            </File>
             <File>
               <FileName>main.c</FileName>
               <FileType>1</FileType>
@@ -709,11 +714,6 @@
                 </FileArmAds>
               </FileOption>
             </File>
-            <File>
-              <FileName>md5c.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Core\Src\md5c.c</FilePath>
-            </File>
           </Files>
         </Group>
         <Group>

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 2121
Output/iocollect_23080700.hex


+ 0 - 46
Output/iocollect_23080700.lnp

@@ -1,46 +0,0 @@
---cpu Cortex-M3
-"..\output\startup_stm32f103xe.o"
-"..\output\iap.o"
-"..\output\datahandling.o"
-"..\output\main.o"
-"..\output\gpio.o"
-"..\output\freertos.o"
-"..\output\adc.o"
-"..\output\dma.o"
-"..\output\tim.o"
-"..\output\usart.o"
-"..\output\stm32f1xx_it.o"
-"..\output\stm32f1xx_hal_msp.o"
-"..\output\stm32f1xx_hal_timebase_tim.o"
-"..\output\md5c.o"
-"..\output\stm32f1xx_hal_gpio_ex.o"
-"..\output\stm32f1xx_hal_adc.o"
-"..\output\stm32f1xx_hal_adc_ex.o"
-"..\output\stm32f1xx_hal.o"
-"..\output\stm32f1xx_hal_rcc.o"
-"..\output\stm32f1xx_hal_rcc_ex.o"
-"..\output\stm32f1xx_hal_gpio.o"
-"..\output\stm32f1xx_hal_dma.o"
-"..\output\stm32f1xx_hal_cortex.o"
-"..\output\stm32f1xx_hal_pwr.o"
-"..\output\stm32f1xx_hal_flash.o"
-"..\output\stm32f1xx_hal_flash_ex.o"
-"..\output\stm32f1xx_hal_exti.o"
-"..\output\stm32f1xx_hal_tim.o"
-"..\output\stm32f1xx_hal_tim_ex.o"
-"..\output\stm32f1xx_hal_uart.o"
-"..\output\system_stm32f1xx.o"
-"..\output\croutine.o"
-"..\output\event_groups.o"
-"..\output\list.o"
-"..\output\queue.o"
-"..\output\stream_buffer.o"
-"..\output\tasks.o"
-"..\output\timers.o"
-"..\output\cmsis_os.o"
-"..\output\heap_4.o"
-"..\output\port.o"
---library_type=microlib --strict --scatter "..\Output\iocollect_23080700.sct"
---summary_stderr --info summarysizes --map --load_addr_map_info --xref --callgraph --symbols
---info sizes --info totals --info unused --info veneers
---list "..\Output\iocollect_23080700.map" -o ..\Output\iocollect_23080700.axf

BIN
Output/iocollect_23080800.bin


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1055 - 1040
Output/iocollect_23080800.hex


+ 3 - 3
Output/iocollect_23080800.lnp

@@ -2,6 +2,7 @@
 "..\output\startup_stm32f103xe.o"
 "..\output\iap.o"
 "..\output\datahandling.o"
+"..\output\md5c.o"
 "..\output\main.o"
 "..\output\gpio.o"
 "..\output\freertos.o"
@@ -12,7 +13,6 @@
 "..\output\stm32f1xx_it.o"
 "..\output\stm32f1xx_hal_msp.o"
 "..\output\stm32f1xx_hal_timebase_tim.o"
-"..\output\md5c.o"
 "..\output\stm32f1xx_hal_gpio_ex.o"
 "..\output\stm32f1xx_hal_adc.o"
 "..\output\stm32f1xx_hal_adc_ex.o"
@@ -40,7 +40,7 @@
 "..\output\cmsis_os.o"
 "..\output\heap_4.o"
 "..\output\port.o"
---library_type=microlib --strict --scatter "..\Output\iocollect_23080800.sct"
+--library_type=microlib --strict --scatter "..\Output\iocollect_23081000.sct"
 --summary_stderr --info summarysizes --map --load_addr_map_info --xref --callgraph --symbols
 --info sizes --info totals --info unused --info veneers
---list "..\Output\iocollect_23080800.map" -o ..\Output\iocollect_23080800.axf
+--list "..\Output\iocollect_23081000.map" -o ..\Output\iocollect_23081000.axf

BIN
Software/IAPV2.0/iapv2.exe


BIN
Output/iocollect_23080700.bin


BIN
Software/测试升级程序/iocollect_23081103.bin


+ 42 - 0
iocollect.ioc

@@ -126,48 +126,90 @@ NVIC.TimeBaseIP=TIM3
 NVIC.USART1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true\:true
 NVIC.USART3_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
 NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
+PA0-WKUP.GPIOParameters=GPIO_Label
+PA0-WKUP.GPIO_Label=input0
 PA0-WKUP.Locked=true
 PA0-WKUP.Signal=GPIO_Input
+PA1.GPIOParameters=GPIO_Label
+PA1.GPIO_Label=input1
 PA1.Locked=true
 PA1.Signal=GPIO_Input
+PA10.GPIOParameters=GPIO_Label
+PA10.GPIO_Label=usart1_rx
 PA10.Mode=Asynchronous
 PA10.Signal=USART1_RX
 PA13.Mode=Serial_Wire
 PA13.Signal=SYS_JTMS-SWDIO
 PA14.Mode=Serial_Wire
 PA14.Signal=SYS_JTCK-SWCLK
+PA2.GPIOParameters=GPIO_Label
+PA2.GPIO_Label=input2
 PA2.Locked=true
 PA2.Signal=GPIO_Input
+PA3.GPIOParameters=GPIO_Label
+PA3.GPIO_Label=input3
 PA3.Locked=true
 PA3.Signal=GPIO_Input
+PA4.GPIOParameters=GPIO_Label
+PA4.GPIO_Label=input4
 PA4.Locked=true
 PA4.Signal=GPIO_Input
+PA5.GPIOParameters=GPIO_Label
+PA5.GPIO_Label=input5
 PA5.Locked=true
 PA5.Signal=GPIO_Input
+PA6.GPIOParameters=GPIO_Label
+PA6.GPIO_Label=input6
 PA6.Locked=true
 PA6.Signal=GPIO_Input
+PA7.GPIOParameters=GPIO_Label
+PA7.GPIO_Label=input7
 PA7.Locked=true
 PA7.Signal=GPIO_Input
+PA9.GPIOParameters=GPIO_Label
+PA9.GPIO_Label=usart1_tx
 PA9.Mode=Asynchronous
 PA9.Signal=USART1_TX
+PB0.GPIOParameters=GPIO_Label
+PB0.GPIO_Label=kmg
 PB0.Locked=true
 PB0.Signal=GPIO_Output
+PB10.GPIOParameters=GPIO_Label
+PB10.GPIO_Label=usart3_tx
 PB10.Mode=Asynchronous
 PB10.Signal=USART3_TX
+PB11.GPIOParameters=GPIO_Label
+PB11.GPIO_Label=usart3_rx
 PB11.Mode=Asynchronous
 PB11.Signal=USART3_RX
+PB12.GPIOParameters=GPIO_Label
+PB12.GPIO_Label=led
 PB12.Locked=true
 PB12.Signal=GPIO_Output
+PB3.GPIOParameters=GPIO_Label
+PB3.GPIO_Label=output0
 PB3.Locked=true
 PB3.Signal=GPIO_Output
+PB4.GPIOParameters=GPIO_Label
+PB4.GPIO_Label=output1
 PB4.Locked=true
 PB4.Signal=GPIO_Output
+PB5.GPIOParameters=GPIO_Label
+PB5.GPIO_Label=output2
 PB5.Locked=true
 PB5.Signal=GPIO_Output
+PB6.GPIOParameters=GPIO_Label
+PB6.GPIO_Label=output3
 PB6.Locked=true
 PB6.Signal=GPIO_Output
+PC0.GPIOParameters=GPIO_Label
+PC0.GPIO_Label=adc0
 PC0.Signal=ADCx_IN10
+PC1.GPIOParameters=GPIO_Label
+PC1.GPIO_Label=adc1
 PC1.Signal=ADCx_IN11
+PC2.GPIOParameters=GPIO_Label
+PC2.GPIO_Label=adc2
 PC2.Signal=ADCx_IN12
 PD0-OSC_IN.Mode=HSE-External-Oscillator
 PD0-OSC_IN.Signal=RCC_OSC_IN