From cb4447ab1ec1edaf95abdcd6f2ff03c2d2f6edd1 Mon Sep 17 00:00:00 2001 From: yincheng.zhong <634916154@qq.com> Date: 星期二, 10 十月 2023 17:32:40 +0800 Subject: [PATCH] 初稿,待测试 --- Src/main.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Src/main.c b/Src/main.c index 682b8a1..c1be3e0 100644 --- a/Src/main.c +++ b/Src/main.c @@ -278,6 +278,12 @@ uint8_t uwb_active_flag = 0; u8 active_flag=0; u16 nomovesleep_time=0,interval; +void UpdateFreq(u16 time) +{ + g_com_map[COM_INTERVAL] = time; + tag_frequency = 1000/time; + bigslot_num = TOTAL_SLOTNUM/tag_frequency; +} void Program_Init(void) { float temp; uint16_t temp2; @@ -319,8 +325,6 @@ tyncpoll_time=(g_com_map[DEV_ID]%max_slotpos)*slottime; slot_startcount=tyncpoll_time*1000/LPTIMER_LSB; lastpoll_time=tyncpoll_time; - - bigslot_num = TOTAL_SLOTNUM/tag_frequency; current_slotnum=1; current_time=GetLPTime(); nomovesleep_time = g_com_map[NOMOVESLEEP_TIME]; @@ -333,6 +337,7 @@ motor_enable=0; } tag_frequency = 1000/interval; + bigslot_num = TOTAL_SLOTNUM/tag_frequency; if (HAL_LPTIM_TimeOut_Start_IT(&hlptim1, LPTIMER_1S_COUNT, slot_startcount) != HAL_OK) //system time is 1010ms 1 puls=30.518us { Error_Handler(); @@ -1023,8 +1028,18 @@ if(nomove_count>g_com_map[STATIONARY_TIME]) { stationary_flag = 1; + UpdateFreq(1000); + if(tagslotpos<10) + { + tagslotpos=HAL_LPTIM_ReadCounter(&hlptim1)%200; + } }else{ stationary_flag = 0; + UpdateFreq(50); + if(tagslotpos>=10) + { + tagslotpos=HAL_LPTIM_ReadCounter(&hlptim1)%10; + } } if(nomove_count>=nomovesleep_time-1&&imu_enable) { -- Gitblit v1.9.3