From 6e7045056f9cb467f12bb2b3f2ce5ff7c75edaf2 Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期二, 31 八月 2021 09:47:00 +0800 Subject: [PATCH] 增加硬件版本号 --- 源码/核心板/Src/main.c | 34 ++++++++++++++++++++++++---------- 1 files changed, 24 insertions(+), 10 deletions(-) diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c" index f4eee9c..5e6e514 100644 --- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c" +++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c" @@ -2,6 +2,7 @@ #include "Rcc_Nvic_Systick.h" #include "Usart.h" #include "Spi.h" +#include "Flash.h" #include "led.h" #include "beep.h" #include "dw_driver.h" @@ -72,11 +73,25 @@ checksum = Checksum_u16(&hbsend[2],12); memcpy(&hbsend[14],&checksum,2); } + uint16_t vel_factor,pos_factor; -u16 tyncpoll_time,dist_threshold; +u16 tyncpoll_time,dist_threshold,group_id; u16 slottime,max_slotpos; extern u8 module_power; extern u16 total_slotnum; +void ComMapCheck(void) +{ + + if(g_com_map[WAR_JDQ_TIME]>1000||g_com_map[WAR_JDQ_TIME]<0) + { + g_com_map[WAR_JDQ_TIME] = 1; + } + if(dist_threshold<300) + {dist_threshold = 300;} + if(dist_threshold>15000) + {dist_threshold = 15000;} +} +u16 JDQ_time; void Program_Init(void) { float temp; u16 temp2; @@ -100,15 +115,14 @@ { g_com_map[COM_INTERVAL]=100; } - - g_com_map[VERSION] = 0x012e; -dist_threshold = (g_com_map[SPEEDFILTER_THRES]*10)/(1000/g_com_map[COM_INTERVAL]); - if(dist_threshold<300) - {dist_threshold = 300;} - if(dist_threshold>15000) - {dist_threshold = 15000;} + JDQ_time = g_com_map[WAR_JDQ_TIME]*10; + g_com_map[VERSION] = 0x0135; + FLASH_Read(FLASH_HARDWARE_FLAG, (uint8_t*)&g_com_map[HARDWAREFLAG_INDEX], 16); + dist_threshold = (g_com_map[SPEEDFILTER_THRES]*10)/(1000/g_com_map[COM_INTERVAL]); + ComMapCheck(); g_com_map[SW_TYPE] = SW_FANGZHUANG; dev_id = g_com_map[DEV_ID]; + group_id=g_com_map[GROUP_ID]; slottime=ceil((double)g_com_map[MAX_REPORT_ANC_NUM]*SLOT_SCALE)+3; max_slotpos=g_com_map[COM_INTERVAL]/slottime; tyncpoll_time=(g_com_map[DEV_ID]%max_slotpos)*slottime; @@ -185,7 +199,7 @@ if(heartbeat_timer>1000) { heartbeat_timer=0; - if(g_com_map[HEARTBEAT]&&g_com_map[DEV_ROLE]==0) + if(g_com_map[HEARTBEAT]) HeatBeat(); } if(flag_newsecond) @@ -265,7 +279,7 @@ int main(void) { - Device_Init(); + Device_Init(); //StartUpTest(); Program_Init(); Dw1000_Init(); -- Gitblit v1.9.3