| | |
| | | #define POLL_TX_TO_RESP_RX_DLY_UUS 150 |
| | | /* This is the delay from Frame RX timestamp to TX reply timestamp used for calculating/setting the DW1000's delayed TX function. This includes the |
| | | * frame length of approximately 2.66 ms with above configuration. */ |
| | | #define RESP_RX_TO_FINAL_TX_DLY_UUS 410 |
| | | #define RESP_RX_TO_FINAL_TX_DLY_UUS 2410 |
| | | |
| | | /* Receive response timeout. See NOTE 5 below. */ |
| | | #define RESP_RX_TIMEOUT_UUS 600 |
| | |
| | | u8 nearbase_num=0,last_nearbase_num,next_nearbase_num,last_slotnum, para_update,para_len,stationary_flag=0; |
| | | u32 rec_tagpos_binary; |
| | | int16_t offset=2700; |
| | | extern int16_t g_commap_antdelay; |
| | | u8 motor_state,rec_remotepara_state,rec_remotepara[80]; |
| | | double firstpath_power,firstpath_power2, rx_power,rec_firstpath_power; |
| | | double f1, f2, r1, r2; |
| | | uint16_t F1,F2,F3,N,C; |
| | | double B = 131072; |
| | | double A = 121.74; |
| | | double min_power; |
| | | dwt_rxdiag_t d1; |
| | | double LOS(dwt_rxdiag_t *dia) { |
| | | F1 = dia->firstPathAmp1; |
| | | F2 = dia->firstPathAmp2; |
| | | F3 = dia->firstPathAmp3; |
| | | N = dia->rxPreamCount; |
| | | C = dia->maxGrowthCIR; |
| | | |
| | | firstpath_power=10* log10((F1*F1+F2*F2+F3*F3)/(N*N))-A; |
| | | rx_power=10*log10(C*B/(N*N))-A; |
| | | |
| | | // min_power = - 10 * log10((F1 *F1 + F2 * F2 + F3 * F3) / (C *B)); |
| | | return min_power; |
| | | } |
| | | |
| | | void NearPoll(void) |
| | | { |
| | | |
| | |
| | | tx_near_msg[NEARBASENUM_INDEX] = nearbase_num; |
| | | memcpy(&tx_near_msg[NEARBASEID_INDEX],&nearbaseid_list,nearbase_num*2); |
| | | tx_near_msg[MESSAGE_TYPE_IDX] = NEAR_POLL; |
| | | memcpy(&tx_near_msg[NEARBASEID_INDEX+nearbase_num*4],&g_commap_antdelay,2); |
| | | memcpy(&tx_near_msg[ANCHOR_ID_IDX],&mainbase_id,2); |
| | | dwt_writetxdata(13+2*nearbase_num, tx_near_msg, 0);//将Poll包数据传给DW1000,将在开启发送时传出去 |
| | | dwt_writetxfctrl(13+2*nearbase_num, 0);//设置超宽带发送数据长度 |
| | | dwt_writetxdata(15+4*nearbase_num, tx_near_msg, 0);//将Poll包数据传给DW1000,将在开启发送时传出去 |
| | | dwt_writetxfctrl(15+4*nearbase_num, 0);//设置超宽带发送数据长度 |
| | | dwt_starttx(DWT_START_TX_IMMEDIATE | DWT_RESPONSE_EXPECTED);//开启发送,发送完成后等待一段时间开启接收,等待时间在dwt_setrxaftertxdelay中设置 |
| | | |
| | | tx_near_msg[TAGCONFIGSUCCESS_INDEX] =0; |
| | |
| | | dwt_writetxfctrl(28+nearbase_num*4, 0);//设定发送数据长度 |
| | | flag_getresponse=1; |
| | | memcpy(&rec_tagpos_binary,&rx_buffer[NEARMSG_EMPTYSLOTPOS_INDEX],4); |
| | | |
| | | dwt_readdiagnostics(&d1); |
| | | LOS(&d1); |
| | | tx_near_msg[TAGRXPOWER_IDX] = -(int)firstpath_power; |
| | | |
| | | //时间同步 |
| | | ancsync_time=((sync_timer)*1000+tmp_time); |