zhao006 6 月之前
父節點
當前提交
1f89148633

+ 65 - 65
APP/HARDWARE/includes/bat.h

@@ -6,105 +6,105 @@
 #define ON  1
 #define OFF 0
 
-#define GPIO0_PIN   			   	 GPIO_Pin_0
-#define GPIO0_PORT      			 GPIOC                      
-#define GPIO0_CLK       			 RCC_AHB1Periph_GPIOC
+#define GPIO0_PIN   			   	 GPIO_Pin_1
+#define GPIO0_PORT      			 GPIOG                      
+#define GPIO0_CLK       			 RCC_AHB1Periph_GPIOG
 
-#define GPIO1_PIN   			   	 GPIO_Pin_1
-#define GPIO1_PORT      			 GPIOC                      
-#define GPIO1_CLK       			 RCC_AHB1Periph_GPIOC
+#define GPIO1_PIN   			   	 GPIO_Pin_11
+#define GPIO1_PORT      			 GPIOB                      
+#define GPIO1_CLK       			 RCC_AHB1Periph_GPIOB
 
-#define GPIO2_PIN   			   	 GPIO_Pin_2
-#define GPIO2_PORT      			 GPIOC                      
-#define GPIO2_CLK       			 RCC_AHB1Periph_GPIOC
+#define GPIO2_PIN   			   	 GPIO_Pin_12
+#define GPIO2_PORT      			 GPIOB                      
+#define GPIO2_CLK       			 RCC_AHB1Periph_GPIOB
 
-#define GPIO3_PIN   			   	 GPIO_Pin_3
-#define GPIO3_PORT      			 GPIOC                      
-#define GPIO3_CLK       			 RCC_AHB1Periph_GPIOC
+#define GPIO3_PIN   			   	 GPIO_Pin_13
+#define GPIO3_PORT      			 GPIOB                      
+#define GPIO3_CLK       			 RCC_AHB1Periph_GPIOB
 
-#define GPIO4_PIN   			   	 GPIO_Pin_4
-#define GPIO4_PORT      			 GPIOC                      
-#define GPIO4_CLK       			 RCC_AHB1Periph_GPIOC
+#define GPIO4_PIN   			   	 GPIO_Pin_14
+#define GPIO4_PORT      			 GPIOB                      
+#define GPIO4_CLK       			 RCC_AHB1Periph_GPIOB
 
-#define GPIO5_PIN   			   	 GPIO_Pin_5
-#define GPIO5_PORT      			 GPIOC                      
-#define GPIO5_CLK       			 RCC_AHB1Periph_GPIOC
+#define GPIO5_PIN   			   	 GPIO_Pin_15
+#define GPIO5_PORT      			 GPIOB                      
+#define GPIO5_CLK       			 RCC_AHB1Periph_GPIOB
 
-#define GPIO6_PIN   			   	 GPIO_Pin_6
-#define GPIO6_PORT      			 GPIOC                      
-#define GPIO6_CLK       			 RCC_AHB1Periph_GPIOC
+#define GPIO6_PIN   			   	 GPIO_Pin_10
+#define GPIO6_PORT      			 GPIOD                      
+#define GPIO6_CLK       			 RCC_AHB1Periph_GPIOD
 
-#define GPIO7_PIN   			   	 GPIO_Pin_7
-#define GPIO7_PORT      			 GPIOC                      
-#define GPIO7_CLK       			 RCC_AHB1Periph_GPIOC
+#define GPIO7_PIN   			   	 GPIO_Pin_11
+#define GPIO7_PORT      			 GPIOD                      
+#define GPIO7_CLK       			 RCC_AHB1Periph_GPIOD
 
-#define GPIO8_PIN   			   	 GPIO_Pin_0
+#define GPIO8_PIN   			   	 GPIO_Pin_12
 #define GPIO8_PORT      			 GPIOD                     
 #define GPIO8_CLK       			 RCC_AHB1Periph_GPIOD
 
-#define GPIO9_PIN   			   	 GPIO_Pin_1
+#define GPIO9_PIN   			   	 GPIO_Pin_13
 #define GPIO9_PORT      			 GPIOD                      
 #define GPIO9_CLK       			 RCC_AHB1Periph_GPIOD
 
-#define GPIO10_PIN   			   	 GPIO_Pin_2
+#define GPIO10_PIN   			   	 GPIO_Pin_14
 #define GPIO10_PORT      			 GPIOD                      
 #define GPIO10_CLK       			 RCC_AHB1Periph_GPIOD
 
-#define GPIO11_PIN   			   	 GPIO_Pin_3
+#define GPIO11_PIN   			   	 GPIO_Pin_15
 #define GPIO11_PORT      			 GPIOD                      
 #define GPIO11_CLK       			 RCC_AHB1Periph_GPIOD
 
-#define GPIO12_PIN   			   	 GPIO_Pin_8
-#define GPIO12_PORT      			 GPIOC                      
-#define GPIO12_CLK       			 RCC_AHB1Periph_GPIOC
+#define GPIO12_PIN   			   	 GPIO_Pin_2
+#define GPIO12_PORT      			 GPIOG                      
+#define GPIO12_CLK       			 RCC_AHB1Periph_GPIOG
 
-#define GPIO13_PIN   			   	 GPIO_Pin_9
-#define GPIO13_PORT      			 GPIOC                      
-#define GPIO13_CLK       			 RCC_AHB1Periph_GPIOC
+#define GPIO13_PIN   			   	 GPIO_Pin_3
+#define GPIO13_PORT      			 GPIOG                      
+#define GPIO13_CLK       			 RCC_AHB1Periph_GPIOG
 
-#define GPIO14_PIN   			   	 GPIO_Pin_10
-#define GPIO14_PORT      			 GPIOC                      
-#define GPIO14_CLK       			 RCC_AHB1Periph_GPIOC
+#define GPIO14_PIN   			   	 GPIO_Pin_4
+#define GPIO14_PORT      			 GPIOG                     
+#define GPIO14_CLK       			 RCC_AHB1Periph_GPIOG
 
-#define GPIO15_PIN   			   	 GPIO_Pin_11
-#define GPIO15_PORT      			 GPIOC                      
-#define GPIO15_CLK       			 RCC_AHB1Periph_GPIOC
+#define GPIO15_PIN   			   	 GPIO_Pin_5
+#define GPIO15_PORT      			 GPIOG                      
+#define GPIO15_CLK       			 RCC_AHB1Periph_GPIOG
 
-#define GPIO16_PIN   			   	 GPIO_Pin_12
-#define GPIO16_PORT      			 GPIOC                      
-#define GPIO16_CLK       			 RCC_AHB1Periph_GPIOC
+#define GPIO16_PIN   			   	 GPIO_Pin_6
+#define GPIO16_PORT      			 GPIOG                      
+#define GPIO16_CLK       			 RCC_AHB1Periph_GPIOG
 
-#define GPIO17_PIN   			   	 GPIO_Pin_13
-#define GPIO17_PORT      			 GPIOC                      
-#define GPIO17_CLK       			 RCC_AHB1Periph_GPIOC
+#define GPIO17_PIN   			   	 GPIO_Pin_7
+#define GPIO17_PORT      			 GPIOG                      
+#define GPIO17_CLK       			 RCC_AHB1Periph_GPIOG
 
-#define GPIO18_PIN   			   	 GPIO_Pin_14
-#define GPIO18_PORT      			 GPIOC                      
-#define GPIO18_CLK       			 RCC_AHB1Periph_GPIOC
+#define GPIO18_PIN   			   	 GPIO_Pin_8
+#define GPIO18_PORT      			 GPIOG                     
+#define GPIO18_CLK       			 RCC_AHB1Periph_GPIOG
 
-#define GPIO19_PIN   			   	 GPIO_Pin_15
+#define GPIO19_PIN   			   	 GPIO_Pin_6
 #define GPIO19_PORT      			 GPIOC                      
 #define GPIO19_CLK       			 RCC_AHB1Periph_GPIOC
 
-#define GPIO20_PIN   			   	 GPIO_Pin_4
-#define GPIO20_PORT      			 GPIOD                      
-#define GPIO20_CLK       			 RCC_AHB1Periph_GPIOD
+#define GPIO20_PIN   			   	 GPIO_Pin_7
+#define GPIO20_PORT      			 GPIOC                      
+#define GPIO20_CLK       			 RCC_AHB1Periph_GPIOC
 
-#define GPIO21_PIN   			   	 GPIO_Pin_5
-#define GPIO21_PORT      			 GPIOD                      
-#define GPIO21_CLK       			 RCC_AHB1Periph_GPIOD
+#define GPIO21_PIN   			   	 GPIO_Pin_8
+#define GPIO21_PORT      			 GPIOC                      
+#define GPIO21_CLK       			 RCC_AHB1Periph_GPIOC
 
-#define GPIO22_PIN   			   	 GPIO_Pin_6
-#define GPIO22_PORT      			 GPIOD                      
-#define GPIO22_CLK       			 RCC_AHB1Periph_GPIOD
+#define GPIO22_PIN   			   	 GPIO_Pin_9
+#define GPIO22_PORT      			 GPIOC                      
+#define GPIO22_CLK       			 RCC_AHB1Periph_GPIOC
 
-#define GPIO23_PIN   			   	 GPIO_Pin_7
-#define GPIO23_PORT      			 GPIOD                     
-#define GPIO23_CLK       			 RCC_AHB1Periph_GPIOD
+#define GPIO23_PIN   			   	 GPIO_Pin_8
+#define GPIO23_PORT      			 GPIOA                     
+#define GPIO23_CLK       			 RCC_AHB1Periph_GPIOA
 
-#define EVM_5V_PIN 			   	 	 GPIO_Pin_10
-#define EVM_5V_PORT      			 GPIOD                     
-#define EVM_5V_CLK       			 RCC_AHB1Periph_GPIOD
+#define EVM_5V_PIN 			   	 	 GPIO_Pin_12
+#define EVM_5V_PORT      			 GPIOA                     
+#define EVM_5V_CLK       			 RCC_AHB1Periph_GPIOA
 
 void BAT_12V_Config(void);
 void BAT_5V_Config(void);

