From 681567d6d1bd2894eccde5b22a948eac7d3a22a5 Mon Sep 17 00:00:00 2001
From: chen <15335560115@163.com>
Date: 星期五, 20 九月 2024 18:38:25 +0800
Subject: [PATCH] 对应发货标签V1.6,更改版本号为V1.1,与一期标签分开,更改了tag的uwb测距配置与DW1000通讯,并将测距接包逻辑单次接包改为打开循环接收

---
 keil/include/drivers/menu.c |  258 +++++++++++++++++++++++++-------------------------
 1 files changed, 129 insertions(+), 129 deletions(-)

diff --git a/keil/include/drivers/menu.c b/keil/include/drivers/menu.c
index 4fb7137..5d1749a 100644
--- a/keil/include/drivers/menu.c
+++ b/keil/include/drivers/menu.c
@@ -15,51 +15,51 @@
 
 uint32_t FlashProtection = 0;
 uint8_t tab_1024[1024] =
-{
+  {
     0
-};
-
+  };
+	
 void Int2Str(uint8_t* str, int32_t intnum)
 {
-    uint32_t i, Div = 1000000000, j = 0, Status = 0;
+  uint32_t i, Div = 1000000000, j = 0, Status = 0;
 
-    for (i = 0; i < 10; i++)
+  for (i = 0; i < 10; i++)
+  {
+    str[j++] = (intnum / Div) + 48;
+
+    intnum = intnum % Div;
+    Div /= 10;
+    if ((str[j-1] == '0') & (Status == 0))
     {
-        str[j++] = (intnum / Div) + 48;
-
-        intnum = intnum % Div;
-        Div /= 10;
-        if ((str[j-1] == '0') & (Status == 0))
-        {
-            j = 0;
-        }
-        else
-        {
-            Status++;
-        }
+      j = 0;
     }
+    else
+    {
+      Status++;
+    }
+  }
 }
 uint32_t IAP_JumpTo(uint32_t ApplicationAddress)
 {
-
+	
 //	if (((*(uint32_t*)ApplicationAddress) & 0x20000000 ) == 0x20000000)
-//	{
-    memcpy((void *)SRAM_BASE, (void *)APP_CONFIG_APPLICATION_ADDRESS, APP_CONFIG_APPLICATION_SIZE);//size太大导致覆盖没法跳转
-    __set_MSP(*(uint32_t *)SRAM_BASE);
-    typedef void (*p_entry_t)(void);
-    ((p_entry_t) (*(uint32_t *)(SRAM_BASE + 4) + SRAM_BASE))();
+//	{ 
+       memcpy((void *)SRAM_BASE, (void *)APP_CONFIG_APPLICATION_ADDRESS, APP_CONFIG_APPLICATION_SIZE);//size太大导致覆盖没法跳转
+			    __set_MSP(*(uint32_t *)SRAM_BASE);
+					typedef void (*p_entry_t)(void);
+				((p_entry_t) (*(uint32_t *)(SRAM_BASE + 4) + SRAM_BASE))();
 //		__set_MSP(*(uint32_t*) ApplicationAddress);         //Set MSP MK8000修改
-//
+//		
 //		(*((void(*)(void))JumpAddress))();
-
+		
 //		return 1;
-//	}
+//	}	
 
-    return 0;
+	return 0;
 }
 
 uint8_t FileName[FILE_NAME_LENGTH];
