From 2e3abb4576f5ee872daffeb626cea76e763a3b54 Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期三, 14 九月 2022 18:20:01 +0800
Subject: [PATCH] v2.54 修改加速计初始化部分,标签保存参数前会校验

---
 Src/application/global_param.c |   34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/Src/application/global_param.c b/Src/application/global_param.c
index 8f7f047..53784be 100644
--- a/Src/application/global_param.c
+++ b/Src/application/global_param.c
@@ -5,11 +5,41 @@
 
 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)

--
Gitblit v1.9.3