From 61445f53207dce2dce3ae11450297aa33908b1e6 Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期四, 21 十月 2021 11:51:03 +0800
Subject: [PATCH] 1

---
 Src/application/dw_app.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c
index 9306e9f..f3d87f1 100644
--- a/Src/application/dw_app.c
+++ b/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))//不断查询芯片状态直到发送完成
 											{ };}								

--
Gitblit v1.9.3