Procházet zdrojové kódy

Signed-off-by: zhuhongbin <kptzhu@163.com>temp

zhuhongbin před 2 roky
rodič
revize
0b6acf696a
23 změnil soubory, kde provedl 111 přidání a 102 odebrání
  1. 1 1
      Inc/dma.h
  2. 1 1
      Inc/gpio.h
  3. 1 1
      Inc/iwdg.h
  4. 1 1
      Inc/rtc.h
  5. 1 0
      Inc/stm32f1xx_it.h
  6. 1 1
      Inc/usart.h
  7. 1 1
      Src/dma.c
  8. 1 1
      Src/gpio.c
  9. 1 1
      Src/iwdg.c
  10. 13 10
      Src/main.c
  11. 1 1
      Src/rtc.c
  12. 15 0
      Src/stm32f1xx_it.c
  13. 6 1
      Src/usart.c
  14. 1 0
      test.ioc
  15. 4 1
      tmr/buffer.c
  16. 6 3
      tmr/button.c
  17. 12 3
      tmr/display.c
  18. 2 0
      tmr/display.h
  19. 4 3
      tmr/flash.c
  20. 1 0
      tmr/flash.h
  21. 3 0
      tmr/init.c
  22. 33 71
      tmr/plan.c
  23. 1 1
      tmr/weight.c

+ 1 - 1
Inc/dma.h

@@ -6,7 +6,7 @@
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; Copyright (c) 2022 STMicroelectronics.
+  * <h2><center>&copy; Copyright (c) 2023 STMicroelectronics.
   * All rights reserved.</center></h2>
   *
   * This software component is licensed by ST under BSD 3-Clause license,

+ 1 - 1
Inc/gpio.h

@@ -6,7 +6,7 @@
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; Copyright (c) 2022 STMicroelectronics.
+  * <h2><center>&copy; Copyright (c) 2023 STMicroelectronics.
   * All rights reserved.</center></h2>
   *
   * This software component is licensed by ST under BSD 3-Clause license,

+ 1 - 1
Inc/iwdg.h

@@ -6,7 +6,7 @@
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; Copyright (c) 2022 STMicroelectronics.
+  * <h2><center>&copy; Copyright (c) 2023 STMicroelectronics.
   * All rights reserved.</center></h2>
   *
   * This software component is licensed by ST under BSD 3-Clause license,

+ 1 - 1
Inc/rtc.h

@@ -6,7 +6,7 @@
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; Copyright (c) 2022 STMicroelectronics.
+  * <h2><center>&copy; Copyright (c) 2023 STMicroelectronics.
   * All rights reserved.</center></h2>
   *
   * This software component is licensed by ST under BSD 3-Clause license,

+ 1 - 0
Inc/stm32f1xx_it.h

@@ -63,6 +63,7 @@ void USART1_IRQHandler(void);
 void USART2_IRQHandler(void);
 void USART3_IRQHandler(void);
 void UART4_IRQHandler(void);
+void UART5_IRQHandler(void);
 void DMA2_Channel3_IRQHandler(void);
 void DMA2_Channel4_5_IRQHandler(void);
 /* USER CODE BEGIN EFP */

+ 1 - 1
Inc/usart.h

@@ -6,7 +6,7 @@
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; Copyright (c) 2022 STMicroelectronics.
+  * <h2><center>&copy; Copyright (c) 2023 STMicroelectronics.
   * All rights reserved.</center></h2>
   *
   * This software component is licensed by ST under BSD 3-Clause license,

+ 1 - 1
Src/dma.c

@@ -6,7 +6,7 @@
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; Copyright (c) 2022 STMicroelectronics.
+  * <h2><center>&copy; Copyright (c) 2023 STMicroelectronics.
   * All rights reserved.</center></h2>
   *
   * This software component is licensed by ST under BSD 3-Clause license,

+ 1 - 1
Src/gpio.c

@@ -6,7 +6,7 @@
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; Copyright (c) 2022 STMicroelectronics.
+  * <h2><center>&copy; Copyright (c) 2023 STMicroelectronics.
   * All rights reserved.</center></h2>
   *
   * This software component is licensed by ST under BSD 3-Clause license,

