yincheng.zhong
2024-01-22 13cd19475cb91e0eebdc79743e32e77a2a212f0e
Src/application/dw_app.c
@@ -253,6 +253,8 @@
  {
    current_count=HAL_LPTIM_ReadCounter(&hlptim1);
    target_count = GetUwbPollCount();
    if(target_count<0)
      target_count+=32768;
    while(current_count<target_count||current_count>target_count+16384)
    {
        current_count=HAL_LPTIM_ReadCounter(&hlptim1);
@@ -271,23 +273,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())
      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);
  }
}