| | |
| | | u16 basesystimer,uwb_losttimer; |
| | | uint8_t remotesend_state,remotesend_index; |
| | | uint16_t random_time; |
| | | u32 value; |
| | | uint8_t Anchor_RecNearPoll(uint8_t ancrec_nearbasepos) //0 mainbase 1 first near_base |
| | | { |
| | | uint8_t motorstate; |
| | |
| | | if(rec_nearbase_num == ancrec_nearbasepos)//抢占模式 |
| | | { |
| | | random_time = (GetLPTime()%100); |
| | | resp_tx_time = (poll_rx_ts+((random_time+rec_nearbase_num*20 + POLL_RX_TO_RESP_TX_DLY_UUS+ancrec_nearbasepos*DELAY_BETWEEN_TWO_FRAME_UUS) * UUS_TO_DWT_TIME)) >> 8;//计算Response发送时间T3。 |
| | | resp_tx_time = (poll_rx_ts+((/*value+*/random_time+rec_nearbase_num*20 + POLL_RX_TO_RESP_TX_DLY_UUS+ancrec_nearbasepos*DELAY_BETWEEN_TWO_FRAME_UUS) * UUS_TO_DWT_TIME)) >> 8;//计算Response发送时间T3。 |
| | | |
| | | }else{ |
| | | resp_tx_time = (poll_rx_ts + ((rec_nearbase_num*20+POLL_RX_TO_RESP_TX_DLY_UUS+ancrec_nearbasepos*DELAY_BETWEEN_TWO_FRAME_UUS) * UUS_TO_DWT_TIME)) >> 8;//计算Response发送时间T3。 |
| | | resp_tx_time = (poll_rx_ts + ((/*value+ */rec_nearbase_num*20+POLL_RX_TO_RESP_TX_DLY_UUS+ancrec_nearbasepos*DELAY_BETWEEN_TWO_FRAME_UUS) * UUS_TO_DWT_TIME)) >> 8;//计算Response发送时间T3。 |
| | | } |
| | | dwt_setdelayedtrxtime(resp_tx_time);//设置Response发送时间T3 |
| | | //dwt_setrxaftertxdelay(RESP_TX_TO_FINAL_RX_DLY_UUS+(rec_nearbase_num+1-ancrec_nearbasepos)*DELAY_BETWEEN_TWO_FRAME_UUS);//设置发送完成后开启接收延迟时间 |
| | |
| | | // result = dwt_starttx(DWT_START_TX_DELAYED); |
| | | //// uwb_timeout = 0; |
| | | // if(result == 0) |
| | | // { |
| | | uwb_timeout=lp_time; |
| | | while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_TXFRS | SYS_STATUS_ALL_RX_ERR)))///不断查询芯片状态直到接收成功或者出现错误 |
| | | while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & SYS_STATUS_TXFRS ))///不断查询芯片状态直到接收成功或者出现错误 |
| | | { |
| | | |
| | | current_time=HAL_LPTIM_ReadCounter(&hlptim1); |
| | | if(current_time>end_time+((32768/1000)*3)/*||current_time<end_time+15000*/) |
| | | { |
| | | // printf("debug2 timec:%d timee:%d\r\n",current_time,end_time); |
| | | break;} |
| | | // current_time=HAL_LPTIM_ReadCounter(&hlptim1); |
| | | // if(current_time>end_time+((32768/1000)*3)||current_time<end_time+15000) |
| | | // { |
| | | //// printf("debug2 timec:%d timee:%d\r\n",current_time,end_time); |
| | | // break;} |
| | | if(lp_time-uwb_timeout>2) |
| | | break; |
| | | }; |
| | | dwt_rxenable(0); |
| | | // } |
| | | // dwt_rxenable(0); |
| | | |
| | | } |
| | | |
| | |
| | | Lora_tx_ancid[Lora_tx_ancnum]=tag_id_recv; |
| | | Lora_tx_ancdist[Lora_tx_ancnum]=rec_ancdistlist[i]; |
| | | Lora_tx_anc_electricity[Lora_tx_ancnum]=battary; |
| | | // printf("接收到uwb测距:%d",Lora_tx_ancdist[0]); |
| | | Lora_tx_ancnum++; |
| | | RX_TIMEOUTs_UWB++; |
| | | } |
| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if(i==rec_nearbase_num) |
| | | { |
| | | seize_anchor=1; //抢占anchor |