1
zhyinch
2021-10-21 61445f53207dce2dce3ae11450297aa33908b1e6
Src/application/dw_app.c
@@ -675,7 +675,38 @@
//         tyncpoll_time = (tagslotpos--%max_slotpos)*slottime;
   }
}
extern u32 synctimer;
u32 target_time=100;
u8 pd_i;
u32 temptime,delaytime;
u16 delaycount;
extern u16 slotpos_intoatl, slotpos;
void NextPollDelay(u32 anchor_time)
{
    for(pd_i=0;pd_i<=tag_frequency;pd_i++)
    {
        slotpos_intoatl = pd_i*bigslot_num+tagslotpos;
        temptime = (slotpos_intoatl*SLOTTIME_MS+100)*100;
        if(anchor_time<temptime-10000)
        {
            delaytime = temptime-anchor_time;
            return ;
        }
    }
    temptime = (tagslotpos*SLOTTIME_MS+100+10000)*100;
    delaytime = temptime-anchor_time;
   return ;
}
u16 lpcount;
void SetLPTimer(u32 anchor_time)
{
    NextPollDelay(anchor_time);
    current_count=HAL_LPTIM_ReadCounter(&hlptim1);
    lpcount = current_count+delaytime/LPTIMER_LSB;
    __HAL_LPTIM_COMPARE_SET(&hlptim1, lpcount);
}
void NearPoll(void)
{
   
@@ -823,7 +854,7 @@
                           {flag_getresponse=1;}
                           lastsync_timer=sync_timer;
                           offsettimeus=ancsync_time-current_count*LPTIMER_LSB+offset;
                           SetNextPollTime(tagslotpos);
                           SetLPTimer(ancsync_time);
                           if(result==0)
                                 {while (!(dwt_read32bitreg(SYS_STATUS_ID) & SYS_STATUS_TXFRS))//不断查询芯片状态直到发送完成
                                 { };}