-
+	
 /**
   * @brief  Download a file via serial port
   * @param  None
@@ -67,41 +67,41 @@
   */
 unsigned char SerialDownload(void)
 {
-    uint8_t Number[10] = {0};
-    int32_t Size = 0;
-    Send_Byte(0x33);
-    Size = Ymodem_Receive(&tab_1024[0]);//开始接收文件,成功会返回文件的大小
-    if (Size > 0)  //返回成功
-    {
-        SerialPutString("\n\n\r Programming Completed Successfully!\n\r--------------------------------\r\n Name: ");
-        SerialPutString(FileName);
-        Int2Str(Number, Size);
-        SerialPutString("\n\r Size: ");
-        SerialPutString(Number);
-        SerialPutString(" Bytes\r\n");
-        SerialPutString("-------------------\n");
-        return 0;
-    }
-    else if (Size == -1)
-    {
-        //SerialPutString("\n\n\rThe image size is higher than the allowed space memory!\n\r");
-        return 1;
-    }
-    else if (Size == -2)
-    {
-        //SerialPutString("\n\n\rVerification failed!\n\r");
-        return 2;
-    }
-    else if (Size == -3)
-    {
-        //SerialPutString("\r\n\nAborted by user.\n\r");
-        return 3;
-    }
-    else
-    {
-        // SerialPutString("\n\rFailed to receive the file!\n\r");
-        return 4;
-    }
+  uint8_t Number[10] = {0};
+  int32_t Size = 0;
+	Send_Byte(0x33);
+  Size = Ymodem_Receive(&tab_1024[0]);//开始接收文件,成功会返回文件的大小
+  if (Size > 0)  //返回成功
+  {
+		SerialPutString("\n\n\r Programming Completed Successfully!\n\r--------------------------------\r\n Name: ");
+    SerialPutString(FileName);
+    Int2Str(Number, Size);
+    SerialPutString("\n\r Size: ");
+    SerialPutString(Number);
+    SerialPutString(" Bytes\r\n");
+    SerialPutString("-------------------\n");
+		return 0;
+  }
+  else if (Size == -1)
+  {
+    //SerialPutString("\n\n\rThe image size is higher than the allowed space memory!\n\r");
+		return 1;
+	}
+  else if (Size == -2)
+  {
+    //SerialPutString("\n\n\rVerification failed!\n\r");
+		return 2;
+	}
+  else if (Size == -3)
+  {
+    //SerialPutString("\r\n\nAborted by user.\n\r");
+		return 3;
+  }
+  else
+  {
+   // SerialPutString("\n\rFailed to receive the file!\n\r");
+		return 4;
+	}
 }
 
 /**
@@ -112,36 +112,36 @@
 
 uint8_t GetKey(void)
 {
-    uint8_t key = 0;
+  uint8_t key = 0;
 
-    /* Waiting for user input */
-    while (1)
-    {
-        if (SerialKeyPressed((uint8_t*)&key)) break;
-    }
-    return key;
+  /* Waiting for user input */
+  while (1)
+  {
+    if (SerialKeyPressed((uint8_t*)&key)) break;
+  }
+  return key;
 
 }
 void SerialUpload(void)
 {
-    uint8_t status = 0 ;
+  uint8_t status = 0 ; 
 
-    SerialPutString("\n\n\rSelect Receive File\n\r");
+  SerialPutString("\n\n\rSelect Receive File\n\r");
 
-    if (GetKey() == CRC16)
+  if (GetKey() == CRC16)
+  {
+    /* Transmit the flash image through ymodem protocol */
+    status = Ymodem_Transmit((uint8_t*)APP_CONFIG_APPLICATION_ADDRESS, (const uint8_t*)"UploadedFlashImage.bin", APP_CONFIG_APPLICATION_SIZE);
+
+    if (status != 0) 
     {
-        /* Transmit the flash image through ymodem protocol */
-        status = Ymodem_Transmit((uint8_t*)APP_CONFIG_APPLICATION_ADDRESS, (const uint8_t*)"UploadedFlashImage.bin", APP_CONFIG_APPLICATION_SIZE);
-
-        if (status != 0)
-        {
-            SerialPutString("\n\rError Occurred while Transmitting File\n\r");
-        }
-        else
-        {
-            SerialPutString("\n\rFile uploaded successfully \n\r");
-        }
+      SerialPutString("\n\rError Occurred while Transmitting File\n\r");
     }
+    else
+    {
+      SerialPutString("\n\rFile uploaded successfully \n\r");
+    }
+  }
 }
 
 /**
@@ -150,69 +150,69 @@
   * @retval None
   */
 