+ 179 - 180
APP/HARDWARE/includes/led.h

@@ -4,234 +4,233 @@
 //Ňý˝Ĺś¨Ňĺ
 /******************** A_LED ********************/
 
-#define A_LED1_PIN   			   	 GPIO_Pin_0
-#define A_LED1_GPIO_PORT       GPIOA                      
-#define A_LED1_GPIO_CLK        RCC_AHB1Periph_GPIOA
+#define A_LED1_PIN   			   	 GPIO_Pin_4
+#define A_LED1_GPIO_PORT       GPIOB                      
+#define A_LED1_GPIO_CLK        RCC_AHB1Periph_GPIOB
 
-#define A_LED2_PIN   					 GPIO_Pin_1
-#define A_LED2_GPIO_PORT       GPIOA                      
-#define A_LED2_GPIO_CLK        RCC_AHB1Periph_GPIOA
+#define A_LED2_PIN   					 GPIO_Pin_10
+#define A_LED2_GPIO_PORT       GPIOG                     
+#define A_LED2_GPIO_CLK        RCC_AHB1Periph_GPIOG
  
-#define A_LED3_PIN   					 GPIO_Pin_2
-#define A_LED3_GPIO_PORT       GPIOA                      
-#define A_LED3_GPIO_CLK        RCC_AHB1Periph_GPIOA
+#define A_LED3_PIN   					 GPIO_Pin_9
+#define A_LED3_GPIO_PORT       GPIOG                     
+#define A_LED3_GPIO_CLK        RCC_AHB1Periph_GPIOG
 
-#define A_LED4_PIN   					 GPIO_Pin_3
-#define A_LED4_GPIO_PORT       GPIOA                      
-#define A_LED4_GPIO_CLK        RCC_AHB1Periph_GPIOA
+#define A_LED4_PIN   					 GPIO_Pin_6
+#define A_LED4_GPIO_PORT       GPIOD                      
+#define A_LED4_GPIO_CLK        RCC_AHB1Periph_GPIOD
 
-#define A_LED5_PIN   					 GPIO_Pin_7
-#define A_LED5_GPIO_PORT       GPIOG                      
-#define A_LED5_GPIO_CLK        RCC_AHB1Periph_GPIOG
+#define A_LED5_PIN   					 GPIO_Pin_4
+#define A_LED5_GPIO_PORT       GPIOD                      
+#define A_LED5_GPIO_CLK        RCC_AHB1Periph_GPIOD
 
-#define A_LED6_PIN   					 GPIO_Pin_4
-#define A_LED6_GPIO_PORT       GPIOG                     
-#define A_LED6_GPIO_CLK        RCC_AHB1Periph_GPIOG
+#define A_LED6_PIN   					 GPIO_Pin_3
+#define A_LED6_GPIO_PORT       GPIOD                     
+#define A_LED6_GPIO_CLK        RCC_AHB1Periph_GPIOD
 
-#define A_LED7_PIN   					 GPIO_Pin_5
-#define A_LED7_GPIO_PORT       GPIOG                      
-#define A_LED7_GPIO_CLK        RCC_AHB1Periph_GPIOG
+#define A_LED7_PIN   					 GPIO_Pin_1
+#define A_LED7_GPIO_PORT       GPIOD                      
+#define A_LED7_GPIO_CLK        RCC_AHB1Periph_GPIOD
 
-#define A_LED8_PIN   					 GPIO_Pin_6
-#define A_LED8_GPIO_PORT       GPIOG                      
-#define A_LED8_GPIO_CLK        RCC_AHB1Periph_GPIOG
+#define A_LED8_PIN   					 GPIO_Pin_12
+#define A_LED8_GPIO_PORT       GPIOC                      
+#define A_LED8_GPIO_CLK        RCC_AHB1Periph_GPIOC
 
-#define A_LED9_PIN   					 GPIO_Pin_8
-#define A_LED9_GPIO_PORT       GPIOA                      
-#define A_LED9_GPIO_CLK        RCC_AHB1Periph_GPIOA
+#define A_LED9_PIN   					 GPIO_Pin_10
+#define A_LED9_GPIO_PORT       GPIOC                     
+#define A_LED9_GPIO_CLK        RCC_AHB1Periph_GPIOC
 
-#define A_LED10_PIN   				 GPIO_Pin_9
-#define A_LED10_GPIO_PORT      GPIOA                      
-#define A_LED10_GPIO_CLK       RCC_AHB1Periph_GPIOA
+#define A_LED10_PIN   				 GPIO_Pin_5
+#define A_LED10_GPIO_PORT      GPIOB                      
+#define A_LED10_GPIO_CLK       RCC_AHB1Periph_GPIOB
 
-#define A_LED11_PIN   				 GPIO_Pin_10
-#define A_LED11_GPIO_PORT      GPIOA                      
-#define A_LED11_GPIO_CLK       RCC_AHB1Periph_GPIOA
+#define A_LED11_PIN   				 GPIO_Pin_11
+#define A_LED11_GPIO_PORT      GPIOG                      
+#define A_LED11_GPIO_CLK       RCC_AHB1Periph_GPIOG
 
-#define A_LED12_PIN   				 GPIO_Pin_11
-#define A_LED12_GPIO_PORT      GPIOA                      
-#define A_LED12_GPIO_CLK       RCC_AHB1Periph_GPIOA
+#define A_LED12_PIN   				 GPIO_Pin_3
+#define A_LED12_GPIO_PORT      GPIOB                      
+#define A_LED12_GPIO_CLK       RCC_AHB1Periph_GPIOB
 
-#define A_LED13_PIN   				 GPIO_Pin_12
-#define A_LED13_GPIO_PORT      GPIOA                      
-#define A_LED13_GPIO_CLK       RCC_AHB1Periph_GPIOA
+#define A_LED13_PIN   				 GPIO_Pin_7
+#define A_LED13_GPIO_PORT      GPIOD                      
+#define A_LED13_GPIO_CLK       RCC_AHB1Periph_GPIOD
 
-#define A_LED14_PIN   				 GPIO_Pin_13
-#define A_LED14_GPIO_PORT      GPIOA                      
-#define A_LED14_GPIO_CLK       RCC_AHB1Periph_GPIOA
+#define A_LED14_PIN   				 GPIO_Pin_5
+#define A_LED14_GPIO_PORT      GPIOD                      
+#define A_LED14_GPIO_CLK       RCC_AHB1Periph_GPIOD
 
-#define A_LED15_PIN   				 GPIO_Pin_14
-#define A_LED15_GPIO_PORT      GPIOA                      
-#define A_LED15_GPIO_CLK       RCC_AHB1Periph_GPIOA
+#define A_LED15_PIN   				 GPIO_Pin_2
+#define A_LED15_GPIO_PORT      GPIOD                      
+#define A_LED15_GPIO_CLK       RCC_AHB1Periph_GPIOD
 
-#define A_LED16_PIN   				 GPIO_Pin_15
-#define A_LED16_GPIO_PORT      GPIOA                      
-#define A_LED16_GPIO_CLK       RCC_AHB1Periph_GPIOA
+#define A_LED16_PIN   				 GPIO_Pin_0
+#define A_LED16_GPIO_PORT      GPIOD                    
+#define A_LED16_GPIO_CLK       RCC_AHB1Periph_GPIOD
 
+#define A_LED17_PIN   			  	GPIO_Pin_11
+#define A_LED17_GPIO_PORT       GPIOC                      
+#define A_LED17_GPIO_CLK        RCC_AHB1Periph_GPIOC
 
-#define A_LED17_PIN   			  	GPIO_Pin_0
-#define A_LED17_GPIO_PORT       GPIOB                      
-#define A_LED17_GPIO_CLK        RCC_AHB1Periph_GPIOB
-
-#define A_LED18_PIN   					GPIO_Pin_1
-#define A_LED18_GPIO_PORT     	GPIOB                      
-#define A_LED18_GPIO_CLK      	RCC_AHB1Periph_GPIOB
+#define A_LED18_PIN   					GPIO_Pin_15
+#define A_LED18_GPIO_PORT     	GPIOA                      
+#define A_LED18_GPIO_CLK      	RCC_AHB1Periph_GPIOA
 
 /******************** B_LED ********************/
 
-#define B_LED1_PIN   					 GPIO_Pin_2
-#define B_LED1_GPIO_PORT       GPIOB                      
-#define B_LED1_GPIO_CLK        RCC_AHB1Periph_GPIOB
+#define B_LED1_PIN   					 GPIO_Pin_5
+#define B_LED1_GPIO_PORT       GPIOC                      
+#define B_LED1_GPIO_CLK        RCC_AHB1Periph_GPIOC
 
 #define B_LED2_PIN   					 GPIO_Pin_3
-#define B_LED2_GPIO_PORT       GPIOB                      
-#define B_LED2_GPIO_CLK        RCC_AHB1Periph_GPIOB
+#define B_LED2_GPIO_PORT       GPIOA                      
+#define B_LED2_GPIO_CLK        RCC_AHB1Periph_GPIOA
  
-#define B_LED3_PIN   					 GPIO_Pin_4
-#define B_LED3_GPIO_PORT       GPIOB                      
-#define B_LED3_GPIO_CLK        RCC_AHB1Periph_GPIOB
+#define B_LED3_PIN   					 GPIO_Pin_1
+#define B_LED3_GPIO_PORT       GPIOA                      
+#define B_LED3_GPIO_CLK        RCC_AHB1Periph_GPIOA
 
-#define B_LED4_PIN   					 GPIO_Pin_5
-#define B_LED4_GPIO_PORT       GPIOB                      
-#define B_LED4_GPIO_CLK        RCC_AHB1Periph_GPIOB
+#define B_LED4_PIN   					 GPIO_Pin_3
+#define B_LED4_GPIO_PORT       GPIOC                     
+#define B_LED4_GPIO_CLK        RCC_AHB1Periph_GPIOC
 
