From a268b9fa1c215ae353de26fb137665232381debe Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期四, 20 九月 2018 21:16:18 +0800
Subject: [PATCH] 上海调试完成,可通讯,可设ID
---
源码/核心板/Src/main.c | 6 ++++--
源码/核心板/Src/application/dw_app.c | 11 +++++------
2 files changed, 9 insertions(+), 8 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 bdd2e5a..c5c6329 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"
@@ -269,7 +269,7 @@
GPIO_SetBits(SPIx_GPIO, SPIx_CS);
/* Write frame data to DW1000 and prepare transmission. See NOTE 7 below. */
- tx_poll_msg[ALL_MSG_SN_IDX] = frame_seq_nb;
+
dwt_writetxdata(sizeof(tx_poll_msg), tx_poll_msg, 0);//将Poll包数据传给DW1000,将在开启发送时传出去
dwt_writetxfctrl(sizeof(tx_poll_msg), 0);//设置超宽带发送数据长度
@@ -297,7 +297,7 @@
/* Check that the frame is the expected response from the companion "DS TWR responder" example.
* As the sequence number field of the frame is not relevant, it is cleared to simplify the validation of the frame. */
- rx_buffer[ALL_MSG_SN_IDX] = 0;
+
if (rx_buffer[MESSAGE_TYPE_IDX] == RESPONSE) //判断接收到的数据是否是response数据
{
/* Retrieve poll transmission and response reception timestamp. */
@@ -319,7 +319,7 @@
final_msg_set_ts(&tx_final_msg[FINAL_MSG_FINAL_TX_TS_IDX], final_tx_ts);
/* Write and send final message. See NOTE 7 below. */
- tx_final_msg[ALL_MSG_SN_IDX] = frame_seq_nb;
+
dwt_writetxdata(sizeof(tx_final_msg), tx_final_msg, 0);//将发送数据写入DW1000
dwt_writetxfctrl(sizeof(tx_final_msg), 0);//设定发送数据长度
dwt_starttx(DWT_START_TX_DELAYED);//设定为延迟发送
@@ -383,7 +383,7 @@
/* Check that the frame is a poll sent by "DS TWR initiator" example.
* As the sequence number field of the frame is not relevant, it is cleared to simplify the validation of the frame. */
- rx_buffer[ALL_MSG_SN_IDX] = 0;
+
//将收到的tag_id分别写入各次通讯的包中,为多标签通讯服务,防止一次通讯中接收到不同ID标签的数据
tag_id_recv = rx_buffer[TAG_ID_IDX];
@@ -405,7 +405,7 @@
/* Write and send the response message. See NOTE 9 below.*/
memcpy(&tx_resp_msg[DIST_IDX], &anchor_dist_last_frm[tag_id_recv], 2);
- tx_resp_msg[ALL_MSG_SN_IDX] = frame_seq_nb;
+
dwt_writetxdata(sizeof(tx_resp_msg), tx_resp_msg, 0);//写入发送数据
dwt_writetxfctrl(sizeof(tx_resp_msg), 0);//设定发送长度
dwt_starttx(DWT_START_TX_DELAYED | DWT_RESPONSE_EXPECTED);//延迟发送,等待接收
@@ -431,7 +431,6 @@
/* Check that the frame is a final message sent by "DS TWR initiator" example.
* As the sequence number field of the frame is not used in this example, it can be zeroed to ease the validation of the frame. */
- rx_buffer[ALL_MSG_SN_IDX] = 0;
if (rx_buffer[MESSAGE_TYPE_IDX] == FINAL&&rx_buffer[TAG_ID_IDX]==tag_id_recv&&rx_buffer[ANCHOR_ID_IDX]==g_com_map[DEV_ID]) //判断是否为Final包
{
uint32_t poll_tx_ts, resp_rx_ts, final_tx_ts;
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c"
index 673affa..53a6841 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/main.c"
@@ -10,8 +10,8 @@
#include "serial_at_cmd_app.h"
#include "global_param.h"
-#define WORK_MODE_TAG
-//#define WORK_MODE_ANCHOR
+//#define WORK_MODE_TAG
+#define WORK_MODE_ANCHOR
void Device_Init(void)
{
@@ -58,8 +58,10 @@
#ifdef WORK_MODE_TAG
tag_sleep_configuraion();
#endif
+ g_com_map[DEV_ID]=1;
Dw1000_App_Init();
/* Loop forever initiating ranging exchanges. */
+
while(1)
{
#ifdef WORK_MODE_TAG
--
Gitblit v1.9.3