+ 1 - 1
Src/iwdg.c

@@ -6,7 +6,7 @@
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; Copyright (c) 2022 STMicroelectronics.
+  * <h2><center>&copy; Copyright (c) 2023 STMicroelectronics.
   * All rights reserved.</center></h2>
   *
   * This software component is licensed by ST under BSD 3-Clause license,

+ 13 - 10
Src/main.c

@@ -163,6 +163,7 @@ int main(void)
   /* USER CODE BEGIN 2 */
   rt_show_version();  
 
+
  /* 使能备份时钟:备份寄存器 */
 	__HAL_RCC_BKP_CLK_ENABLE();
 	HAL_PWR_EnableBkUpAccess();
@@ -191,26 +192,28 @@ int main(void)
 	output2_off();
 	pwr_lock_on();
 	AT_on();
-
-  rt_kprintf("\n \\ | /\n");
+  rt_kprintf("\n \\ | /\n");	
 	rt_sem_take(thread_init_sem, RT_WAITING_FOREVER);   //等待初始化进程完毕
 //			 init_allflash();
 //			 beep();			
 //			 rt_sem_take(thread_init_sem, RT_WAITING_FOREVER);   //等待初始化进程完毕
 	if (WeightConst_SBType == 4)
 	{
+		init_allflash();
+		__HAL_RCC_CLEAR_RESET_FLAGS();
 		if (HAL_GPIO_ReadPin(B2_GPIO_Port, B2_Pin) > 0)
 		{
 			beep();			
 			rt_thread_mdelay(1000);
-			if (HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin)> 0 && HAL_GPIO_ReadPin(B2_GPIO_Port, B2_Pin) > 0)
-			{
-				 init_allflash();
-				 __HAL_RCC_CLEAR_RESET_FLAGS();
-				 beep();			
-				 rt_sem_take(thread_init_sem, RT_WAITING_FOREVER);   
-			}
-			else if (HAL_GPIO_ReadPin(B2_GPIO_Port, B2_Pin) > 0)
+//			if (HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin)> 0 && HAL_GPIO_ReadPin(B2_GPIO_Port, B2_Pin) > 0)
+//			{
+//				 init_allflash();
+//				 __HAL_RCC_CLEAR_RESET_FLAGS();
+//				 beep();			
+//				 rt_sem_take(thread_init_sem, RT_WAITING_FOREVER);   
+//			}
+//			else
+				if (HAL_GPIO_ReadPin(B2_GPIO_Port, B2_Pin) > 0)
 			{
 				if (WeightConst_SBType == 6) WeightConst_SBType = 1;
 				inMenu = 1;			

+ 1 - 1
Src/rtc.c

@@ -6,7 +6,7 @@
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; Copyright (c) 2022 STMicroelectronics.
+  * <h2><center>&copy; Copyright (c) 2023 STMicroelectronics.
   * All rights reserved.</center></h2>
   *
   * This software component is licensed by ST under BSD 3-Clause license,

+ 15 - 0
Src/stm32f1xx_it.c

@@ -69,6 +69,7 @@ extern DMA_HandleTypeDef hdma_usart2_tx;
 extern DMA_HandleTypeDef hdma_usart3_rx;
 extern DMA_HandleTypeDef hdma_usart3_tx;
 extern UART_HandleTypeDef huart4;
+extern UART_HandleTypeDef huart5;
 extern UART_HandleTypeDef huart1;
 extern UART_HandleTypeDef huart2;
 extern UART_HandleTypeDef huart3;
@@ -311,6 +312,20 @@ void UART4_IRQHandler(void)
   /* USER CODE END UART4_IRQn 1 */
 }
 
+/**
+  * @brief This function handles UART5 global interrupt.
+  */
+void UART5_IRQHandler(void)
+{
+  /* USER CODE BEGIN UART5_IRQn 0 */
+
+  /* USER CODE END UART5_IRQn 0 */
+  HAL_UART_IRQHandler(&huart5);
+  /* USER CODE BEGIN UART5_IRQn 1 */
+
+  /* USER CODE END UART5_IRQn 1 */
+}
+
 /**
   * @brief This function handles DMA2 channel3 global interrupt.
   */

+ 6 - 1
Src/usart.c

@@ -6,7 +6,7 @@
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; Copyright (c) 2022 STMicroelectronics.
+  * <h2><center>&copy; Copyright (c) 2023 STMicroelectronics.
   * All rights reserved.</center></h2>
   *
   * This software component is licensed by ST under BSD 3-Clause license,
@@ -239,6 +239,9 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
     GPIO_InitStruct.Pull = GPIO_NOPULL;
     HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
 
+    /* UART5 interrupt Init */
+    HAL_NVIC_SetPriority(UART5_IRQn, 0, 0);
+    HAL_NVIC_EnableIRQ(UART5_IRQn);
   /* USER CODE BEGIN UART5_MspInit 1 */
 
   /* USER CODE END UART5_MspInit 1 */
@@ -477,6 +480,8 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
 
     HAL_GPIO_DeInit(GPIOD, GPIO_PIN_2);
 
+    /* UART5 interrupt Deinit */
+    HAL_NVIC_DisableIRQ(UART5_IRQn);
   /* USER CODE BEGIN UART5_MspDeInit 1 */
 
   /* USER CODE END UART5_MspDeInit 1 */

+ 1 - 0
test.ioc

@@ -163,6 +163,7 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
 NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:false\:false\:false
 NVIC.UART4_IRQn=true\:1\:0\:true\:false\:true\:true\:true
+NVIC.UART5_IRQn=true\:0\:0\:false\:false\:true\:true\:true
 NVIC.USART1_IRQn=true\:1\:0\:true\:false\:true\:true\:true
 NVIC.USART2_IRQn=true\:1\:0\:true\:false\:true\:true\:true
 NVIC.USART3_IRQn=true\:1\:0\:true\:false\:true\:true\:true

+ 4 - 1
tmr/buffer.c

@@ -314,7 +314,10 @@ void RX(void) {
                                 XbeeConst_CanSend=0x01;//取消无线发送锁定	
                             }
                         }