-#define B_LED5_PIN   					 GPIO_Pin_6
-#define B_LED5_GPIO_PORT       GPIOB                
-#define B_LED5_GPIO_CLK        RCC_AHB1Periph_GPIOB
+#define B_LED5_PIN   					 GPIO_Pin_10
+#define B_LED5_GPIO_PORT       GPIOF               
+#define B_LED5_GPIO_CLK        RCC_AHB1Periph_GPIOF
 
-#define B_LED6_PIN   					 GPIO_Pin_7
-#define B_LED6_GPIO_PORT       GPIOB                      
-#define B_LED6_GPIO_CLK        RCC_AHB1Periph_GPIOB
+#define B_LED6_PIN   					 GPIO_Pin_6
+#define B_LED6_GPIO_PORT       GPIOF                      
+#define B_LED6_GPIO_CLK        RCC_AHB1Periph_GPIOF
 
-#define B_LED7_PIN   					 GPIO_Pin_8
-#define B_LED7_GPIO_PORT       GPIOB                      
-#define B_LED7_GPIO_CLK        RCC_AHB1Periph_GPIOB
+#define B_LED7_PIN   					 GPIO_Pin_2
+#define B_LED7_GPIO_PORT       GPIOF                      
+#define B_LED7_GPIO_CLK        RCC_AHB1Periph_GPIOF
 
-#define B_LED8_PIN   					 GPIO_Pin_9
-#define B_LED8_GPIO_PORT       GPIOB                      
-#define B_LED8_GPIO_CLK        RCC_AHB1Periph_GPIOB
+#define B_LED8_PIN   					 GPIO_Pin_14
+#define B_LED8_GPIO_PORT       GPIOC                      
+#define B_LED8_GPIO_CLK        RCC_AHB1Periph_GPIOC
 
-#define B_LED9_PIN   					 GPIO_Pin_10
-#define B_LED9_GPIO_PORT       GPIOB                      
-#define B_LED9_GPIO_CLK        RCC_AHB1Periph_GPIOB
+#define B_LED9_PIN   					 GPIO_Pin_5
+#define B_LED9_GPIO_PORT       GPIOE                      
+#define B_LED9_GPIO_CLK        RCC_AHB1Periph_GPIOE
 
-#define B_LED10_PIN   				 GPIO_Pin_11
+#define B_LED10_PIN   				 GPIO_Pin_0
 #define B_LED10_GPIO_PORT      GPIOB                      
 #define B_LED10_GPIO_CLK       RCC_AHB1Periph_GPIOB
 
-#define B_LED11_PIN   				 GPIO_Pin_12
-#define B_LED11_GPIO_PORT      GPIOB                      
-#define B_LED11_GPIO_CLK       RCC_AHB1Periph_GPIOB
+#define B_LED11_PIN   				 GPIO_Pin_4
+#define B_LED11_GPIO_PORT      GPIOC                     
+#define B_LED11_GPIO_CLK       RCC_AHB1Periph_GPIOC
 
-#define B_LED12_PIN   				 GPIO_Pin_13
-#define B_LED12_GPIO_PORT      GPIOB                      
-#define B_LED12_GPIO_CLK       RCC_AHB1Periph_GPIOB
+#define B_LED12_PIN   				 GPIO_Pin_2
+#define B_LED12_GPIO_PORT      GPIOA                      
+#define B_LED12_GPIO_CLK       RCC_AHB1Periph_GPIOA
 
-#define B_LED13_PIN   				 GPIO_Pin_14
-#define B_LED13_GPIO_PORT      GPIOB                  
-#define B_LED13_GPIO_CLK       RCC_AHB1Periph_GPIOB
+#define B_LED13_PIN   				 GPIO_Pin_0
+#define B_LED13_GPIO_PORT      GPIOA                  
+#define B_LED13_GPIO_CLK       RCC_AHB1Periph_GPIOA
 
-#define B_LED14_PIN   				 GPIO_Pin_15
-#define B_LED14_GPIO_PORT      GPIOB                      
-#define B_LED14_GPIO_CLK       RCC_AHB1Periph_GPIOB
+#define B_LED14_PIN   				 GPIO_Pin_0
+#define B_LED14_GPIO_PORT      GPIOC                      
+#define B_LED14_GPIO_CLK       RCC_AHB1Periph_GPIOC
 
-#define B_LED15_PIN   				 GPIO_Pin_12
-#define B_LED15_GPIO_PORT      GPIOD                      
-#define B_LED15_GPIO_CLK       RCC_AHB1Periph_GPIOD	
+#define B_LED15_PIN   				 GPIO_Pin_7
+#define B_LED15_GPIO_PORT      GPIOF                      
+#define B_LED15_GPIO_CLK       RCC_AHB1Periph_GPIOF	
 
-#define B_LED16_PIN   				 GPIO_Pin_13
-#define B_LED16_GPIO_PORT      GPIOD                      
-#define B_LED16_GPIO_CLK       RCC_AHB1Periph_GPIOD
+#define B_LED16_PIN   				 GPIO_Pin_3
+#define B_LED16_GPIO_PORT      GPIOF                      
+#define B_LED16_GPIO_CLK       RCC_AHB1Periph_GPIOF
 
-#define B_LED17_PIN   				 GPIO_Pin_14
-#define B_LED17_GPIO_PORT      GPIOD                      
-#define B_LED17_GPIO_CLK       RCC_AHB1Periph_GPIOD
+#define B_LED17_PIN   				 GPIO_Pin_15
+#define B_LED17_GPIO_PORT      GPIOC                      
+#define B_LED17_GPIO_CLK       RCC_AHB1Periph_GPIOC
 
-#define B_LED18_PIN   				 GPIO_Pin_15
-#define B_LED18_GPIO_PORT      GPIOD                      
-#define B_LED18_GPIO_CLK       RCC_AHB1Periph_GPIOD
+#define B_LED18_PIN   				 GPIO_Pin_13
+#define B_LED18_GPIO_PORT      GPIOC                     
+#define B_LED18_GPIO_CLK       RCC_AHB1Periph_GPIOC
 
 
 /******************** C_LED ********************/
-#define C_LED1_PIN   					 GPIO_Pin_0
+#define C_LED1_PIN   					 GPIO_Pin_15
 #define C_LED1_GPIO_PORT       GPIOE                      
 #define C_LED1_GPIO_CLK        RCC_AHB1Periph_GPIOE
 
-#define C_LED2_PIN   					 GPIO_Pin_1
+#define C_LED2_PIN   					 GPIO_Pin_13
 #define C_LED2_GPIO_PORT       GPIOE                      
 #define C_LED2_GPIO_CLK        RCC_AHB1Periph_GPIOE
  
-#define C_LED3_PIN   					 GPIO_Pin_2
+#define C_LED3_PIN   					 GPIO_Pin_11
 #define C_LED3_GPIO_PORT       GPIOE                      
 #define C_LED3_GPIO_CLK        RCC_AHB1Periph_GPIOE
 
-#define C_LED4_PIN   					 GPIO_Pin_3
+#define C_LED4_PIN   					 GPIO_Pin_9
 #define C_LED4_GPIO_PORT       GPIOE                      
 #define C_LED4_GPIO_CLK        RCC_AHB1Periph_GPIOE
 
-#define C_LED5_PIN   					 GPIO_Pin_4
+#define C_LED5_PIN   					 GPIO_Pin_7
 #define C_LED5_GPIO_PORT       GPIOE               
 #define C_LED5_GPIO_CLK        RCC_AHB1Periph_GPIOE
 
-#define C_LED6_PIN   					 GPIO_Pin_5
-#define C_LED6_GPIO_PORT       GPIOE                      
-#define C_LED6_GPIO_CLK        RCC_AHB1Periph_GPIOE
+#define C_LED6_PIN   					 GPIO_Pin_15
+#define C_LED6_GPIO_PORT       GPIOF                      
+#define C_LED6_GPIO_CLK        RCC_AHB1Periph_GPIOF
 
-#define C_LED7_PIN   					 GPIO_Pin_6
-#define C_LED7_GPIO_PORT       GPIOE                      
-#define C_LED7_GPIO_CLK        RCC_AHB1Periph_GPIOE
+#define C_LED7_PIN   					 GPIO_Pin_13
+#define C_LED7_GPIO_PORT       GPIOF                      
+#define C_LED7_GPIO_CLK        RCC_AHB1Periph_GPIOF
 
-#define C_LED8_PIN   					 GPIO_Pin_7
-#define C_LED8_GPIO_PORT       GPIOE                      
-#define C_LED8_GPIO_CLK        RCC_AHB1Periph_GPIOE
+#define C_LED8_PIN   					 GPIO_Pin_11
+#define C_LED8_GPIO_PORT       GPIOF                      
+#define C_LED8_GPIO_CLK        RCC_AHB1Periph_GPIOF
 
-#define C_LED9_PIN   					 GPIO_Pin_8
-#define C_LED9_GPIO_PORT       GPIOE                      
-#define C_LED9_GPIO_CLK        RCC_AHB1Periph_GPIOE
+#define C_LED9_PIN   					 GPIO_Pin_1
+#define C_LED9_GPIO_PORT       GPIOB                      
+#define C_LED9_GPIO_CLK        RCC_AHB1Periph_GPIOB
 
-#define C_LED10_PIN   				 GPIO_Pin_9
-#define C_LED10_GPIO_PORT      GPIOE                     
-#define C_LED10_GPIO_CLK       RCC_AHB1Periph_GPIOE
+#define C_LED10_PIN   				 GPIO_Pin_10
+#define C_LED10_GPIO_PORT      GPIOB                     
+#define C_LED10_GPIO_CLK       RCC_AHB1Periph_GPIOB
 
-#define C_LED11_PIN   				 GPIO_Pin_10
+#define C_LED11_PIN   				 GPIO_Pin_14
 #define C_LED11_GPIO_PORT      GPIOE                      
 #define C_LED11_GPIO_CLK       RCC_AHB1Periph_GPIOE
 
-#define C_LED12_PIN   				 GPIO_Pin_11
+#define C_LED12_PIN   				 GPIO_Pin_12
 #define C_LED12_GPIO_PORT      GPIOE                      
 #define C_LED12_GPIO_CLK       RCC_AHB1Periph_GPIOE
 
