From 4402e21a531b498511417f44c246917edcf8b040 Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期三, 26 七月 2023 17:57:15 +0800
Subject: [PATCH] Merge branch '防撞' of http://47.108.70.204:60062/r/XRange_Tag into 防撞

---
 Src/application/global_param.c |   38 +++++++++++++++++++++++++++++++++++---
 1 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/Src/application/global_param.c b/Src/application/global_param.c
index f366224..68a299b 100644
--- a/Src/application/global_param.c
+++ b/Src/application/global_param.c
@@ -4,12 +4,42 @@
 #include <string.h>
 
 uint16_t g_com_map[COM_MAP_SIZE];
-
+u8 parameter_check(void)
+{
+    if(g_com_map[0] != 0x55AA)
+    {
+        return 1;
+    }
+    if(g_com_map[COM_INTERVAL]<50||COM_INTERVAL>1000)
+    {
+        return 1;
+    }
+    if(g_com_map[POWER]>67)
+    {
+        return 1;
+    }
+    if(g_com_map[MOTOR_ENABLE]>1)
+    {
+        return 1;
+    }
+    if(g_com_map[IMU_ENABLE]>1)
+    {
+        return 1;
+    }
+    if(g_com_map[ACTIVE_INDEX]>1)
+    {
+        return 1;
+    }
+    return 0;
+}
 
 uint32_t save_com_map_to_flash(void)
 {
 	uint32_t result = 0;
-
+    if(parameter_check()) //参数错误,不保存
+    {
+        return 1;
+    }
 	__disable_irq();
 	result = FLASH_Prepare(FLASH_IAP_CTRL_MAP, (COM_MAP_SIZE<<1));
 	if(result)
@@ -21,7 +51,7 @@
 void parameter_init(void)
 {
 	FLASH_Read(FLASH_IAP_CTRL_MAP, (uint8_t*)&g_com_map, (COM_MAP_SIZE<<1));
-	
+
 	if(g_com_map[0] != 0x55AA)
 	{
 		g_com_map[0] = 0x55AA;
@@ -48,6 +78,8 @@
 		g_com_map[MOTOR_ENABLE]=1;
 		g_com_map[IMU_ENABLE]=1;
         
+        g_com_map[ANT_LENGTH] = 0;
+    
 		g_com_map[ACTIVE_INDEX]=0;
 		g_com_map[CNT_RESTART]=0;
 		g_com_map[CNT_REBOOT]=0;

--
Gitblit v1.9.3