From 147d2248cd39e7686e73313ef5408fda066fdb0a Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期二, 27 八月 2019 21:09:00 +0800
Subject: [PATCH] 增加标签确定序号
---
源码/核心板/Src/application/global_param.c | 2 +-
源码/核心板/Src/main.c | 20 +++++++++++++++++---
源码/核心板/Src/application/serial_at_cmd_app.c | 4 ++--
源码/核心板/MDK-ARM/Objects/UWB_Projects_sct.Bak | 15 +++++++++++++++
源码/核心板/Src/application/dw_app.c | 16 +++++++++-------
5 files changed, 44 insertions(+), 13 deletions(-)
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/MDK-ARM/Objects/UWB_Projects_sct.Bak" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/MDK-ARM/Objects/UWB_Projects_sct.Bak"
new file mode 100644
index 0000000..985fd4f
--- /dev/null
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/MDK-ARM/Objects/UWB_Projects_sct.Bak"
@@ -0,0 +1,15 @@
+; *************************************************************
+; *** Scatter-Loading Description File generated by uVision ***
+; *************************************************************
+
+LR_IROM1 0x08005000 0x00005000 { ; load region size_region
+ ER_IROM1 0x08005000 0x00005000 { ; load address = execution address
+ *.o (RESET, +First)
+ *(InRoot$$Sections)
+ .ANY (+RO)
+ }
+ RW_IRAM1 0x20000000 0x00005000 { ; RW data
+ .ANY (+RW +ZI)
+ }
+}
+
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 643eb8b..2a911aa 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"
@@ -73,7 +73,7 @@
#define ANC_TYPE_IDX 14
#define BATTARY_IDX 15
#define BUTTON_IDX 16
-
+#define SEQUENCE_IDX 17
//respose
#define TIMECORRE 14
@@ -97,7 +97,7 @@
};
/* Frames used in the ranging process. See NOTE 2 below. */
-static uint8_t tx_poll_msg[19] = {0};
+static uint8_t tx_poll_msg[20] = {0};
//static uint8_t rx_resp_msg[] = {0x41, 0x88, 0, 0xCA, 0xDE, 'V', 'E', 'W', 'A', 0x10, 0x02, 0, 0, 0, 0};
static uint8_t tx_final_msg[] = {0x41, 0x88, 0, 0xCA, 0xDE, 'W', 'A', 'V', 'E', 0x23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -295,7 +295,7 @@
uint16_t g_Resttimer;
uint8_t result;
u8 tag_succ_times=0;
-u32 hex_dist;
+int32_t hex_dist;
u16 checksum;
int8_t tag_delaytime;
void Tag_App(void)//发送模式(TAG标签)
@@ -312,6 +312,7 @@
tag_succ_times = 0;
tx_poll_msg[BATTARY_IDX] = Get_Battary();
tx_poll_msg[BUTTON_IDX] = !READ_KEY0;
+ tx_poll_msg[SEQUENCE_IDX] = frame_seq_nb++;
for(i=0;i<g_com_map[MAX_REPORT_ANC_NUM];i++)
{
@@ -395,7 +396,7 @@
usart_send[2] = 1;//正常模式
usart_send[3] = 17;//数据段长度
- usart_send[4] = frame_seq_nb++;//数据段长度
+ usart_send[4] = frame_seq_nb;//数据段长度
memcpy(&usart_send[5],&dev_id,2);
memcpy(&usart_send[7],&rx_buffer[ANCHOR_ID_IDX],2);
hex_dist = anchor_dist_last_frm[0];;
@@ -488,7 +489,7 @@
if (rx_buffer[MESSAGE_TYPE_IDX] == POLL&&(anchor_type == rx_buffer[ANC_TYPE_IDX])) //判断是否是poll包数据
{
- correction_time=tag_timer-(tag_id_recv%GROUP_TAG_NUM)*3;
+ correction_time=tag_timer-tag_id_recv*3;
if(correction_time == g_com_map[COM_INTERVAL])
correction_time = 0;
tx_resp_msg[TIMECORRE] = correction_time;
@@ -516,6 +517,7 @@
battary = rx_buffer[BATTARY_IDX];
button = rx_buffer[BUTTON_IDX];
+ frame_seq_nb = 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. */
if(result==0)
@@ -587,10 +589,10 @@
usart_send[2] = 1;//正常模式
usart_send[3] = 17;//数据段长度
- usart_send[4] = frame_seq_nb++;//数据段长度
+ usart_send[4] = frame_seq_nb;//数据段长度
memcpy(&usart_send[5],&tag_id_recv,2);
memcpy(&usart_send[7],&dev_id,2);
- hex_dist = dist_cm;
+
memcpy(&usart_send[9],&hex_dist,4);
usart_send[13] = battary;
usart_send[14] = button;
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/global_param.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/global_param.c"
index 99177bc..202b222 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/global_param.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/global_param.c"
@@ -25,7 +25,7 @@
if(g_com_map[0] != 0x55AA)
{
g_com_map[0] = 0x55AA;
- g_com_map[VERSION] = 0x0100;
+ g_com_map[VERSION] = 0x0101;
g_com_map[DEV_ID] =0x04;//DEFAULT_DEV_ID; //默认设备ID
g_com_map[COM_INTERVAL]=50;
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/serial_at_cmd_app.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/serial_at_cmd_app.c"
index 60b4204..ae83024 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/serial_at_cmd_app.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/serial_at_cmd_app.c"
@@ -69,7 +69,7 @@
{
case CMD_WRITE:
//从mUsartReceivePack中读取pack_length长度的字节,放到全局变量中
- memcpy((uint8_t*)&g_com_map + pack_index, mUsartReceivePack, pack_length);
+ memcpy((uint8_t*)&g_com_map + pack_index, mUsartReceivePack, pack_datalen);
//返回一个error状态
//SendComMap(pack_datalen,pack_index);
save_com_map_to_flash();
@@ -89,7 +89,7 @@
pack_index = 0;
pack_length = 0;
index=0;
- } else if((usart_receive_state == UsartReceiveWaitData) && (pack_index < pack_length)) { //若果收到的是正常通讯包
+ } else if((usart_receive_state == UsartReceiveWaitData) ) { //若果收到的是正常通讯包
mUsartReceivePack[index] = data;
index++;
if(index == pack_length-5) { //如果收到的index与长度相等
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 e07463e..872fdb4 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"
@@ -16,6 +16,7 @@
{
RCC_Configuration();
//SystemInit();
+ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x5000);
Nvic_Init();
Systick_Init();
Led_Init();
@@ -100,7 +101,7 @@
{
if(g_com_map[DEV_ROLE]==0)
{int8_t correction_time;
- correction_time=tag_timer-(GROUP_TAG_NUM+1)*3;
+ correction_time=tag_timer-g_com_map[DEV_ID]*3;
tag_delaytime=correction_time;
if(tag_delaytime>g_com_map[COM_INTERVAL]/2)
{
@@ -110,6 +111,20 @@
g_start_send_flag=1;
}
+ }
+ if(g_com_map[CNT_UPDATE]==1)
+ {
+ uint32_t result = 0;
+ u16 tmp = 0xAAAA;
+ __disable_irq();
+ result = FLASH_Prepare(0x8004A38, 2);
+ if(result)
+ result = FLASH_Write(0x8004A38, (const uint8_t*)&tmp, 2);
+ __enable_irq();
+ printf("进入升级模式\r\n");
+ // STMFLASH_Write_NoCheck(0x8004A38,0xAAAA);
+ // Delay_ms(100);
+ SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader
}
}
@@ -130,8 +145,7 @@
IdleTask();
if(g_start_send_flag)
{
- g_start_send_flag = 0;
-
+ g_start_send_flag = 0;
Tag_App();
}
--
Gitblit v1.9.3