-#define C_LED13_PIN   				 GPIO_Pin_12
+#define C_LED13_PIN   				 GPIO_Pin_10
 #define C_LED13_GPIO_PORT      GPIOE                  
 #define C_LED13_GPIO_CLK       RCC_AHB1Periph_GPIOE
 
-#define C_LED14_PIN   				 GPIO_Pin_13
+#define C_LED14_PIN   				 GPIO_Pin_8
 #define C_LED14_GPIO_PORT      GPIOE                     
 #define C_LED14_GPIO_CLK       RCC_AHB1Periph_GPIOE
 
-#define C_LED15_PIN   				 GPIO_Pin_14
-#define C_LED15_GPIO_PORT      GPIOE                      
-#define C_LED15_GPIO_CLK       RCC_AHB1Periph_GPIOE
+#define C_LED15_PIN   				 GPIO_Pin_0
+#define C_LED15_GPIO_PORT      GPIOG                      
+#define C_LED15_GPIO_CLK       RCC_AHB1Periph_GPIOG
 
-#define C_LED16_PIN   				 GPIO_Pin_15
-#define C_LED16_GPIO_PORT      GPIOE                     
-#define C_LED16_GPIO_CLK       RCC_AHB1Periph_GPIOE
+#define C_LED16_PIN   				 GPIO_Pin_14
+#define C_LED16_GPIO_PORT      GPIOF                     
+#define C_LED16_GPIO_CLK       RCC_AHB1Periph_GPIOF
 
-#define C_LED17_PIN   				 GPIO_Pin_0
+#define C_LED17_PIN   				 GPIO_Pin_12
 #define C_LED17_GPIO_PORT      GPIOF                      
 #define C_LED17_GPIO_CLK       RCC_AHB1Periph_GPIOF
 
-#define C_LED18_PIN   				 GPIO_Pin_1
-#define C_LED18_GPIO_PORT      GPIOF                      
-#define C_LED18_GPIO_CLK       RCC_AHB1Periph_GPIOF
+#define C_LED18_PIN   				 GPIO_Pin_2
+#define C_LED18_GPIO_PORT      GPIOB                      
+#define C_LED18_GPIO_CLK       RCC_AHB1Periph_GPIOB
 
 
 /******************** D_LED ********************/
-#define D_LED1_PIN   					 GPIO_Pin_2
-#define D_LED1_GPIO_PORT       GPIOF                      
-#define D_LED1_GPIO_CLK        RCC_AHB1Periph_GPIOF
+#define D_LED1_PIN   					 GPIO_Pin_1
+#define D_LED1_GPIO_PORT       GPIOC                      
+#define D_LED1_GPIO_CLK        RCC_AHB1Periph_GPIOC
 
-#define D_LED2_PIN   					 GPIO_Pin_3
+#define D_LED2_PIN   					 GPIO_Pin_8
 #define D_LED2_GPIO_PORT       GPIOF                      
 #define D_LED2_GPIO_CLK        RCC_AHB1Periph_GPIOF
  
@@ -239,65 +238,65 @@
 #define D_LED3_GPIO_PORT       GPIOF                      
 #define D_LED3_GPIO_CLK        RCC_AHB1Periph_GPIOF
 
-#define D_LED4_PIN   					 GPIO_Pin_5
+#define D_LED4_PIN   					 GPIO_Pin_0
 #define D_LED4_GPIO_PORT       GPIOF                      
 #define D_LED4_GPIO_CLK        RCC_AHB1Periph_GPIOF
 
-#define D_LED5_PIN   					 GPIO_Pin_6
-#define D_LED5_GPIO_PORT       GPIOF               
-#define D_LED5_GPIO_CLK        RCC_AHB1Periph_GPIOF
+#define D_LED5_PIN   					 GPIO_Pin_4
+#define D_LED5_GPIO_PORT       GPIOE              
+#define D_LED5_GPIO_CLK        RCC_AHB1Periph_GPIOE
 
-#define D_LED6_PIN   					 GPIO_Pin_7
-#define D_LED6_GPIO_PORT       GPIOF                      
-#define D_LED6_GPIO_CLK        RCC_AHB1Periph_GPIOF
+#define D_LED6_PIN   					 GPIO_Pin_2
+#define D_LED6_GPIO_PORT       GPIOE                      
+#define D_LED6_GPIO_CLK        RCC_AHB1Periph_GPIOE
 
-#define D_LED7_PIN   					 GPIO_Pin_8
-#define D_LED7_GPIO_PORT       GPIOF                      
-#define D_LED7_GPIO_CLK        RCC_AHB1Periph_GPIOF
+#define D_LED7_PIN   					 GPIO_Pin_0
+#define D_LED7_GPIO_PORT       GPIOE                      
+#define D_LED7_GPIO_CLK        RCC_AHB1Periph_GPIOE
 
-#define D_LED8_PIN   					 GPIO_Pin_9
-#define D_LED8_GPIO_PORT       GPIOF                      
-#define D_LED8_GPIO_CLK        RCC_AHB1Periph_GPIOF
+#define D_LED8_PIN   					 GPIO_Pin_8
+#define D_LED8_GPIO_PORT       GPIOB                      
+#define D_LED8_GPIO_CLK        RCC_AHB1Periph_GPIOB
 
-#define D_LED9_PIN   					 GPIO_Pin_10
-#define D_LED9_GPIO_PORT       GPIOF                      
-#define D_LED9_GPIO_CLK        RCC_AHB1Periph_GPIOF
+#define D_LED9_PIN   					 GPIO_Pin_7
+#define D_LED9_GPIO_PORT       GPIOB                      
+#define D_LED9_GPIO_CLK        RCC_AHB1Periph_GPIOB
 
-#define D_LED10_PIN   				 GPIO_Pin_11
-#define D_LED10_GPIO_PORT      GPIOF                     
-#define D_LED10_GPIO_CLK       RCC_AHB1Periph_GPIOF
+#define D_LED10_PIN   				 GPIO_Pin_2
+#define D_LED10_GPIO_PORT      GPIOC                    
+#define D_LED10_GPIO_CLK       RCC_AHB1Periph_GPIOC
 
-#define D_LED11_PIN   				 GPIO_Pin_12
+#define D_LED11_PIN   				 GPIO_Pin_9
 #define D_LED11_GPIO_PORT      GPIOF                     
 #define D_LED11_GPIO_CLK       RCC_AHB1Periph_GPIOF
 
-#define D_LED12_PIN   				 GPIO_Pin_13
+#define D_LED12_PIN   				 GPIO_Pin_5
 #define D_LED12_GPIO_PORT      GPIOF                     
 #define D_LED12_GPIO_CLK       RCC_AHB1Periph_GPIOF
 
-#define D_LED13_PIN   				 GPIO_Pin_14
+#define D_LED13_PIN   				 GPIO_Pin_1
 #define D_LED13_GPIO_PORT      GPIOF                 
 #define D_LED13_GPIO_CLK       RCC_AHB1Periph_GPIOF
 
-#define D_LED14_PIN   				 GPIO_Pin_15
-#define D_LED14_GPIO_PORT      GPIOF                    
-#define D_LED14_GPIO_CLK       RCC_AHB1Periph_GPIOF
+#define D_LED14_PIN   				 GPIO_Pin_6
+#define D_LED14_GPIO_PORT      GPIOE                    
+#define D_LED14_GPIO_CLK       RCC_AHB1Periph_GPIOE
 
-#define D_LED15_PIN   				 GPIO_Pin_0
-#define D_LED15_GPIO_PORT      GPIOG                     
-#define D_LED15_GPIO_CLK       RCC_AHB1Periph_GPIOG
+#define D_LED15_PIN   				 GPIO_Pin_3
+#define D_LED15_GPIO_PORT      GPIOE                    
+#define D_LED15_GPIO_CLK       RCC_AHB1Periph_GPIOE
 
 #define D_LED16_PIN   				 GPIO_Pin_1
-#define D_LED16_GPIO_PORT      GPIOG                     
-#define D_LED16_GPIO_CLK       RCC_AHB1Periph_GPIOG
+#define D_LED16_GPIO_PORT      GPIOE                     
+#define D_LED16_GPIO_CLK       RCC_AHB1Periph_GPIOE
 
-#define D_LED17_PIN   				 GPIO_Pin_2
-#define D_LED17_GPIO_PORT      GPIOG                     
-#define D_LED17_GPIO_CLK       RCC_AHB1Periph_GPIOG
+#define D_LED17_PIN   				 GPIO_Pin_9
+#define D_LED17_GPIO_PORT      GPIOB                    
+#define D_LED17_GPIO_CLK       RCC_AHB1Periph_GPIOB
 
-#define D_LED18_PIN   				 GPIO_Pin_3
-#define D_LED18_GPIO_PORT      GPIOG                     
-#define D_LED18_GPIO_CLK       RCC_AHB1Periph_GPIOG
+#define D_LED18_PIN   				 GPIO_Pin_6
+#define D_LED18_GPIO_PORT      GPIOB                     
+#define D_LED18_GPIO_CLK       RCC_AHB1Periph_GPIOB
 /************************************************************/
 
 void LED_GPIO_Config(void);

+ 1 - 9
APP/HARDWARE/includes/sys_data.h

@@ -1,8 +1,6 @@
 #ifndef __SYS_DATA_H
 #define __SYS_DATA_H
 
-
-
 #include "usart.h"
 #include "stm32f2xx.h"
 #include "string.h"
@@ -16,19 +14,13 @@ typedef struct
 {
   uint32_t             	rxIndex;  
   uint8_t               rxBuf[_USART3_RXSIZE];
-  uint32_t              rxTime;
   uint8_t               txBusy;
-  uint32_t              timeout; 
 	uint8_t								done; 
 }USART_MSG_t;
 
 extern USART_MSG_t usartMsg;
 extern uint8_t result;
-void call_back();
-// UPDATA
-uint8_t updata(void);
-
-
+void call_back(void);
 
 uint8_t channel_LED(uint8_t channel, int i);
 uint8_t channel_12VBAT(uint8_t channel, int i);