-void delay_ms(uint32_t nTimer)
-{
-    uint32_t i=1000*nTimer;
-    delay_us(i);
-}
+void delay_ms(uint32_t nTimer)  
+{  
+    uint32_t i=1000*nTimer;  
+    delay_us(i);  
+} 
 void Main_Menu(void)
 {
-    uint8_t key = 0;
+  uint8_t key = 0;
 
+  
+  while (1)
+  {
 
-    while (1)
-    {
-
-        Serial0PutString("请传输升级文件\r\n\n");
-        /* Download user application in the Flash */
-        if(SerialDownload()==0)//如果传输完成跳回APP
-        {
-            //标志清除
-            uint16_t tmp = 0xFFFF;
-            flash_erase(FLASH_ID0, APP_CONFIG_IAPFLAG_SECTOR_ADDR, FLASH_SECTOR_SIZE);//擦除APPFLAG
-            flash_write_nbytes(FLASH_ID0,APP_CONFIG_IAPFLAG_MAP,(uint8_t*)&tmp,2);
+    Serial0PutString("请传输升级文件\r\n\n");
+      /* Download user application in the Flash */
+			if(SerialDownload()==0)//如果传输完成跳回APP
+			{
+				//标志清除
+        uint16_t tmp = 0xFFFF;
+				flash_erase(FLASH_ID0, APP_CONFIG_IAPFLAG_SECTOR_ADDR, FLASH_SECTOR_SIZE);//擦除APPFLAG
+				flash_write_nbytes(FLASH_ID0,APP_CONFIG_IAPFLAG_MAP,(uint8_t*)&tmp,2);
 //            SPIFlash_Erase(SPI_FLASH_ID_0, APP_CONFIG_IAPFLAG_MAP,2, SPI_FLASH_SECTOR_ERASE_MODE_4K);  MK8000修改
-//            SPIFlash_Write(SPI_FLASH_ID_0, APP_CONFIG_IAPFLAG_MAP, (HIDO_UINT8*)&tmp, sizeof(tmp));
-
+//            SPIFlash_Write(SPI_FLASH_ID_0, APP_CONFIG_IAPFLAG_MAP, (HIDO_UINT8*)&tmp, sizeof(tmp)); 
+    
 //			  if (((*(__IO uint32_t*)APP_CONFIG_APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000)先注释掉即一成功就跳转
-//				{
-            /* Jump to user application */
-            Serial0PutString("跳转APP\r\n");
-            memcpy((void *)SRAM_BASE, (void *)APP_CONFIG_APPLICATION_ADDRESS, APP_CONFIG_APPLICATION_SIZE);
-            // setup new msp
-            __set_MSP(*(uint32_t *)SRAM_BASE);
-            Serial0PutString("跳转APP后\r\n");
-            typedef void (*p_entry_t)(void);
-            ((p_entry_t) (*(uint32_t *)(SRAM_BASE + 4) + SRAM_BASE))();
-
-            //JumpAddress = *(__IO uint32_t*) (SRAM_BASE + 4);
-
+//				{ 
+					/* Jump to user application */
+					Serial0PutString("跳转APP\r\n");
+					memcpy((void *)SRAM_BASE, (void *)APP_CONFIG_APPLICATION_ADDRESS, APP_CONFIG_APPLICATION_SIZE);
+				 // setup new msp
+					__set_MSP(*(uint32_t *)SRAM_BASE);
+					Serial0PutString("跳转APP后\r\n");
+					typedef void (*p_entry_t)(void);
+					((p_entry_t) (*(uint32_t *)(SRAM_BASE + 4) + SRAM_BASE))();
+					
+				//JumpAddress = *(__IO uint32_t*) (SRAM_BASE + 4);
+				
 //					Jump_To_Application = (pFunction) JumpAddress;
-//
+//					
 //					/* Initialize user application's Stack Pointer */
 //					__set_MSP(*(__IO uint32_t*) SRAM_BASE);
-//
+//					
 //					/* Jump to application */
 //					Jump_To_Application();
-        } else {
+				}else{		
 //                    uint16_t tmp = 0xFFFF;
 //				flash_erase(FLASH_ID0, APP_CONFIG_IAPFLAG_MAP, 2);//擦除APPFLAG    此处失败就重启重新进入boot里面传输且不改变要升级的标志位
 //				flash_write(FLASH_ID0, APP_CONFIG_IAPFLAG_MAP, (uint8_t*)&tmp, sizeof(tmp));
-            //SPIFlash_Erase(SPI_FLASH_ID_0, APP_CONFIG_IAPFLAG_MAP,2, SPI_FLASH_SECTOR_ERASE_MODE_4K);  改写为MK8000API
-            //SPIFlash_Write(SPI_FLASH_ID_0, APP_CONFIG_IAPFLAG_MAP, (HIDO_UINT8*)&tmp, sizeof(tmp));
-            delay_ms(10);
-            LOG_INFO(TRACE_MODULE_APP,"升级失败重启\r\n\n");
-            NVIC_SystemReset();
-            //SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader  MK8000修改
-        }
-
-        return;
-    }
+                    //SPIFlash_Erase(SPI_FLASH_ID_0, APP_CONFIG_IAPFLAG_MAP,2, SPI_FLASH_SECTOR_ERASE_MODE_4K);  改写为MK8000API
+                    //SPIFlash_Write(SPI_FLASH_ID_0, APP_CONFIG_IAPFLAG_MAP, (HIDO_UINT8*)&tmp, sizeof(tmp)); 
+                    delay_ms(10);
+										LOG_INFO(TRACE_MODULE_APP,"升级失败重启\r\n\n");
+										NVIC_SystemReset();
+							//SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader  MK8000修改 
+				}
+				
+				return;
+			}
 //			else
 //			{
 //                NVIC_SystemReset();
 //				return;
 //			}
-
+    
 //}
 }

--
Gitblit v1.9.3