From ce9ff1ded137cb9915e4d8619b7bee5dc0e05138 Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期四, 25 四月 2024 15:21:50 +0800 Subject: [PATCH] V2.1 调试完成 1V4没有问题 --- Src/application/dw_app.c | 49 ++++++++++++++++++++++++++++++++++--------------- 1 files changed, 34 insertions(+), 15 deletions(-) diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c index c8086cd..f9c6e82 100644 --- a/Src/application/dw_app.c +++ b/Src/application/dw_app.c @@ -73,21 +73,33 @@ //#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}; @@ -163,7 +175,14 @@ *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. @@ -176,7 +195,7 @@ /* Configure DW1000. See NOTE 6 below. */ dwt_configure(&config);//配置DW1000 - +// SetNLOSNTMSettings(); /* Apply default antenna delay value. See NOTE 1 below. */ @@ -346,9 +365,9 @@ // 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]; @@ -435,7 +454,7 @@ 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;} -- Gitblit v1.9.3