+ 12 - 63
APP/HARDWARE/includes/usart.h

@@ -7,73 +7,22 @@
 
 
 
-//#define USART_BAUDRATE                    	9600 //눔왯꺼景쪽
+#define USART_BAUDRATE                    	9600 //눔왯꺼景쪽
 
-//#define USART3_RX_GPIO_PORT                GPIOD
-//#define USART3_RX_GPIO_CLK                 RCC_AHB1Periph_GPIOD
-//#define USART3_RX_PIN                     GPIO_Pin_8
-//#define USART3_RX_AF                       GPIO_AF_USART3
-//#define USART3_RX_SOURCE                   GPIO_PinSource8
+#define USART3_RX_GPIO_PORT                GPIOD
+#define USART3_RX_GPIO_CLK                 RCC_AHB1Periph_GPIOD
+#define USART3_RX_PIN                    	 GPIO_Pin_8
+#define USART3_RX_AF                       GPIO_AF_USART3
+#define USART3_RX_SOURCE                   GPIO_PinSource8
 
-//#define USART3_TX_GPIO_PORT                GPIOD
-//#define USART3_TX_GPIO_CLK                 RCC_AHB1Periph_GPIOD
-//#define USART3_TX_PIN                      GPIO_Pin_9
-//#define USART3_TX_AF                       GPIO_AF_USART3
-//#define USART3_TX_SOURCE                   GPIO_PinSource9
-
-//232多신땍屢
-#define USART_232                             USART1
-#define USART_232_CLK                         RCC_APB2Periph_USART1
-#define USART_232_BAUDRATE                    115200  //눔왯꺼景쪽
-
-#define USART_232_RX_GPIO_PORT                GPIOA
-#define USART_232_RX_GPIO_CLK                 RCC_AHB1Periph_GPIOA
-#define USART_232_RX_PIN                      GPIO_Pin_10
-#define USART_232_RX_AF                       GPIO_AF_USART1
-#define USART_232_RX_SOURCE                   GPIO_PinSource10
-
-#define USART_232_TX_GPIO_PORT                GPIOA
-#define USART_232_TX_GPIO_CLK                 RCC_AHB1Periph_GPIOA
-#define USART_232_TX_PIN                      GPIO_Pin_9
-#define USART_232_TX_AF                       GPIO_AF_USART1
-#define USART_232_TX_SOURCE                   GPIO_PinSource9
-
-#define USART_232_IRQHandler                  USART1_IRQHandler
-#define USART_232_IRQ                 				USART1_IRQn
+#define USART3_TX_GPIO_PORT                GPIOD
+#define USART3_TX_GPIO_CLK                 RCC_AHB1Periph_GPIOD
+#define USART3_TX_PIN                      GPIO_Pin_9
+#define USART3_TX_AF                       GPIO_AF_USART3
+#define USART3_TX_SOURCE                   GPIO_PinSource9
 
+#define USART_232                             USART3
 void USART3_config(void);
 
 
-
-// 꿎桿刻절
-void USART_485_config(void);
-void USART_485_DE_TX(void);
-void USART_485_DE_RX(void);
-
-
-//485多신땍屢
-#define USART_485                             USART3
-#define USART_485_CLK                         RCC_APB1Periph_USART3 
-#define USART_485_BAUDRATE                    9600 //눔왯꺼景쪽
-
-#define USART_485_RX_GPIO_PORT                GPIOC
-#define USART_485_RX_GPIO_CLK                 RCC_AHB1Periph_GPIOC
-#define USART_485_RX_PIN                      GPIO_Pin_11
-#define USART_485_RX_AF                       GPIO_AF_USART3
-#define USART_485_RX_SOURCE                   GPIO_PinSource11
-
-#define USART_485_TX_GPIO_PORT                GPIOC
-#define USART_485_TX_GPIO_CLK                 RCC_AHB1Periph_GPIOC
-#define USART_485_TX_PIN                      GPIO_Pin_10
-#define USART_485_TX_AF                       GPIO_AF_USART3
-#define USART_485_TX_SOURCE                   GPIO_PinSource10
-
-#define USART_485_IRQHandler                  USART3_IRQHandler
-#define USART_485_IRQ                 				USART3_IRQn
-//485왠齡多신
-#define USART_485_DE_GPIO_PORT 								GPIOC
-#define USART_485_DE_GPIO_CLK									RCC_AHB1Periph_GPIOC
-#define USART_485_DE_PIN											GPIO_Pin_12
-
-
 #endif /* __USART1_H */

+ 56 - 19
APP/HARDWARE/sources/bat.c

@@ -1,47 +1,84 @@
 #include "bat.h"
 
-void GPIO_C_Config(void)
+void BAT_GPIOA_Config(void)
+{		
+		GPIO_InitTypeDef GPIO_InitStructure;
+		RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOA, ENABLE); 	
+		GPIO_InitStructure.GPIO_Pin =	GPIO_Pin_8;		
+		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   
+    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;   
+    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
+		GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
+		GPIO_Init(GPIOA, &GPIO_InitStructure);
+}
+
+void BAT_GPIOB_Config(void)
+{		
+		GPIO_InitTypeDef GPIO_InitStructure;
+		RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOB, ENABLE); 	
+		GPIO_InitStructure.GPIO_Pin =	GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;		
+		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   
+    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;   
+    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
+		GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
+		GPIO_Init(GPIOB, &GPIO_InitStructure);
+}
+void BAT_GPIOC_Config(void)
 {		
 		GPIO_InitTypeDef GPIO_InitStructure;
 		RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOC, ENABLE); 	
-		GPIO_InitStructure.GPIO_Pin =	GPIO_Pin_All;		
+		GPIO_InitStructure.GPIO_Pin =	GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;		
 		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;   
-    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
+    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
 		GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
 		GPIO_Init(GPIOC, &GPIO_InitStructure);
 }
-
-static void GPIO_D_Config(void)
+void BAT_GPIOD_Config(void)
 {		
 		GPIO_InitTypeDef GPIO_InitStructure;
 		RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOD, ENABLE); 	
-		GPIO_InitStructure.GPIO_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;		
+		GPIO_InitStructure.GPIO_Pin =	GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;		
 		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;   
-    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
+    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
 		GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
 		GPIO_Init(GPIOD, &GPIO_InitStructure);
 }
-
+void BAT_GPIOG_Config(void)
+{		
+		GPIO_InitTypeDef GPIO_InitStructure;
+		RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOG, ENABLE); 	
+		GPIO_InitStructure.GPIO_Pin =	GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | 
+																	GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8;		
+		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   
+    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;   
+    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
+		GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
+		GPIO_Init(GPIOG, &GPIO_InitStructure);
+}
 
 void BAT_12V_Config()
 {
-	GPIO_C_Config();
-	GPIO_D_Config();
+	BAT_GPIOA_Config();
+	BAT_GPIOB_Config();
+	BAT_GPIOC_Config();
+	BAT_GPIOD_Config();
+	BAT_GPIOG_Config();
+	
 }
 
 void BAT_5V_Config()
 {
-	GPIO_InitTypeDef GPIO_InitStructure;
-	RCC_AHB1PeriphClockCmd (EVM_5V_CLK, ENABLE); 	
-	GPIO_InitStructure.GPIO_Pin =	EVM_5V_PIN;		
-	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   
-	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;   
-	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
-	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
-	GPIO_Init(EVM_5V_PORT, &GPIO_InitStructure);
+		GPIO_InitTypeDef GPIO_InitStructure;
+		RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOA, ENABLE); 	
+		GPIO_InitStructure.GPIO_Pin =GPIO_Pin_12;		
+		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   
+    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;   
+    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
+		GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
+		GPIO_Init(GPIOA, &GPIO_InitStructure);
+		GPIO_SetBits(GPIOA,GPIO_Pin_12);
 }
 
 

+ 2 - 2
APP/HARDWARE/sources/bat_function.c

@@ -49,11 +49,11 @@ uint8_t channel_5VBAT(uint8_t cmd)
 	switch(cmd)
 	{
 		case 1:
-			GPIO_SetBits(GPIOD,GPIO_Pin_10);
+			GPIO_SetBits(GPIOA,GPIO_Pin_12);
 			result = 1;
 			break;
 		case 2:
-			GPIO_ResetBits(GPIOD,GPIO_Pin_10);
+			GPIO_ResetBits(GPIOA,GPIO_Pin_12);
 			result = 1;
 			break;
 		default:

+ 8 - 9
APP/HARDWARE/sources/delay.c

@@ -4,7 +4,12 @@
 
 #if TIMER
 #include "timer.h"
-#endif
+void delay_ms(uint32_t nms)
+{	 
+	 uint32_t start_time = TIM7->CNT; // 获取当前定时器计数值
+   while ((TIM7->CNT - start_time) < nms); // 等待经过指定的延时时间
+}
+#else
 
 static u8  fac_us=0;							//us延时倍乘数			   
 static u16 fac_ms=0;							//ms延时倍乘数
@@ -43,12 +48,6 @@ void delay_us(u32 nus)
 //对72M条件下,nms<=1864 
 void delay_ms(uint32_t nms)
 {	
-#if TIMER
-	 
-	 uint32_t start_time = TIM7->CNT; // 获取当前定时器计数值
-   while ((TIM7->CNT - start_time) < nms); // 等待经过指定的延时时间
-
-#else	
 	u32 temp;		   
 	SysTick->LOAD=(u32)nms*fac_ms;				//时间加载(SysTick->LOAD为24bit)
 	SysTick->VAL =0x00;							//清空计数器
@@ -59,6 +58,6 @@ void delay_ms(uint32_t nms)
 	}while((temp&0x01)&&!(temp&(1<<16)));		//等待时间到达   
 	SysTick->CTRL&=~SysTick_CTRL_ENABLE_Msk;	//关闭计数器
 	SysTick->VAL =0X00;       					//清空计数器	 
-#endif	
+	
 } 
-
+#endif

+ 39 - 27
APP/HARDWARE/sources/led.c

@@ -1,85 +1,97 @@
 #include "led.h"
 
