| | |
| | | #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); |
| | | |
| | |
| | | } |
| | | } |
| | | 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; |
| | |
| | | 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) |
| | | { |
| | |
| | | { |
| | | 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) |
| | | { |
| | |
| | | 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) |
| | |
| | | |
| | | // 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 |
| | |
| | | #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) |
| | | { |
| | |
| | | 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) |
| | | { |
| | |
| | | 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; |