| | |
| | | |
| | | //#define _UWB_4G |
| | | |
| | | static dwt_config_t config = { |
| | | #ifdef _UWB_4G |
| | | 2, /* Channel number. */ |
| | | #else |
| | | 5, |
| | | #endif |
| | | //static dwt_config_t config = { |
| | | //#ifdef _UWB_4G |
| | | // 2, /* Channel number. */ |
| | | //#else |
| | | // 5, |
| | | //#endif |
| | | // DWT_PRF_64M, /* Pulse repetition frequency. */ |
| | | // DWT_PLEN_1024, /* Preamble length. */ |
| | | // DWT_PAC8, /* Preamble acquisition chunk size. Used in RX only. */ |
| | | // 9, /* TX preamble code. Used in TX only. */ |
| | | // 9, /* RX preamble code. Used in RX only. */ |
| | | // 1, /* Use non-standard SFD (Boolean) */ |
| | | // DWT_BR_110K, /* Data rate. */ |
| | | // DWT_PHRMODE_STD, /* PHY header mode. */ |
| | | // (1025 + 8 - 8) /* SFD timeout (preamble length + 1 + SFD length - PAC size). Used in RX only. */ |
| | | //}; |
| | | dwt_config_t config = { |
| | | 5, /* Channel number. */ |
| | | DWT_PRF_64M, /* Pulse repetition frequency. */ |
| | | DWT_PLEN_64, /* Preamble length. */ |
| | | DWT_PAC8, /* Preamble acquisition chunk size. Used in RX only. */ |
| | | DWT_PLEN_1024, /* Preamble length. */ |
| | | DWT_PAC32, /* Preamble acquisition chunk size. Used in RX only. */ |
| | | 9, /* TX preamble code. Used in TX only. */ |
| | | 9, /* RX preamble code. Used in RX only. */ |
| | | 1, /* Use non-standard SFD (Boolean) */ |
| | | DWT_BR_6M8, /* Data rate. */ |
| | | DWT_BR_110K, /* Data rate. */ |
| | | DWT_PHRMODE_STD, /* PHY header mode. */ |
| | | (65 + 8 - 8) /* SFD timeout (preamble length + 1 + SFD length - PAC size). Used in RX only. */ |
| | | (1025 + 64 - 32) /* SFD timeout (preamble length + 1 + SFD length - PAC size). Used in RX only. */ |
| | | }; |
| | | static uint8_t tx_poll_msg[20] = {0}; |
| | | static uint8_t tx_sync_msg[14] = {0}; |
| | |
| | | *ts += ts_field[i] << (i * 8); |
| | | } |
| | | } |
| | | |
| | | void SetNLOSNTMSettings(void) |
| | | { |
| | | uint8_t temp; |
| | | temp = 7; |
| | | dwt_writetodevice(LDE_IF_ID,LDE_CFG1_OFFSET,1,&temp); |
| | | dwt_write16bitoffsetreg(LDE_IF_ID,LDE_CFG2_OFFSET,3); |
| | | // NTM = dwt_read32bitoffsetreg(LDE_IF_ID,LDE_CFG1_OFFSET) & LDE_CFG1_NSTDEV_MASK; |
| | | } |
| | | void Dw1000_Init(void) |
| | | { |
| | | /* Reset and initialise DW1000. |
| | |
| | | |
| | | /* Configure DW1000. See NOTE 6 below. */ |
| | | dwt_configure(&config);//配置DW1000 |
| | | |
| | | // SetNLOSNTMSettings(); |
| | | |
| | | |
| | | /* Apply default antenna delay value. See NOTE 1 below. */ |
| | |
| | | |
| | | // exsistbase_list[i]--; |
| | | #ifdef _UWB_4G |
| | | clockOffsetRatio = anc_clockoffset[i] * (FREQ_OFFSET_MULTIPLIER * HERTZ_TO_PPM_MULTIPLIER_CHAN_2 / 1.0e6) ; |
| | | clockOffsetRatio = anc_clockoffset[i] * (FREQ_OFFSET_MULTIPLIER_110KB * HERTZ_TO_PPM_MULTIPLIER_CHAN_2 / 1.0e6) ; |
| | | #else |
| | | clockOffsetRatio = anc_clockoffset[i] * (FREQ_OFFSET_MULTIPLIER * HERTZ_TO_PPM_MULTIPLIER_CHAN_5 / 1.0e6) ; |
| | | clockOffsetRatio = anc_clockoffset[i] * (FREQ_OFFSET_MULTIPLIER_110KB * HERTZ_TO_PPM_MULTIPLIER_CHAN_5 / 1.0e6) ; |
| | | #endif |
| | | rtd_init = tag_resprx[i] - poll_tx_ts; |
| | | rtd_resp = anc_resptx[i] - anc_pollrx[i]; |
| | |
| | | flag_getresponse=0; |
| | | start_count=HAL_LPTIM_ReadCounter(&hlptim1); |
| | | recbase_num=0; |
| | | timeout=nearbase_num*SLOT_SCALE+10; |
| | | timeout=nearbase_num*SLOT_SCALE+500; |
| | | end_count=start_count+(timeout<<2); |
| | | if(end_count>=32768) |
| | | {end_count-=32768;} |