-void GPIO_A_Config(void)
+void LED_GPIOA_Config(void)
 {		
 		GPIO_InitTypeDef GPIO_InitStructure;
-		RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOF, ENABLE); 
-		GPIO_InitStructure.GPIO_Pin =	GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 |GPIO_Pin_8 |GPIO_Pin_9 |
-																 GPIO_Pin_10 | GPIO_Pin_11| GPIO_Pin_12|GPIO_Pin_13 |GPIO_Pin_14|GPIO_Pin_15;		
+		RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOA, ENABLE); 
+		GPIO_InitStructure.GPIO_Pin =	GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_15;		
 		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
-    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; 
+    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; 
 		GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
 		GPIO_Init(GPIOA, &GPIO_InitStructure);
 }
 
-void GPIO_B_Config(void)
+void LED_GPIOB_Config(void)
 {		
 		GPIO_InitTypeDef GPIO_InitStructure;
 		RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOB, ENABLE); 
-		GPIO_InitStructure.GPIO_Pin =	GPIO_Pin_All;		
+		GPIO_InitStructure.GPIO_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 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 ;		
 		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
-    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; 
+    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; 
 		GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
 		GPIO_Init(GPIOB, &GPIO_InitStructure);
 }
 
-static void GPIO_D_Config(void)
+void LED_GPIOC_Config(void)
+{		
+		GPIO_InitTypeDef GPIO_InitStructure;
+		RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOC, ENABLE); 
+		GPIO_InitStructure.GPIO_Pin =	GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 |
+																	GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15 ;		
+		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   
+    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
+    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; 
+		GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
+		GPIO_Init(GPIOC, &GPIO_InitStructure);
+}
+void LED_GPIOD_Config(void)
 {		
 		GPIO_InitTypeDef GPIO_InitStructure;
 		RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOD, ENABLE); 
-		GPIO_InitStructure.GPIO_Pin =	GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;		
+		GPIO_InitStructure.GPIO_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;		
 		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
-    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; 
+    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; 
 		GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
 		GPIO_Init(GPIOD, &GPIO_InitStructure);
 }
-
-void GPIO_E_Config(void)
+void LED_GPIOE_Config(void)
 {		
 		GPIO_InitTypeDef GPIO_InitStructure;
 		RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOE, ENABLE); 
 		GPIO_InitStructure.GPIO_Pin =	GPIO_Pin_All;		
 		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
-    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; 
+    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; 
 		GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
 		GPIO_Init(GPIOE, &GPIO_InitStructure);
 }
-void GPIO_F_Config(void)
+void LED_GPIOF_Config(void)
 {		
 		GPIO_InitTypeDef GPIO_InitStructure;
 		RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOF, ENABLE); 
 		GPIO_InitStructure.GPIO_Pin =	GPIO_Pin_All;		
 		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
-    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; 
+    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; 
 		GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
 		GPIO_Init(GPIOF, &GPIO_InitStructure);
 }
-void GPIO_G_Config(void)
+void LED_GPIOG_Config(void)
 {		
 		GPIO_InitTypeDef GPIO_InitStructure;
 		RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOG, ENABLE); 