-
+												else if (dataframehead.data.frameType == 0xAA && isnewLora==1) { //1号键回复
+                            rt_sem_release(displayRemote_lock);																	
+					                  rt_sem_release(sendLora_lock);
+                        }
                         else if (dataframehead.data.frameType == 0x11 ) { //1号键回复
                             if (XbeeConst_FRxBuf0[XbeeConst_FrameLength0-1] == XbeeConst_FrameNumLast) {	
 															  save_read_ts('k');																									

+ 6 - 3
tmr/button.c

@@ -101,7 +101,8 @@ static void CheckMenuButton_entry(void *parameter) {
 								if (XbeeConst_NetAddress>0) XbeeConst_NetAddress--;  
 								else
 								{
-										if (WeightConst_SBType==4) XbeeConst_NetAddress=2; else XbeeConst_NetAddress=13;
+										//if (WeightConst_SBType==4) XbeeConst_NetAddress=2; else 
+									  XbeeConst_NetAddress=13;
 								}										
 								setNetAddress();
 								write_Flash("WL", &XbeeConst_NetAddress, sizeof(XbeeConst_NetAddress));
@@ -185,7 +186,8 @@ static void CheckMenuButton_entry(void *parameter) {
 						{
 								if (XbeeConst_NetAddress<13 && (WeightConst_SBType!=4&&WeightConst_SBType!=6))
 										XbeeConst_NetAddress++;
-								else if (XbeeConst_NetAddress<2 && (WeightConst_SBType==4))
+							//	else if (XbeeConst_NetAddress<2 && (WeightConst_SBType==4))
+								else if (WeightConst_SBType==4)
 										XbeeConst_NetAddress++;
 								else
 										XbeeConst_NetAddress=0;
@@ -465,7 +467,8 @@ static void CheckButton_entry(void *parameter) {
 				if (button_state.b4>=5)	button_state.b4 = 0;
 				
 				if (button_state.b7>=15)	button_state.b7 = 0;
-				if (WeightConst_SBType == 3 && isnewBan==1)
+				if //(WeightConst_SBType == 3 &&
+					(isnewBan==1)
 				{					
 					if ((HAL_GPIO_ReadPin(pwr_GPIO_Port, pwr_Pin) == 0) ) {
 						rt_thread_mdelay(2000);

+ 12 - 3
tmr/display.c

@@ -12,6 +12,8 @@
 #include "xBeeAppEscapingMode.h"
 
 rt_sem_t display_lock = RT_NULL;
+rt_sem_t displayRemote_lock = RT_NULL;
+rt_sem_t sendLora_lock = RT_NULL;
 struct rt_event display_event;
 
 uint8_t MenuItem=0; //µ±Ç°²Ëµ¥
@@ -520,6 +522,13 @@ static void sendRemote(void *parameter)
 	{
     if (RemoteSendDisplay == 1 )
     {
+				if (XbeeConst_UseAPI==0 && isnewLora==1) {     
+				  rt_sem_take(displayRemote_lock, RT_WAITING_FOREVER);	
+				  rt_thread_mdelay((XbeeConst_DeviceAddress-1)*80);
+			  } else if (XbeeConst_UseAPI<4)
+					{rt_thread_mdelay(500);	}	 
+			  else {rt_thread_mdelay(250);}
+		
         if ((flag_uart2_send==0 && (XbeeConst_UseAPI==1 || XbeeConst_UseAPI>=3))||
                 (flag_uart3_send==0 && XbeeConst_UseAPI==0))
         {
@@ -627,6 +636,7 @@ static void sendRemote(void *parameter)
             {
 							if (iscowweight<1 )
 							{
+								
 							  rt_sem_take(uart3_lock, RT_WAITING_FOREVER);
                 for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_FRemoteTxBuf[0]; SendWifi_i++)  //½«»º³åÇø·¢³ö
                     usart3_send_data[SendWifi_i-1] = XbeeConst_FRemoteTxBuf[SendWifi_i];							
@@ -638,9 +648,8 @@ static void sendRemote(void *parameter)
             }
         }
     }
-		 if (XbeeConst_UseAPI<4)
-		rt_thread_mdelay(500);
-		 else rt_thread_mdelay(250);
+		 
+		
 	}
 }
 

+ 2 - 0
tmr/display.h

@@ -19,6 +19,8 @@
 #define EVENT_Stop (1 << 15)
 
 extern rt_sem_t display_lock;
+extern rt_sem_t displayRemote_lock;
+extern rt_sem_t sendLora_lock;
 extern struct rt_event display_event;
 extern unsigned char RemoteSendDisplay;
 extern unsigned char WeightConst_displayTotal;

+ 4 - 3
tmr/flash.c

@@ -11,8 +11,9 @@ uint8_t  isCC = 0 ;
 uint8_t  isBLE =0;  //用蓝牙传输
 uint8_t  isNsmall =0;  //新小屏
 uint8_t  isnewBan =1;  //隔离主板
+uint8_t  isnewLora =1;  //用lora协议
 const uint8_t  isTag = 0 ; //是否含识读标签
-unsigned char  isn = 1;  //是否新大屏
+unsigned char  isn = 0;  //是否新大屏
 unsigned char  remote_sumweight = 0;  //远程是否包含重量
 unsigned char  iscowweight = 0;  //是否奶牛秤
 unsigned char eid[10];    //电子耳标,0为长度
@@ -20,10 +21,10 @@ unsigned char eid[10];    //
 uint8_t XbeeConst_DeviceAddress = 0x01;         
 uint8_t XbeeConst_NetAddress = 0x00;
 uint8_t XbeeConst_UseAPI = 0x01;
-uint8_t WeightConst_TQ = 0x05;//0x05;
+uint8_t WeightConst_TQ = 0x03;//0x05;
 uint8_t WeightConst_BLE = 0;
 uint8_t WeightConst_ChanCheShu = 0x02;
-uint8_t WeightConst_SBType = 0x03;
+uint8_t WeightConst_SBType = 0x01;
 
 int16_t WeightConst_WeightBegin = -3000;    //按键开始重量
 

+ 1 - 0
tmr/flash.h

@@ -4,6 +4,7 @@
 
 extern uint8_t  isCC;
 extern uint8_t  isTag; //ÊÇ·ñº¬Ê¶¶Á±êÇ©
+extern uint8_t  isnewLora;  //ÓÃloraЭÒé
 
 extern struct fdb_kvdb kvdb;
 extern struct fdb_tsdb ts_keydb;

+ 3 - 0
tmr/init.c

@@ -45,6 +45,9 @@ void thread_init(void)
   	delay_key_sem = rt_sem_create("delay_key_sem", 0, RT_IPC_FLAG_FIFO);
 	
 		weight_lock = rt_sem_create("weight_lock", 1, RT_IPC_FLAG_FIFO);
+	  displayRemote_lock = rt_sem_create("displayRemote_lock", 1, RT_IPC_FLAG_FIFO); 	
+	  sendLora_lock = rt_sem_create("sendLora_lock", 1, RT_IPC_FLAG_FIFO); 
+	
 	  display_lock = rt_sem_create("display_lock", 1, RT_IPC_FLAG_FIFO); 
 	  rt_event_init(&display_event, "display_event", RT_IPC_FLAG_FIFO);	
 	  

+ 33 - 71
tmr/plan.c

@@ -650,10 +650,24 @@ void getTargetWeight(void)
     	*/
 }
 
+void sendWifi_buf(uint8_t *buf){
+	if (XbeeConst_UseAPI==0 && isnewLora==1) {     
+		 rt_sem_take(sendLora_lock, RT_WAITING_FOREVER);					
+		 rt_thread_mdelay((XbeeConst_DeviceAddress-1)*50);
+	}
+	rt_sem_take(uart2_lock, RT_WAITING_FOREVER);
+	
+  for (int SendWifi_i = 1; SendWifi_i <= buf[0]; SendWifi_i++)  //将缓冲区发出
+		usart2_send_data[SendWifi_i-1] = buf[SendWifi_i];
+
+	HAL_UART_Transmit_DMA(&huart2, usart2_send_data, buf[0]);		
+	rt_thread_mdelay(50);							
+	rt_sem_release(uart2_lock);	
+}
 
 void SendWifi_entry(void *parameter) {
    while (1) 
-	 {
+	 {	
 			if ((XbeeConst_needRetry>(40+XbeeConst_DeviceAddress)) && XbeeConst_CanSend==0) {  //需要2秒后重发
 					if ((XbeeConst_FTxBuf0[4]&0xF0) == 0xF0) {
 							XbeeConst_FTxBuf0[4]=XbeeConst_FTxBuf0[4]-16;
@@ -669,26 +683,10 @@ void SendWifi_entry(void *parameter) {
 							setSendFrame_t(XbeeConst_FTxBuf0[4]==0xF8 || XbeeConst_FTxBuf0[4]==0xE8,0x00,0xC0);
 					//	  setSendFrame_t(1,0x00,0xC0);
 							XbeeConst_PTxBuf0 = xBeeApp2MakeFrame(&userSendFrame_t, XbeeConst_FTxBuf0);
-							for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_PTxBuf0[0]; SendWifi_i++)  //将缓冲区发出
-									usart2_send_data[SendWifi_i-1] = XbeeConst_PTxBuf0[SendWifi_i];
-						
-//	{								
-//											usart2_send_data[SendWifi_i-1] = XbeeConst_PTxBuf0[SendWifi_i];
-//	 rt_kprintf(" %02X",usart2_send_data[SendWifi_i-1]);
-//}
-//		rt_kprintf("\n");	
-							HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_PTxBuf0[0]);
-							rt_thread_mdelay(50);							
-						  rt_sem_release(uart2_lock);
+              sendWifi_buf(XbeeConst_PTxBuf0);
 					}
 					else{
-						  rt_sem_take(uart2_lock, RT_WAITING_FOREVER);
-							for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_FTxBuf0[0]; SendWifi_i++)  //将缓冲区发出
-									usart2_send_data[SendWifi_i-1] = XbeeConst_FTxBuf0[SendWifi_i];
-						  
-							HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_FTxBuf0[0]);
-							rt_thread_mdelay(50);							
-						  rt_sem_release(uart2_lock);
+              sendWifi_buf(XbeeConst_FTxBuf0);
 					}
 
 					XbeeConst_needRetry = 0;  //重置重发定时计数
@@ -701,30 +699,14 @@ void SendWifi_entry(void *parameter) {
 							XbeeConst_CanSend = 0; //锁定无线不可发送直至解锁
 							XbeeConst_needRetry = 0;  //重置重发定时计数
 							XbeeConst_FrameNumLast = XbeeConst_FTxBuf0[XbeeConst_FTxBuf0[0]-1];
-							if (XbeeConst_UseAPI>0) {								
-									rt_sem_take(uart2_lock, RT_WAITING_FOREVER);								
+							if (XbeeConst_UseAPI>0) {	
 									setSendFrame_t(XbeeConst_FTxBuf0[4]==0xF8,0x00,0xC0);
 									XbeeConst_PTxBuf0 = xBeeApp2MakeFrame(&userSendFrame_t, XbeeConst_FTxBuf0);									
-
-									for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_PTxBuf0[0]; SendWifi_i++)  //将缓冲区发出
-										 usart2_send_data[SendWifi_i-1] = XbeeConst_PTxBuf0[SendWifi_i];									
-//	{								
-//											usart2_send_data[SendWifi_i-1] = XbeeConst_PTxBuf0[SendWifi_i];
-//	 rt_kprintf(" %02X",usart2_send_data[SendWifi_i-1]);
-//}
-//		rt_kprintf("\n");		
-									HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_PTxBuf0[0]);
-							    rt_thread_mdelay(50);							
-									rt_sem_release(uart2_lock);
+                  sendWifi_buf(XbeeConst_PTxBuf0);
 							}
 							else
 							{
-								  rt_sem_take(uart2_lock, RT_WAITING_FOREVER);
-									for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_FTxBuf0[0]; SendWifi_i++)  //将缓冲区发出
-											usart2_send_data[SendWifi_i-1] = XbeeConst_FTxBuf0[SendWifi_i];
-									HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_FTxBuf0[0]);
-							    rt_thread_mdelay(50);							
-									rt_sem_release(uart2_lock);
+                 sendWifi_buf(XbeeConst_FTxBuf0);
 							}
 					}
 			}
@@ -733,24 +715,13 @@ void SendWifi_entry(void *parameter) {
 							XbeeConst_CanSend = 0; //锁定无线不可发送直至解锁
 							XbeeConst_needRetry = 0;  //重置重发定时计数
 							XbeeConst_FrameNumLast = XbeeConst_FTxBuf0[XbeeConst_FTxBuf0[0]-1];						
-							if (XbeeConst_UseAPI>0) {									
-									rt_sem_take(uart2_lock, RT_WAITING_FOREVER);						
+							if (XbeeConst_UseAPI>0) {				
 									setSendFrame_t(XbeeConst_FTxBuf0[4]==0xF8,0x00,0xC0);
-									XbeeConst_PTxBuf0 = xBeeApp2MakeFrame(&userSendFrame_t, XbeeConst_FTxBuf0);
-									for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_PTxBuf0[0]; SendWifi_i++)  //将缓冲区发出								
-											usart2_send_data[SendWifi_i-1] = XbeeConst_PTxBuf0[SendWifi_i];
-					
-                  HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_PTxBuf0[0]);							
-									rt_thread_mdelay(50);							
-									rt_sem_release(uart2_lock);								
+									XbeeConst_PTxBuf0 = xBeeApp2MakeFrame(&userSendFrame_t, XbeeConst_FTxBuf0);									
+                  sendWifi_buf(XbeeConst_PTxBuf0);
 							}
-							else{
-									rt_sem_take(uart2_lock, RT_WAITING_FOREVER);
-									for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_FTxBuf0[0]; SendWifi_i++)  //将缓冲区发出
-										usart2_send_data[SendWifi_i-1] = XbeeConst_FTxBuf0[SendWifi_i];			
-									HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_FTxBuf0[0]);							
-									rt_thread_mdelay(50);							
-									rt_sem_release(uart2_lock);								
+							else{									
+                  sendWifi_buf(XbeeConst_FTxBuf0);					
 							}
 					}
 			}
