From 88da33b0d531f61e1b75d27e18b6f244ad2c3224 Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期四, 25 一月 2024 18:05:19 +0800 Subject: [PATCH] 完成升级基站开发 --- Src/application/dw_app.c | 33 ++++++++++++++++++--------------- 1 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c index bea83cb..a2d6bac 100644 --- a/Src/application/dw_app.c +++ b/Src/application/dw_app.c @@ -253,6 +253,7 @@ { current_count=HAL_LPTIM_ReadCounter(&hlptim1); target_count = GetUwbPollCount(); + SwitchLoraSettings(UWB_CHANNEL_FRQ,5); //切换lora接收频点 while(current_count<target_count||current_count>target_count+16384) { current_count=HAL_LPTIM_ReadCounter(&hlptim1); @@ -261,7 +262,6 @@ break; } } - memcpy(&lora_start_poll_buff[ANC_ID_IDX],&g_com_map[DEV_ID],2); Radio.Send(lora_start_poll_buff, 4); UWB_Wkup(); @@ -271,23 +271,26 @@ bat_percent=Get_VDDVlotage(); next_poll_state = Next_Poll_LORASYNC; }else{ - current_count=HAL_LPTIM_ReadCounter(&hlptim1); - target_count = GetWGRecSyncCount()-2000/LPTIMER_LSB; //提前2ms进入接收状态 - while(current_count<target_count||current_count>target_count+16384) - { - current_count=HAL_LPTIM_ReadCounter(&hlptim1); - if(current_count<target_count-300) - { - break; - } - } - LoraSyncRecPoll(); - if(GetRangeState()) + LoraSyncRecPoll(); + if(GetRangeState()) //获取当前测距状态,是否开启。如果开启下次为测距,否为同步 { next_poll_state = Next_Poll_RANGE; }else{ next_poll_state = Next_Poll_LORASYNC; - } - + } + } + if(next_poll_state == Next_Poll_LORASYNC) + { + target_count = GetUwbPollCount()-4000/LPTIMER_LSB; //同步则提前4ms唤醒,如果在同步间隔内,则会快速进入休眠。 + if(target_count<0) + target_count+=32768; + __HAL_LPTIM_COMPARE_SET(&hlptim1, target_count); + }else{ + + target_count = GetUwbPollCount()-2000/LPTIMER_LSB; //测距提前4ms唤醒 + + if(target_count<0) + target_count+=32768; + __HAL_LPTIM_COMPARE_SET(&hlptim1, target_count); } } -- Gitblit v1.9.3