From f223f306a6810aa2c2c6181176ea54ed26256273 Mon Sep 17 00:00:00 2001 From: yincheng.zhong <634916154@qq.com> Date: 星期四, 22 十二月 2022 17:43:45 +0800 Subject: [PATCH] 2.61 增加时间片异常处理逻辑 --- Src/main.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Src/main.c b/Src/main.c index e613194..99cf2eb 100644 --- a/Src/main.c +++ b/Src/main.c @@ -281,7 +281,7 @@ hardware_pici= STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+2); hardware_type= STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+4); //deca_sleep(1000); - g_com_map[VERSION] = (2<<8)|60; + g_com_map[VERSION] = (2<<8)|61; // g_com_map[DEV_ID]=0x7; #ifdef DEBUG_MODE @@ -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