@@ -765,25 +736,17 @@ void SendWifi_entry(void *parameter) {
             XbeeConst_CanSend = 0; //锁定无线不可发送直至解锁
             XbeeConst_needRetry = 0;  //重置重发定时计数
             XbeeConst_FrameNumLast = XbeeConst_FTxBuf0[XbeeConst_FTxBuf0[0]-1];
-				    rt_sem_take(uart2_lock, RT_WAITING_FOREVER);
             if (XbeeConst_UseAPI>0) {
                 setSendFrame_t(XbeeConst_FTxBuf0[4]==0xF8,0x00,0xC0);
-                XbeeConst_PTxBuf0 = xBeeApp2MakeFrame(&userSendFrame_t, XbeeConst_FTxBuf0);
-                for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_PTxBuf0[0]; SendWifi_i++)  //将缓冲区发出
-                    usart2_send_data[SendWifi_i-1] = XbeeConst_PTxBuf0[SendWifi_i];
-						  	HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_PTxBuf0[0]);		
-            }
-            else
-            {		
-                for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_FTxBuf0[0]; SendWifi_i++)  //将缓冲区发出
-                    usart2_send_data[SendWifi_i-1] = XbeeConst_FTxBuf0[SendWifi_i];
-							  HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_FTxBuf0[0]);		
-            }
-						rt_thread_mdelay(50);							
-						rt_sem_release(uart2_lock);				
+                XbeeConst_PTxBuf0 = xBeeApp2MakeFrame(&userSendFrame_t, XbeeConst_FTxBuf0);								
+                sendWifi_buf(XbeeConst_PTxBuf0);
+						}
+						else{									
+              sendWifi_buf(XbeeConst_FTxBuf0);					
+						}
         }
 			XbeeConst_needRetry++;
