From 817b7bbc6cc5c1a6aeeacf0a3b2d8b4362bfe64b Mon Sep 17 00:00:00 2001 From: yincheng.zhong <634916154@qq.com> Date: 星期五, 08 三月 2024 10:25:45 +0800 Subject: [PATCH] V1.10 测试一标签对10基站,时间稳定,测距正常。配合标签V1.9,就是和标签发送lora间隔要超过60ms,否则标签不测距 --- Src/main.c | 56 +++++++++++++++++++++++--------------------------------- 1 files changed, 23 insertions(+), 33 deletions(-) diff --git a/Src/main.c b/Src/main.c index 0c0053d..31a281e 100644 --- a/Src/main.c +++ b/Src/main.c @@ -35,11 +35,13 @@ #include "stdio.h" #include "delay.h" #include "lora.h" +#include "dps310.h" #include "dw_mbx_anc.h" #define NSH1 0x0001 #define GP 0x0002 #define FLASH_HARDWARE_VERSION_MAP (uint32_t)0x08004F00 //硬件版本号和批次信息位置 -#define DEBUG_MODE +//#define DEBUG_MODE + /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -92,7 +94,7 @@ /* USER CODE BEGIN 0 */ #define DIANLIANG_TIME 3600 uint8_t Anchor_Vcc_Flag; -uint16_t Anchor_Vcc_time=DIANLIANG_TIME-2; +uint16_t Anchor_Vcc_time=DIANLIANG_TIME+1; uint32_t dev_id; uint16_t heartbeat_timer,poll_timer,sync_timer; uint8_t aRxBuffer[1],group_id; @@ -245,7 +247,7 @@ hardware_pici = STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+2); hardware_type = STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+4); //deca_sleep(1000); - g_com_map[VERSION] = (6<<8)|0; + g_com_map[VERSION] = (1<<8)|10; // testprogram(); // g_com_map[DEV_ID]=0x6777; #ifdef DEBUG_MODE @@ -256,43 +258,28 @@ // g_com_map[NOMOVESLEEP_TIME]=10; #endif g_com_map[ACTIVE_INDEX] = 1; - g_com_map[GROUP_ID]=5; - g_com_map[UWBPOLLTIME_MS_IDX] = 520; + g_com_map[GROUP_ID]=0; + g_com_map[COM_INTERVAL] = 1000; - if(g_com_map[COM_INTERVAL]<1000) - {g_com_map[COM_INTERVAL] = 1000;} - active_flag = g_com_map[ACTIVE_INDEX]; - g_com_map[POWER]=0; + if(g_com_map[UWBPOLLTIME_MS_IDX]<10) //如果uwbpoll 时间小于10,随机生成一个小于一千的数。 + {g_com_map[UWBPOLLTIME_MS_IDX] = GetRandomValue()%1000+10;} + + if(g_com_map[UWBPOLLTIME_MS_IDX]>1000) + { + g_com_map[UWBPOLLTIME_MS_IDX] = GetRandomValue()%1000+10; + } + module_power = g_com_map[POWER]; g_com_map[IMU_ENABLE] = 0; - imu_enable=g_com_map[IMU_ENABLE]; - motor_enable=g_com_map[MOTOR_ENABLE]; + group_id=g_com_map[GROUP_ID]; dev_id = g_com_map[DEV_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; - slot_startcount=tyncpoll_time*1000/LPTIMER_LSB; - lastpoll_time=tyncpoll_time; - tag_frequency = 1000/g_com_map[COM_INTERVAL]; - total_slotnum = 1000/g_com_map[COM_INTERVAL]; - nomovesleeptime = g_com_map[NOMOVESLEEP_TIME]; - if(active_flag==0) - { - - } - // g_com_map[COM_INTERVAL]=100; - if(g_com_map[COM_INTERVAL]==0) - { - g_com_map[COM_INTERVAL]=1000; - } if(module_power>67) {module_power=67;} - - current_slotnum=1; - current_time=GetLPTime(); + if (HAL_LPTIM_TimeOut_Start_IT(&hlptim1, LPTIMER_1S_COUNT, slot_startcount) != HAL_OK) //system time is 1010ms 1 puls=30.518us { Error_Handler(); @@ -456,6 +443,9 @@ MbxInit(); // SwitchLoraSettingstest(UWB_CHANNEL_FRQ,UWB_CHANNEL_SF); Delay_Ms(10); +#ifdef _USE_BAR_ + BarInit(); +#endif // HAL_ADC_Start_DMA(&hadc,(uint32_t*)&AD_value,sizeof(AD_value)); /* USER CODE END 2 */ @@ -469,7 +459,7 @@ // Send_Anchor_Vcc_Poll(); if(g_start_send_flag&&g_com_map[ACTIVE_INDEX]) { - SystemClock_Config(); + g_start_send_flag = 0; HAL_IWDG_Refresh(&hiwdg); if(bat_percent>15) @@ -924,9 +914,9 @@ void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim) { static uint8_t i=0; + SystemClock_Config(); i++; - Anchor_Vcc_time++; - if(Anchor_Vcc_time>DIANLIANG_TIME) + if(Anchor_Vcc_time++>DIANLIANG_TIME) { Anchor_Vcc_Flag=1; Anchor_Vcc_time=0; -- Gitblit v1.9.3