From 51e6f405ab9a9c4fc21d0e1bc3220e389a72939b Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期三, 03 三月 2021 18:32:16 +0800 Subject: [PATCH] 修改无55 AA 的模式 --- 源码/核心板/Src/application/dw_app.c | 30 ++++++++++++++++++++++++++---- 1 files changed, 26 insertions(+), 4 deletions(-) diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c" index 9a871d1..b446135 100644 --- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c" +++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c" @@ -28,7 +28,7 @@ #include <stdio.h> #include "beep.h" #include "modbus.h" - +//#define DEBUG_OUTPUT /*------------------------------------ Marcos ------------------------------------------*/ /* Inter-ranging delay period, in milliseconds. */ #define RNG_DELAY_MS 100 @@ -361,6 +361,9 @@ * set by dwt_setrxaftertxdelay() has elapsed. */ dwt_starttx(DWT_START_TX_IMMEDIATE | DWT_RESPONSE_EXPECTED);//开启发送,发送完成后等待一段时间开启接收,等待时间在dwt_setrxaftertxdelay中设置 start_poll = time32_incr; + #ifdef DEBUG_OUTPUT + printf("P包发送,基站ID: %d .\r\n",i); + #endif /* We assume that the transmission is achieved correctly, poll for reception of a frame or error/timeout. See NOTE 8 below. */ while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR)))//不断查询芯片状态直到成功接收或者发生错误 { if(time32_incr - start_poll>20) @@ -439,16 +442,20 @@ dwt_writetxfctrl(sizeof(tx_final_msg), 0);//设定发送数据长度 result=dwt_starttx(DWT_START_TX_DELAYED);//设定为延迟发送 + #ifdef DEBUG_OUTPUT + printf("F包发送,基站ID: %d .\r\n",i); + #endif + tag_succ_times++; LED0_BLINK; - + g_Resttimer=0; memcpy(&anc_id_recv,&rx_buffer[ANCHOR_ID_IDX],2); if(hex_dist2!=0xffff) { g_Tagdist[anc_id_recv]= hex_dist2; g_flag_Taggetdist[anc_id_recv]=0; -// g_Resttimer=0; + if(!g_com_map[MODBUS_MODE]) { hex_dist2 = hex_dist2; @@ -488,6 +495,9 @@ } else { + #ifdef DEBUG_OUTPUT + printf("R包失败错误信息: %x .\r\n",status_reg); + #endif /* Clear RX error events in the DW1000 status register. */ dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR); random_delay_tim = DFT_RAND_DLY_TIM_MS; @@ -585,6 +595,9 @@ frame_seq_nb2 = rx_buffer[SEQUENCE_IDX]; /* We assume that the transmission is achieved correctly, now poll for reception of expected "final" frame or error/timeout. * See NOTE 7 below. */ + #ifdef DEBUG_OUTPUT + printf("收到POLL包,标签ID: %d .\r\n",tag_id_recv); + #endif if(result==0) { while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR)))///不断查询芯片状态直到接收成功或者出现错误 @@ -644,9 +657,12 @@ // dist[TAG_ID] = LP(dis, TAG_ID); //LP 为低通滤波器,让数据更稳定 /*--------------------------以下为非测距逻辑------------------------*/ + #ifdef DEBUG_OUTPUT + printf("收到FINAL包,标签ID: %d .\r\n",tag_id_recv); + #endif LED0_BLINK; //每成功一次通讯则闪烁一次 g_UWB_com_interval = 0; -// g_Resttimer=0; + g_Resttimer=0; hex_dist = dist_cm+(int16_t)g_com_map[DIST_OFFSET]*10; if(tag_id_recv-TAG_ID_START<=TAG_NUM_IN_SYS) { @@ -696,6 +712,9 @@ } }else{ /* Clear RX error events in the DW1000 status register. */ + #ifdef DEBUG_OUTPUT + printf("F包失败错误信息: %x .\r\n",status_reg); + #endif dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR); } }else if(rx_buffer[MESSAGE_TYPE_IDX] == SYNC) @@ -711,6 +730,9 @@ } else { + #ifdef DEBUG_OUTPUT + printf("P包失败错误信息: %x .\r\n",status_reg); + #endif /* Clear RX error events in the DW1000 status register. */ dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR); } -- Gitblit v1.9.3