-			rt_thread_mdelay(100);				
+      rt_thread_mdelay(100);						
 	 }      
 }
 
@@ -792,7 +755,7 @@ static  rt_thread_t SendWifiid = RT_NULL;
 
 void SendWifi_thread(void)
 {
-    SendWifiid = rt_thread_create("SendWifi", SendWifi_entry, RT_NULL, 0x300,5, 5);
+    SendWifiid = rt_thread_create("SendWifi", SendWifi_entry, RT_NULL, 0x300,4, 5);
 
     /* 如果获得线程控制块,启动这个线程 */
     if (SendWifiid != RT_NULL) rt_thread_startup(SendWifiid);
@@ -805,7 +768,6 @@ static void pop_product_thread_cleanup(struct rt_thread *tid)
     {
         return ;
     }
-        
 }
 
 void pop_product_thread(void)

+ 1 - 1
tmr/weight.c

@@ -806,7 +806,7 @@ static void P_XK3190_A27E() {
     if (WeightConst_RecWeightData1[WeightConst_RecWeightPoint1] == 0x0A) 
 		{
 			  if (WeightConst_RecWeightPoint1 == 13) {					
-					 readnumber(WeightConst_RecWeightData1, WeightConst_RecWeightPoint1, 3, 6, 11, 0x2d, 0xFF);                
+					 readnumber(WeightConst_RecWeightData1, WeightConst_RecWeightPoint1, 4, 6, 11, 0x2d, 0xFF);                
 				}
 				else if (WeightConst_RecWeightPoint1 == 12) {					
 					 readnumber(WeightConst_RecWeightData1, WeightConst_RecWeightPoint1, 3, 6, 10, 0x2d, 0xFF);