From 66bdd9977d6bfe014389d2cf67e83cecedb6cd7e Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期六, 11 四月 2020 10:25:14 +0800 Subject: [PATCH] ver 1.21 湖南客户固件 --- 源码/核心板/Src/main.c | 82 +++++++++++++++++++++++++++++----------- 1 files changed, 59 insertions(+), 23 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 acba733..6ec41e9 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" @@ -10,7 +10,9 @@ #include "serial_at_cmd_app.h" #include "global_param.h" #include "ADC.h" - +#include "modbus.h" +#include "deca_device_api.h" +#include "Flash.h" //#define DEBUG_MODE void Device_Init(void) @@ -46,6 +48,10 @@ } u16 tyncpoll_time; TrackingDiffClass *pUWBDistanceTrackingDiff; +u8 group_id,sync_mainbase=0,synclost_timer=0; +uint16_t vel_factor,pos_factor; + +extern u8 module_power; void Program_Init(void) {uint16_t i; float temp; @@ -61,15 +67,26 @@ #ifdef DEBUG_MODE - g_com_map[COM_INTERVAL]=50; - g_com_map[MAX_REPORT_ANC_NUM]=3; - g_com_map[DEV_ID]=1; - g_com_map[ANC_POLL]=0; - g_com_map[ALARM_DISTANCE1]=100; +// g_com_map[COM_INTERVAL]=50; +// g_com_map[MAX_REPORT_ANC_NUM]=3; +// g_com_map[DEV_ID]=1; +// g_com_map[ANC_POLL]=0; +// g_com_map[ALARM_DISTANCE1]=100; + g_com_map[FILTER_COEFFICIENT]=12; #endif - pUWBDistanceTrackingDiff = NewTrackingDiffClass(2, 4, 0.03); + //pUWBDistanceTrackingDiff = NewTrackingDiffClass(2, 4, 0.03); dev_id = g_com_map[DEV_ID]; - g_com_map[VERSION] = 0x010c; + group_id=g_com_map[GROUP_ID]; + vel_factor=g_com_map[FILTER_COEFFICIENT]; + pos_factor=g_com_map[FILTER_COEFFICIENT]; + if(dev_id==0) + sync_mainbase=1; + module_power = g_com_map[POWER]; + if(module_power>67) + { + module_power=67; + } + g_com_map[VERSION] = 0x0115; temp=(float)g_com_map[MAX_REPORT_ANC_NUM]*4/3; temp2=g_com_map[DEV_ID]*g_com_map[MAX_REPORT_ANC_NUM]*4/3; if(temp2<temp) @@ -83,7 +100,6 @@ printf("通讯间隔: %d ms.\r\n",g_com_map[COM_INTERVAL]); printf("单次通讯基站数量: %d个.\r\n",g_com_map[MAX_REPORT_ANC_NUM]); }else{ - anchor_type = dev_id%g_com_map[MAX_REPORT_ANC_NUM]; printf("基站ID: %x .\r\n",dev_id); printf("基站类型: %c .\r\n",anchor_type+0x41); @@ -129,23 +145,40 @@ if(g_com_map[CNT_UPDATE]==1) { - uint32_t result = 0; + uint32_t result = 0; u16 tmp = 0xAAAA; - __disable_irq(); - result = FLASH_Prepare(0x8004A38, 2); - if(result) - result = FLASH_Write(0x8004A38, (const uint8_t*)&tmp, 2); - __enable_irq(); - printf("进入升级模式\r\n"); - g_com_map[CNT_UPDATE]=0; - save_com_map_to_flash(); - delay_ms(100); - // STMFLASH_Write_NoCheck(0x8004A38,0xAAAA); - // Delay_ms(100); - SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader + __disable_irq(); + result = FLASH_Prepare(0x8004A38, 2); + if(result) + result = FLASH_Write(0x8004A38, (const uint8_t*)&tmp, 2); + __enable_irq(); + printf("进入升级模式\r\n"); + g_com_map[CNT_UPDATE]=0; + save_com_map_to_flash(); + delay_ms(100); + // STMFLASH_Write_NoCheck(0x8004A38,0xAAAA); + // Delay_ms(100); + SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader } + if(g_com_map[CNT_REBOOT]==1) + { + g_com_map[CNT_REBOOT]=0; + g_com_map[MAP_SIGN_INDEX]=0; + save_com_map_to_flash(); + delay_ms(100); + SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader + } + if(g_com_map[CNT_RESTART]==1) + { + g_com_map[CNT_RESTART]=0; + save_com_map_to_flash(); + delay_ms(100); + SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader + } } +uint16_t temp; +float dw_vbat; int main(void) { @@ -163,7 +196,10 @@ { if(g_start_send_flag) { - g_start_send_flag = 0; + g_start_send_flag = 0; + temp=dwt_readtempvbat(1); + dw_vbat=(float)(temp&0xff-173)/173+3.3; + if(dw_vbat>2.8) Tag_App(); }//else{ IdleTask(); -- Gitblit v1.9.3