-		GPIO_InitStructure.GPIO_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;	
+		GPIO_InitStructure.GPIO_Pin =	GPIO_Pin_0 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 ;	
 		GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;   
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
-    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; 
+    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; 
 		GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
 		GPIO_Init(GPIOG, &GPIO_InitStructure);
 }
 // LED³õʼ»¯
 void LED_GPIO_Config()
 {
-	GPIO_A_Config();
-	GPIO_B_Config();
-	GPIO_D_Config();
-	GPIO_E_Config();
-	GPIO_F_Config();
-	GPIO_G_Config();
+	LED_GPIOA_Config();
+	LED_GPIOB_Config();
+	LED_GPIOC_Config();
+	LED_GPIOD_Config();
+	LED_GPIOE_Config();
+	LED_GPIOF_Config();
+	LED_GPIOG_Config();
 }
 /*
 *********************************************************************************************************
@@ -268,4 +280,4 @@ uint8_t all_light(uint8_t cmd)
 	all_red_light(cmd);
 	all_yellow_light(cmd);
 	return 1;
-}
+}

+ 184 - 79
APP/HARDWARE/sources/sys_data.c

@@ -1,8 +1,56 @@
 #include "sys_data.h"
 #include "led.h"
 #include "usart.h"
+#include "time.h"
 
 USART_MSG_t usartMsg;
+static const uint16_t wCRCTable[] =
+    {
+        0X0000, 0XC0C1, 0XC181, 0X0140, 0XC301, 0X03C0, 0X0280, 0XC241,
+        0XC601, 0X06C0, 0X0780, 0XC741, 0X0500, 0XC5C1, 0XC481, 0X0440,
+        0XCC01, 0X0CC0, 0X0D80, 0XCD41, 0X0F00, 0XCFC1, 0XCE81, 0X0E40,
+        0X0A00, 0XCAC1, 0XCB81, 0X0B40, 0XC901, 0X09C0, 0X0880, 0XC841,
+        0XD801, 0X18C0, 0X1980, 0XD941, 0X1B00, 0XDBC1, 0XDA81, 0X1A40,
+        0X1E00, 0XDEC1, 0XDF81, 0X1F40, 0XDD01, 0X1DC0, 0X1C80, 0XDC41,
+        0X1400, 0XD4C1, 0XD581, 0X1540, 0XD701, 0X17C0, 0X1680, 0XD641,
+        0XD201, 0X12C0, 0X1380, 0XD341, 0X1100, 0XD1C1, 0XD081, 0X1040,
+        0XF001, 0X30C0, 0X3180, 0XF141, 0X3300, 0XF3C1, 0XF281, 0X3240,
+        0X3600, 0XF6C1, 0XF781, 0X3740, 0XF501, 0X35C0, 0X3480, 0XF441,
+        0X3C00, 0XFCC1, 0XFD81, 0X3D40, 0XFF01, 0X3FC0, 0X3E80, 0XFE41,
+        0XFA01, 0X3AC0, 0X3B80, 0XFB41, 0X3900, 0XF9C1, 0XF881, 0X3840,
+        0X2800, 0XE8C1, 0XE981, 0X2940, 0XEB01, 0X2BC0, 0X2A80, 0XEA41,
+        0XEE01, 0X2EC0, 0X2F80, 0XEF41, 0X2D00, 0XEDC1, 0XEC81, 0X2C40,
+        0XE401, 0X24C0, 0X2580, 0XE541, 0X2700, 0XE7C1, 0XE681, 0X2640,
+        0X2200, 0XE2C1, 0XE381, 0X2340, 0XE101, 0X21C0, 0X2080, 0XE041,
+        0XA001, 0X60C0, 0X6180, 0XA141, 0X6300, 0XA3C1, 0XA281, 0X6240,
+        0X6600, 0XA6C1, 0XA781, 0X6740, 0XA501, 0X65C0, 0X6480, 0XA441,
+        0X6C00, 0XACC1, 0XAD81, 0X6D40, 0XAF01, 0X6FC0, 0X6E80, 0XAE41,
+        0XAA01, 0X6AC0, 0X6B80, 0XAB41, 0X6900, 0XA9C1, 0XA881, 0X6840,
+        0X7800, 0XB8C1, 0XB981, 0X7940, 0XBB01, 0X7BC0, 0X7A80, 0XBA41,
+        0XBE01, 0X7EC0, 0X7F80, 0XBF41, 0X7D00, 0XBDC1, 0XBC81, 0X7C40,
+        0XB401, 0X74C0, 0X7580, 0XB541, 0X7700, 0XB7C1, 0XB681, 0X7640,
+        0X7200, 0XB2C1, 0XB381, 0X7340, 0XB101, 0X71C0, 0X7080, 0XB041,
+        0X5000, 0X90C1, 0X9181, 0X5140, 0X9301, 0X53C0, 0X5280, 0X9241,
+        0X9601, 0X56C0, 0X5780, 0X9741, 0X5500, 0X95C1, 0X9481, 0X5440,
+        0X9C01, 0X5CC0, 0X5D80, 0X9D41, 0X5F00, 0X9FC1, 0X9E81, 0X5E40,
+        0X5A00, 0X9AC1, 0X9B81, 0X5B40, 0X9901, 0X59C0, 0X5880, 0X9841,
+        0X8801, 0X48C0, 0X4980, 0X8941, 0X4B00, 0X8BC1, 0X8A81, 0X4A40,
+        0X4E00, 0X8EC1, 0X8F81, 0X4F40, 0X8D01, 0X4DC0, 0X4C80, 0X8C41,
+        0X4400, 0X84C1, 0X8581, 0X4540, 0X8701, 0X47C0, 0X4680, 0X8641,
+        0X8201, 0X42C0, 0X4380, 0X8341, 0X4100, 0X81C1, 0X8081, 0X4040};
+// crc校验
+uint16_t Checkcrc16(const uint8_t *nData, uint16_t wLength)
+{
+  uint8_t nTemp;
+  uint16_t wCRCWord = 0xFFFF;
+  while (wLength--)
+  {
+    nTemp = *nData++ ^ wCRCWord;
+    wCRCWord >>= 8;
+    wCRCWord ^= wCRCTable[nTemp];
+  }
+  return wCRCWord;
+}
 uint8_t result ;
 // 校验码
 unsigned char CheckXor(const uint8_t *strData,int len)  
@@ -72,94 +120,151 @@ int sendCmd(uint8_t *data, uint16_t size)
 // 文件更新升级
 uint8_t updata()
 {
-	
-	return 1;
+	uint16_t crc;	
+	uint8_t databuf[1024];
+	uint16_t packId = 0x01;
+	uint8_t i = 30,c = 0x63,ack = 0x06,nack = 0x15;
+	// 发送第一个'c'
+	sendCmd(&c,1);
+	//检测 3s 内有无收到数据
+	for(int i = 0; i  < 3000; i++)
+	{
+		delay_ms(1);
+		// 收到数据,跳转到处理数据
+		if(usartMsg.done == 1)
+		{
+			goto __start;
+		}
+	}
+	//3s 内未收到第一包数据,再发送'c'
+	sendCmd(&c,1);
+
+__start:	
+	// 开始处理数据
+	// 当数据包为EOT(0x04),表示结束
+	while(usartMsg.done == 1 && usartMsg.rxBuf[0] != 0x04)
+	{
+		// 检测帧头
+		if(usartMsg.rxBuf[0] != 0x02)
+		{
+			sendCmd(&nack,1);
+			goto __start;
+		}
+		// 检测包序列
+		if(usartMsg.rxBuf[1] != packId)
+		{
+			sendCmd(&nack,1);
+			goto __start;
+		}
+		// 检测包号反码
+		if(usartMsg.rxBuf[2] != ~packId)
+		{
+			sendCmd(&nack,1);
+			goto __start;
+		}
+		// 提取数据包
+		for(int i = 0; i < 1024; i++)
+		{
+			databuf[i] = usartMsg.rxBuf[3 + i];
+		}
+		crc = Checkcrc16(databuf, 1024);
+		// 检测数据包的校验码
+		if (((crc & 0x00FF) != usartMsg.rxBuf[1028]) || (((crc & 0xFF00) >> 8) != usartMsg.rxBuf[1027]))
+		{	
+			sendCmd(&nack,1);	
+			goto __start;
+		}
+		// 准备接收下一包数据
+		sendCmd(&ack,1);
+		packId += 1;
+	}
+		// 接收到结束信号,反馈ack
+		sendCmd(&ack,1);
+	if(packId != 0)
+		return 1;
+	else
+		return 2;
 }
 
 void broad_to_host()
 {
-			int i, j;
-			result = 2;// 初始化为 2 表示操作失败(硬件故障或其他原因)
-			// 反馈信息
-			uint8_t txData[8];
-			// 校验位验证信息
-			uint8_t crc[1 + (4 * usartMsg.rxBuf[4])];
-				
-			
+		int i, j;
+		result = 2;// 初始化为 2 表示操作失败(硬件故障或其他原因)
+		// 反馈信息
+		uint8_t txData[8];
+		// 校验位验证信息
+		uint8_t crc[1 + (4 * usartMsg.rxBuf[4])];
+						
 		// 判断帧头帧尾
-			if(usartMsg.rxBuf[0] != 0xAA || usartMsg.rxBuf[1] != 0xFF || usartMsg.rxBuf[2] != 0x55  || usartMsg.rxBuf[3] != 0xCC|| usartMsg.rxBuf[10 + (4 * (usartMsg.rxBuf[4] - 1))] != 0xDD || usartMsg.rxBuf[11 + (4 * (usartMsg.rxBuf[4] - 1))] != 0xFF)
-			{
-					result = 0x04;//帧头/帧尾异常
-					goto __feedback;
-			}
+		if(usartMsg.rxBuf[0] != 0xAA || usartMsg.rxBuf[1] != 0xFF || usartMsg.rxBuf[2] != 0x55  || usartMsg.rxBuf[3] != 0xCC|| usartMsg.rxBuf[10 + (4 * (usartMsg.rxBuf[4] - 1))] != 0xDD || usartMsg.rxBuf[11 + (4 * (usartMsg.rxBuf[4] - 1))] != 0xFF)
+		{
+				result = 0x04;//帧头/帧尾异常
+				goto __feedback;
+		}
 			
-			// 判断指令数
-			if(usartMsg.rxBuf[4] < 1 || usartMsg.rxBuf[4] > 255)
-			{
-					result = 5;//帧内容异常(指令值超出范围等)
-					goto __feedback;
-			}
+		// 判断指令数
+		if(usartMsg.rxBuf[4] < 1 || usartMsg.rxBuf[4] > 255)
+		{
+				result = 5;//帧内容异常(指令值超出范围等)
+				goto __feedback;
+		}
+		
+		// 判断校验位	
+		// 提取指令数
+		crc[0] = usartMsg.rxBuf[4];				
+		// 提取指令码、channel、平台号、指令值	
+		for(j = 0; j < usartMsg.rxBuf[4] * 4;j += 4)
+		{
+				crc[1 + j] = usartMsg.rxBuf[5+ j];//指令码
+				crc[2 + j] = usartMsg.rxBuf[6+ j];//channel
+				crc[3 + j] = usartMsg.rxBuf[7+ j];//平台号
+				crc[4 + j] = usartMsg.rxBuf[8+ j];//指令值
+		}
+		if((CheckXor(crc,1 + (4 * usartMsg.rxBuf[4])) != usartMsg.rxBuf[9 + (4 * (usartMsg.rxBuf[4] - 1))]))
+		{
+				result = 0x03;//校验位异常
+				goto __feedback;
+		}
 			
-			// 判断校验位	
-			// 提取指令数
-			crc[0] = usartMsg.rxBuf[4];				
-			// 提取指令码、channel、平台号、指令值	
-			for(j = 0; j < usartMsg.rxBuf[4] * 4;j += 4)
+		// 执行指令
+		for(i = 0; i < usartMsg.rxBuf[4] * 4;i += 4)
+		{
+			// 判断指令码
+			switch (usartMsg.rxBuf[5 + i])
 			{
-					crc[1 + j] = usartMsg.rxBuf[5+ j];//指令码
-					crc[2 + j] = usartMsg.rxBuf[6+ j];//channel
-					crc[3 + j] = usartMsg.rxBuf[7+ j];//平台号
-					crc[4 + j] = usartMsg.rxBuf[8+ j];//指令值
-			}
-			if((CheckXor(crc,1 + (4 * usartMsg.rxBuf[4])) != usartMsg.rxBuf[9 + (4 * (usartMsg.rxBuf[4] - 1))]))
-			{
-					result = 0x03;//校验位异常
-					goto __feedback;
-			}
-				
-			// 执行指令
-			for(i = 0; i < usartMsg.rxBuf[4] * 4;i += 4)
-			{
-				// 判断指令码
-				switch (usartMsg.rxBuf[5 + i])
-				{
-					case 0x01: // LED指令
-						result = channel_LED(usartMsg.rxBuf[6 + i], i);
-						if(result != 1)	goto __feedback;
-							break;
-						
-					case 0x02: // 12V BAT指令
-						result = channel_12VBAT(usartMsg.rxBuf[6 + i], i);
-						if(result != 1)	goto __feedback;
-							break;
-						
-					case 0x03: // 5V BAT指令 channel和平台号固定为0x00
-						result = channel_5VBAT(usartMsg.rxBuf[8 + i]);
-						if(result != 1)goto __feedback;
-							break;
-						
-					case 0x04: // updata指令
-						if(usartMsg.rxBuf[8] == 1)
-						{
-							result = updata();
-						}
+				case 0x01: // LED指令
+					result = channel_LED(usartMsg.rxBuf[6 + i], i);
+					if(result != 1)	goto __feedback;
 						break;
-						
-					default:
-						result = 0x05;//帧内容异常(指令值超出范围等)
-						goto __feedback;
+					
+				case 0x02: // 12V BAT指令
+					result = channel_12VBAT(usartMsg.rxBuf[6 + i], i);
+					if(result != 1)	goto __feedback;
 						break;
-				}
-			}	
-						
+					
+				case 0x03: // 5V BAT指令 channel和平台号固定为0x00
+					result = channel_5VBAT(usartMsg.rxBuf[8 + i]);
+					if(result != 1)goto __feedback;
+						break;
+					
+				case 0x04: // updata指令
+					if(usartMsg.rxBuf[8] == 1)
+						result = updata();	
+					break;				
+				default:
+					result = 0x05;//帧内容异常(指令值超出范围等)
+					goto __feedback;
+			}
+		}	
+					
 __feedback:		
-			txData[0] = 0xBB;	// 帧头
-			txData[1] = 0xFF;	// 帧头
-			txData[2] = 0x55;	// 帧头
-			txData[3] = 0xCC;	// 帧头
-			txData[4] = result;	// 反馈值		 
-			txData[5] = CheckXor(&txData[4], 1);	// 校验位
-			txData[6] = 0xEE;	// 帧尾
-			txData[7] = 0xFF;	// 帧尾	
-			sendCmd(txData,8);
+		txData[0] = 0xBB;	// 帧头
+		txData[1] = 0xFF;	// 帧头
+		txData[2] = 0x55;	// 帧头
+		txData[3] = 0xCC;	// 帧头
+		txData[4] = result;	// 反馈值		 
+		txData[5] = CheckXor(&txData[4], 1);	// 校验位
+		txData[6] = 0xEE;	// 帧尾
+		txData[7] = 0xFF;	// 帧尾	
+		sendCmd(txData,8);
 }

+ 26 - 66
APP/HARDWARE/sources/usart.c

@@ -19,95 +19,55 @@ int fgetc(FILE *f)
 
 		return (int)USART_ReceiveData(USART_232);
 }
-
-// USART3的初始化
-//void USART3_config()
-//{
-//	USART_InitTypeDef USART_InitStruct;
-//  GPIO_InitTypeDef GPIO_InitStruct;
-
-//	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
-//  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
-//	
-//	GPIO_PinAFConfig(USART3_RX_GPIO_PORT, USART3_RX_SOURCE, USART3_RX_AF);
-//  GPIO_PinAFConfig(USART3_TX_GPIO_PORT, USART3_TX_SOURCE, USART3_TX_AF);
-//	
-//  GPIO_InitStruct.GPIO_Pin = USART3_TX_PIN ;
-//  GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
-//  GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
-//  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
-//  GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
-//  GPIO_Init(GPIOC, &GPIO_InitStruct);
-//	
-//  GPIO_InitStruct.GPIO_Pin = USART3_RX_PIN;
-//	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
-//	GPIO_Init(GPIOC, &GPIO_InitStruct);
-
-
-//  USART_InitStruct.USART_BaudRate = USART_BAUDRATE;
-//  USART_InitStruct.USART_WordLength = USART_WordLength_8b;
-//  USART_InitStruct.USART_StopBits = USART_StopBits_1;
-//  USART_InitStruct.USART_Parity = USART_Parity_No;
-//  USART_InitStruct.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
-//  USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
-//  USART_Init(USART3, &USART_InitStruct);
-
-//  USART_Cmd(USART3, ENABLE);
-//	
-//	USART_ClearFlag(USART3, USART_FLAG_TC);
-//	USART_ITConfig(USART3,USART_IT_RXNE,ENABLE);
-//	USART_ITConfig(USART3,USART_IT_IDLE,ENABLE);
-//	
-//	NVIC_InitTypeDef NVIC_InitStruct;
-//	NVIC_InitStruct.NVIC_IRQChannel = USART3_IRQn;
-//	NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0;
-//	NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0;
-//	NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
-
-//	NVIC_Init(&NVIC_InitStruct);
-//}
-
+//USART3的初始化
 void USART3_config()
 {
 	USART_InitTypeDef USART_InitStruct;
   GPIO_InitTypeDef GPIO_InitStruct;
+
+	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
+  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
 	
-  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
-	RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
-	
-	GPIO_PinAFConfig(USART_232_RX_GPIO_PORT, USART_232_RX_SOURCE, USART_232_RX_AF);
-  GPIO_PinAFConfig(USART_232_TX_GPIO_PORT, USART_232_TX_SOURCE, USART_232_TX_AF);	
+	GPIO_PinAFConfig(USART3_RX_GPIO_PORT, USART3_RX_SOURCE, USART3_RX_AF);
+  GPIO_PinAFConfig(USART3_TX_GPIO_PORT, USART3_TX_SOURCE, USART3_TX_AF);
 	
-  GPIO_InitStruct.GPIO_Pin = USART_232_RX_PIN | USART_232_TX_PIN; 
+  GPIO_InitStruct.GPIO_Pin = USART3_TX_PIN ;
   GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
   GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
-  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;
+  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
   GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
-  GPIO_Init(GPIOA, &GPIO_InitStruct);
+  GPIO_Init(GPIOD, &GPIO_InitStruct);
 	
-  USART_InitStruct.USART_BaudRate = USART_232_BAUDRATE;
+  GPIO_InitStruct.GPIO_Pin = USART3_RX_PIN;
+	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
+	GPIO_Init(GPIOD, &GPIO_InitStruct);
+
+
+  USART_InitStruct.USART_BaudRate = USART_BAUDRATE;
   USART_InitStruct.USART_WordLength = USART_WordLength_8b;
   USART_InitStruct.USART_StopBits = USART_StopBits_1;
   USART_InitStruct.USART_Parity = USART_Parity_No;
   USART_InitStruct.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
   USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
-  USART_Init(USART_232, &USART_InitStruct);
+  USART_Init(USART3, &USART_InitStruct);
+
+  USART_Cmd(USART3, ENABLE);
 	
-  USART_Cmd(USART_232, ENABLE);
-	USART_ClearFlag(USART1, USART_FLAG_TC);	
-	USART_ITConfig(USART_232,USART_IT_RXNE,ENABLE);
-	USART_ITConfig(USART_232,USART_IT_IDLE,ENABLE);
+	USART_ClearFlag(USART3, USART_FLAG_TC);
+	USART_ITConfig(USART3,USART_IT_RXNE,ENABLE);
+	USART_ITConfig(USART3,USART_IT_IDLE,ENABLE);
 	
- // 配置USART1接收中断优先级
 	NVIC_InitTypeDef NVIC_InitStruct;
-	NVIC_InitStruct.NVIC_IRQChannel = USART1_IRQn;
+	NVIC_InitStruct.NVIC_IRQChannel = USART3_IRQn;
 	NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0;
 	NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0;
 	NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
-	NVIC_Init(&NVIC_InitStruct);	
+
+	NVIC_Init(&NVIC_InitStruct);
 }
 
+
 // USART3的中断函数
-void USART_232_IRQHandler(){	
+void USART3_IRQHandler(){	
 	call_back();
 }

+ 27 - 25
APP/MDKProject/project.uvoptx

@@ -99,7 +99,7 @@
         <sRSysVw>1</sRSysVw>
         <tRSysVw>1</tRSysVw>
         <sRunDeb>0</sRunDeb>
-        <sLrtime>0</sLrtime>
+        <sLrtime>1</sLrtime>
         <bEvRecOn>1</bEvRecOn>
         <bSchkAxf>0</bSchkAxf>
         <bTchkAxf>0</bTchkAxf>
@@ -117,6 +117,11 @@
         <pMon>BIN\CMSIS_AGDI.dll</pMon>
       </DebugOpt>
       <TargetDriverDllRegistry>
+        <SetRegEntry>
+          <Number>0</Number>
+          <Key>DLGDARM</Key>
+          <Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)</Name>
+        </SetRegEntry>
         <SetRegEntry>
           <Number>0</Number>
           <Key>DLGUARM</Key>
@@ -140,12 +145,12 @@
         <SetRegEntry>
           <Number>0</Number>
           <Key>ARMDBGFLAGS</Key>
-          <Name></Name>
+          <Name>-T0</Name>
         </SetRegEntry>
         <SetRegEntry>
           <Number>0</Number>
           <Key>CMSIS_AGDI</Key>
-          <Name>-X"WCH CMSIS-DAP" -UECBF8F0671A4 -O206 -S10 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F2xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F207ZGTx$CMSIS\Flash\STM32F2xx_1024.FLM)</Name>
+          <Name>-X"WCH CMSIS-DAP" -UECBF8F0671A4 -O206 -S7 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F2xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F207ZGTx$CMSIS\Flash\STM32F2xx_1024.FLM)</Name>
         </SetRegEntry>
         <SetRegEntry>
           <Number>0</Number>
@@ -153,31 +158,28 @@
           <Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F2xx_1024 -FS08000000 -FL0100000 -FP0($$Device:STM32F207ZGTx$CMSIS\Flash\STM32F2xx_1024.FLM))</Name>
         </SetRegEntry>
       </TargetDriverDllRegistry>
-      <Breakpoint/>
+      <Breakpoint>
+        <Bp>
+          <Number>0</Number>
+          <Type>0</Type>
+          <LineNumber>112</LineNumber>
+          <EnabledFlag>1</EnabledFlag>
+          <Address>134224748</Address>
+          <ByteObject>0</ByteObject>
+          <HtxType>0</HtxType>
+          <ManyObjects>0</ManyObjects>
+          <SizeOfObject>0</SizeOfObject>
+          <BreakByAccess>0</BreakByAccess>
+          <BreakIfRCount>1</BreakIfRCount>
+          <Filename>C:\Users\IBM\Desktop\proje\HARDWARE\sources\led.c</Filename>
+          <ExecCommand></ExecCommand>
+          <Expression>\\lora_gateway\../HARDWARE/sources/led.c\112</Expression>
+        </Bp>
+      </Breakpoint>
       <WatchWindow1>
         <Ww>
           <count>0</count>
           <WinNumber>1</WinNumber>
-          <ItemText>http_data</ItemText>
-        </Ww>
-        <Ww>
-          <count>1</count>
-          <WinNumber>1</WinNumber>
-          <ItemText>path</ItemText>
-        </Ww>
-        <Ww>
-          <count>2</count>
-          <WinNumber>1</WinNumber>
-          <ItemText>"0:",0x0A</ItemText>
-        </Ww>
-        <Ww>
-          <count>3</count>
-          <WinNumber>1</WinNumber>
-          <ItemText>mqtt_connectFlag,0x0A</ItemText>
-        </Ww>
-        <Ww>
-          <count>4</count>
-          <WinNumber>1</WinNumber>
           <ItemText>usartMsg</ItemText>
         </Ww>
       </WatchWindow1>
@@ -236,7 +238,7 @@
         <EnableFlashSeq>0</EnableFlashSeq>
         <EnableLog>0</EnableLog>
         <Protocol>2</Protocol>
-        <DbgClock>2000000</DbgClock>
+        <DbgClock>5000</DbgClock>
       </DebugDescription>
     </TargetOption>
   </Target>

+ 2 - 2
APP/MDKProject/project.uvprojx

@@ -111,8 +111,8 @@
         <DllOption>
           <SimDllName>SARMCM3.DLL</SimDllName>
           <SimDllArguments> -REMAP -MPU</SimDllArguments>
-          <SimDlgDll>DCM.DLL</SimDlgDll>
-          <SimDlgDllArguments>-pCM3</SimDlgDllArguments>
+          <SimDlgDll>DARMSTM.DLL</SimDlgDll>
+          <SimDlgDllArguments>-pSTM32F207ZG</SimDlgDllArguments>
           <TargetDllName>SARMCM3.DLL</TargetDllName>
           <TargetDllArguments> -MPU</TargetDllArguments>
           <TargetDlgDll>TCM.DLL</TargetDlgDll>

+ 11 - 15
APP/USER/main.c

@@ -10,39 +10,35 @@
 int main(void)
 {
 	// LED硬件初始化
-//	LED_GPIO_Config();
+	LED_GPIO_Config();
 	// 12V电源初始化
-//	BAT_12V_Config();
+	BAT_12V_Config();
 	// 5V电源初始化
-//	BAT_5V_Config();
+	BAT_5V_Config();
 	// USART3初始化
 	USART3_config();
-	// 测试串口
-//	USART_485_config();
 	// 定时器初始化
 	timer_config();
-	IWDG_Configuration(5000);// 参数单位ms
+// 设置看门狗 3S
+//	IWDG_Configuration(3000);// 参数单位ms 范围 0~0x0FFF
 	
 	while(1)
 	{
 		if(usartMsg.done == 1)
 		{		
 			broad_to_host();
-			delay_ms(1000);
+			delay_ms(100);
 		}
-		IWDG_feed();
+//		IWDG_feed();
 	}
-  
 }
 
 void assert_failed(uint8_t* file, uint32_t line)
 {
-  /* User can add his own implementation to report the file name and line number,
-     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
-
   /* Infinite loop */
- // while (1)
- //{}
-//	printf("Wrong parameters value: file %s on line %d\r\n", __FILE__, __LINE__);
+//  while (1)
+//	{
+//		printf("Wrong parameters value: file %s on line %d\r\n", __FILE__, __LINE__);
+//	}
 }