From f8dda0f9757bab836487931d88935e0d6a334e58 Mon Sep 17 00:00:00 2001 From: chen <15335560115@163.com> Date: 星期三, 13 十一月 2024 09:16:17 +0800 Subject: [PATCH] 手环V1.12版本,修复GPS太快获得数据导致DMA缓存重复出现有效经纬度仅有一个报文保持不变的问题,修改从供电保护到正常后部分4G重连逻辑,增加查询功能,测距稳定版本 --- keil/uwb_app.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 53 insertions(+), 3 deletions(-) diff --git a/keil/uwb_app.c b/keil/uwb_app.c index 0010dbf..b668f73 100644 --- a/keil/uwb_app.c +++ b/keil/uwb_app.c @@ -8,11 +8,14 @@ #include "dw_app_anchor.h" #include "global_param.h" #include "board.h" +#include "HIDO_TypeDef.h" extern int simple_main(void); extern int temp_main(void); +extern void Air780E_4G_POLL(void); void TagListUpdate(void); +void Calibration_Time(void); extern void IO_LED_control_change(uint8_t data); extern void IO_control_init(void); @@ -263,6 +266,8 @@ } } uint32_t start_receive_count,end_receive_count,poll_timeout,current_count,temp_resp; +uint32_t start_receive_count_calibration; +uint32_t current_count_calibration; static uint16_t anchordata_id[TAG_NUM_IN_SYS],anchordata_dist[TAG_NUM_IN_SYS]; static uint8_t anchordata_bat[TAG_NUM_IN_SYS]; uint8_t anchordata_num = 0; @@ -377,7 +382,10 @@ uint32_t range_timeout_us = 5000; uint16_t uwb_searchcount; uint8_t flag_recsuccess; +uint8_t secondtask_search_count,secondtask_search_flag; uint8_t flag_temp2,flag_temp1; +extern HIDO_UINT32 u32CurTick; +extern float nomove_count; extern uint8_t g_start_send_flag,search_open_flag = 1,link_success_flag,flag_secondtask; int UwbRange(void) { @@ -427,8 +435,12 @@ { current_count=phy_timer_count_get(); while(mac_is_busy()) - { + { + +// MotorPoll(); IdleTask(); + UserKeyTask(); + IMUTask(); current_count=phy_timer_count_get(); if(current_count>end_receive_count&¤t_count<end_receive_count+HALF_SECOND_TIME) { @@ -506,6 +518,39 @@ return 0; } +void Calibration_Time(void) +{ + current_count_calibration=phy_timer_count_get(); + if((current_count_calibration-start_receive_count_calibration>=MS_TO_PHY_TIMER_COUNT(500)||current_count_calibration+(UINT32_MAX-start_receive_count_calibration)>=MS_TO_PHY_TIMER_COUNT(500)) + &&!((end_receive_count-current_count_calibration<=MS_TO_PHY_TIMER_COUNT(200))||(end_receive_count+(UINT32_MAX-current_count_calibration)<=MS_TO_PHY_TIMER_COUNT(200)))) + { + start_receive_count_calibration=current_count_calibration;//更新开始时间 + MotorPoll(); + + if(secondtask_search_count++%2==0) + { + secondtask_search_flag = 1; + }else{ + secondtask_search_flag = 0; + } + if(secondtask_search_flag)//更新S时间TICK + { + HIDO_TimerTick(); + TagListUpdate(); + GPS_Poll(); + if(nomove_count<=g_com_map[NOMOVESLEEP_TIME])//防止溢出 + nomove_count++; + else{ + nomove_count=g_com_map[NOMOVESLEEP_TIME]+1; + } + } + update_led_power_state();//更新等状态防止震动卡死在搜索 + } +// if(current_count_calibration-start_receive_count_calibration>=MS_TO_PHY_TIMER_COUNT(1000)||current_count_calibration+(UINT32_MAX-start_receive_count_calibration)>=MS_TO_PHY_TIMER_COUNT(1000)) +// { +// HIDO_TimerTick(); +// } +} //主函数绑定接受逻辑 int UwbSearch(void) @@ -536,6 +581,7 @@ // Register rx interrupt callback function mac_register_process_handler(tx_int_callback, rx_int_callback); + receive_flag = 0; temp_count3=phy_timer_count_get(); #ifdef BO_XING @@ -543,7 +589,8 @@ #endif flag_temp2=uwb_rx(0, 0, RX_SYNC_WIN_US_TEMP);//开启接收 start_receive_count=phy_timer_count_get(); - poll_timeout=US_TO_PHY_TIMER_COUNT(2000000);//多一个多0.4ms默认0.4ms计算为0.125*4*100000,默认开启1mss + start_receive_count_calibration=start_receive_count; + poll_timeout=US_TO_PHY_TIMER_COUNT(1000000);//多一个多0.4ms默认0.4ms计算为0.125*4*100000,默认开启1mss end_receive_count=start_receive_count+poll_timeout; if(end_receive_count>=UINT32_MAX) { @@ -553,8 +600,10 @@ while(current_count<end_receive_count||current_count>end_receive_count+HALF_SECOND_TIME)//循环接受包体,若为124.8K则是+62400000 { while(mac_is_busy()) - { + { Calibration_Time(); IdleTask(); + UserKeyTask(); + IMUTask(); current_count=phy_timer_count_get(); if(current_count>end_receive_count&¤t_count<end_receive_count+HALF_SECOND_TIME) { @@ -645,6 +694,7 @@ search_open_flag=0; uwb_led_on(); link_success_flag=UwbSearch();//第一次开启接收2s绑定失败后则进行下面1分钟后重新开启2s绑定流程 + Calibration_Time(); uwb_led_off(); if(link_success_flag) UWB_work_state=LINK_SUCCESS; -- Gitblit v1.9.3