From c6338b964effd7b5283ce74097dd84eabbd884d0 Mon Sep 17 00:00:00 2001 From: yincheng.zhong <634916154@qq.com> Date: 星期二, 20 十二月 2022 11:34:02 +0800 Subject: [PATCH] V2.60 --- Src/main.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Src/main.c b/Src/main.c index e613194..652a76f 100644 --- a/Src/main.c +++ b/Src/main.c @@ -924,11 +924,19 @@ /*Enter the Standby mode*/ HAL_PWR_EnterSTANDBYMode(); } -extern u16 tagslotpos; -extern uint8_t tx_near_msg[80],stationary_flag,gotosleep_flag,current_sync_sec,tagpoll_sync_sec; + +extern u16 tagslotpos,current_slotpos; +extern uint8_t tx_near_msg[80],stationary_flag,gotosleep_flag,current_sync_sec,tagpoll_sync_sec,flag_tagnewpos; float key_keeptime; extern float motor_ontime; extern uint16_t rec_tagperiod; +void GetRandomPos(void) +{ + current_slotpos = HAL_LPTIM_ReadCounter(&hlptim1)%max_slotpos; //如果丢失连接超过5次就随机换个时间片 + tagpoll_sync_sec = current_slotpos/200; + tagslotpos = current_slotpos%200; + flag_tagnewpos = 0; +} void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim) { static uint8_t i=0; @@ -936,7 +944,10 @@ // current_slotnum++; // SetNextPollTime(tagslotpos); - + if(current_slotpos>=max_slotpos) + { + GetRandomPos(); + } if(current_sync_sec==tagpoll_sync_sec) { g_start_send_flag=1; -- Gitblit v1.9.3