From 13cd19475cb91e0eebdc79743e32e77a2a212f0e Mon Sep 17 00:00:00 2001 From: yincheng.zhong <634916154@qq.com> Date: 星期一, 22 一月 2024 22:20:38 +0800 Subject: [PATCH] 修改部分代码 --- Src/application/dw_mbx_anc.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Src/application/dw_mbx_anc.c b/Src/application/dw_mbx_anc.c index ad2bd16..41bd3b8 100644 --- a/Src/application/dw_mbx_anc.c +++ b/Src/application/dw_mbx_anc.c @@ -71,14 +71,27 @@ synclock_zero_count = rec_sync_count-(uint32_t)wg_sync_polltime_100us*100/LPTIMER_LSB; if(synclock_zero_count<0) synclock_zero_count+=32768; - uwbpoll_time_count = synclock_zero_count + (uint32_t)g_com_map[UWBPOLLTIME_MS_IDX]*1000/LPTIMER_LSB; + uwbpoll_time_count = synclock_zero_count + (uint32_t)g_com_map[UWBPOLLTIME_MS_IDX]*1000/LPTIMER_LSB; //设定好的UWB发送时间 if(uwbpoll_time_count>32768) uwbpoll_time_count-=32768; } +static uint16_t current_count,target_count; void LoraSyncRecPoll(void) { if(sync_interval_count++>=sync_interval_s) { + current_count=HAL_LPTIM_ReadCounter(&hlptim1); //如果需要触发同步就会等待触发时间,提前2ms打开接收 + target_count = GetWGRecSyncCount()-2000/LPTIMER_LSB; //提前2ms进入接收状态 + if(target_count<0) + target_count+=32768; + while(current_count<target_count||current_count>target_count+16384) + { + current_count=HAL_LPTIM_ReadCounter(&hlptim1); + if(current_count<target_count-300) + { + break; + } + } sync_interval_count = 0; flag_sync_success = 0; SwitchLoraToSyncRec(); //切换lora接收频点 @@ -89,6 +102,7 @@ if(end_count>=32768) {end_count-=32768;} current_count=HAL_LPTIM_ReadCounter(&hlptim1); + while(GetFlagLoraWaitSync()) { current_count=HAL_LPTIM_ReadCounter(&hlptim1); @@ -110,7 +124,8 @@ }else{ sync_state = Sync_Sleep; } - switch(lora_recbuffer[SUBMSGTYPE_IDX]) + SyncStateSwitch(); + switch(lora_recbuffer[SUBMSGTYPE_IDX]) //子状态函数 { case SUBMSG_READ_ANCPARA: -- Gitblit v1.9.3