yincheng.zhong
2024-01-22 13cd19475cb91e0eebdc79743e32e77a2a212f0e
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: