| | |
| | | #define POLL_DELAY 100U //yuan100U |
| | | |
| | | /* Receive response timeout */ |
| | | #define RESP_RX_TIMEOUT_US 10000 //Yuan500 10mssuccess 300jixian |
| | | #define RESP_RX_TIMEOUT_US 1000 //Yuan500 10mssuccess 300jixian |
| | | |
| | | /* Field index in frame */ |
| | | #define MSG_SEQ_NUM_IDX 2 |
| | |
| | | } |
| | | } |
| | | uint8_t readgcom_flag1; |
| | | uint32_t current_count11,current_count22,current_count33,current_count44,current_count55; |
| | | void DiscPoll2(void) |
| | | { |
| | | uint32_t temp1,temp2,dw_systime,mindist_slavebaseid,mindist; |
| | |
| | | flag_getresponse=0; |
| | | |
| | | temp_tag_count2=phy_timer_count_get(); |
| | | resp_rx_en_start_u32 = poll_tx_en_start_u32+ US_TO_PHY_TIMER_COUNT(POLL_TX_TO_RESP_RX_DLY_US);//设置发送多少s后接收按target独立时间起点算+ US_TO_PHY_TIMER_COUNT(POLL_TX_TO_RESP_RX_DLY_US为发送后要多久开启接收时间 |
| | | resp_rx_en_start_u32 = temp_tag_count2+ US_TO_PHY_TIMER_COUNT(600);//设置发送多少s后接收按target独立时间起点算+ US_TO_PHY_TIMER_COUNT(POLL_TX_TO_RESP_RX_DLY_US为发送后要多久开启接收时间 |
| | | temp_resp=resp_rx_en_start_u32; |
| | | //tempflag=uwb_rx(1, resp_rx_en_start_u32, RESP_RX_TIMEOUT_US);//开启接受并设置接收超时 |
| | | tempflag=uwb_rx(0,0, RESP_RX_TIMEOUT_US); |
| | | tempflag=uwb_rx(1,resp_rx_en_start_u32, RESP_RX_TIMEOUT_US); |
| | | // tempflag=uwb_rx(0,0, 3000); |
| | | receive_flag =0; |
| | | start_receive_count=phy_timer_count_get(); |
| | | poll_timeout=nearbase_num*US_TO_PHY_TIMER_COUNT(DELAY_BETWEEN_TWO_FRAME_UUS)+US_TO_PHY_TIMER_COUNT(30000);//多一个多0.4ms默认0.4ms计算为0.125*4*100000,默认开启1mss |
| | | poll_timeout=US_TO_PHY_TIMER_COUNT(600);//多一个多0.4ms默认0.4ms计算为0.125*4*100000,默认开启1mss |
| | | end_receive_count=start_receive_count+poll_timeout; |
| | | if(end_receive_count>=UINT32_MAX) |
| | | {end_receive_count-=UINT32_MAX;} |
| | | current_count=phy_timer_count_get(); |
| | | mainbase_dist=100000; |
| | | mainbase_lost_count++; |
| | | while(current_count<end_receive_count||current_count>end_receive_count+HALF_SECOND_TIME)//循环接受包体,若为124.8K则是+62400000 |
| | | { |
| | | // while(current_count<end_receive_count||current_count>end_receive_count+HALF_SECOND_TIME)//循环接受包体,若为124.8K则是+62400000 |
| | | // { |
| | | |
| | | current_count=phy_timer_count_get();//不断刷新当前计数器值 |
| | | temp_tag_count2=phy_timer_count_get(); |
| | |
| | | temp_dist = nearbase_distlist[rec_nearbasepos]; |
| | | if(rx_buf[0]==0xff) |
| | | {xiaobiaoqian_flag=1;} |
| | | tempflag=uwb_rx(0, 0, RESP_RX_TIMEOUT_US);//立即开启接受并设置0超时 |
| | | current_count11=phy_timer_count_get(); |
| | | // tempflag=uwb_rx(0, 0, RESP_RX_TIMEOUT_US);//立即开启接受并设置0超时 |
| | | } |
| | | else if(rx_buf[MSG_TYPE_IDX]==LORA_MSGTYPE_WGRESPTAG) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | current_count22=phy_timer_count_get(); |
| | | if(recbase_num!=nearbase_num+1) |
| | | { |
| | | tempflag=uwb_rx(0, 0, RESP_RX_TIMEOUT_US);//立即开启接受并设置0超时 |
| | | // tempflag=uwb_rx(0, 0, RESP_RX_TIMEOUT_US);//立即开启接受并设置0超时 |
| | | } |
| | | } |
| | | //gpio_pin_clr(IO_PIN_5);//测试 |
| | |
| | | {//接收出错 |
| | | receive_flag=0; |
| | | ggggg++; |
| | | tempflag=uwb_rx(0, 0, RESP_RX_TIMEOUT_US);//立即开启接受并设置0超时 |
| | | // tempflag=uwb_rx(0, 0, RESP_RX_TIMEOUT_US);//立即开启接受并设置0超时 |
| | | current_count33=phy_timer_count_get(); |
| | | } |
| | | //gpio_pin_clr(IO_PIN_5);//测试 |
| | | } |
| | | // } |
| | | delay_us(1); |
| | | uwb_rx_force_off(1); |
| | | current_count44=phy_timer_count_get(); |
| | | // if(readgcom_flag1==0) |
| | | // { |
| | | CalculateDists(poll_tx_ts_i64); //计算距离并更新距离表 |
| | |
| | | recbase_num=0; |
| | | |
| | | temp_tag_count2=phy_timer_count_get(); |
| | | resp_rx_en_start_u32 = poll_tx_en_start_u32+ US_TO_PHY_TIMER_COUNT(POLL_TX_TO_RESP_RX_DLY_US);//设置发送多少s后接收按target独立时间起点算+ US_TO_PHY_TIMER_COUNT(POLL_TX_TO_RESP_RX_DLY_US为发送后要多久开启接收时间 |
| | | resp_rx_en_start_u32 = temp_tag_count2+ US_TO_PHY_TIMER_COUNT(600);//设置发送多少s后接收按target独立时间起点算+ US_TO_PHY_TIMER_COUNT(POLL_TX_TO_RESP_RX_DLY_US为发送后要多久开启接收时间 |
| | | temp_resp=resp_rx_en_start_u32; |
| | | //tempflag=uwb_rx(1, resp_rx_en_start_u32, RESP_RX_TIMEOUT_US);//开启接受并设置接收超时 |
| | | tempflag=uwb_rx(0,0, RESP_RX_TIMEOUT_US); |
| | | tempflag=uwb_rx(1, resp_rx_en_start_u32, RESP_RX_TIMEOUT_US);//开启接受并设置接收超时 |
| | | // tempflag=uwb_rx(0,0, RESP_RX_TIMEOUT_US); |
| | | receive_flag =0; |
| | | start_receive_count=phy_timer_count_get(); |
| | | poll_timeout=nearbase_num*US_TO_PHY_TIMER_COUNT(DELAY_BETWEEN_TWO_FRAME_UUS)+US_TO_PHY_TIMER_COUNT(RESP_RX_TIMEOUT_US);//多一个多0.4ms默认0.4ms计算为0.125*4*100000,默认开启1mss |