From aaf7e4ef5c1aa0535940531f20e4846cbcd39b69 Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期一, 04 十一月 2019 19:48:15 +0800
Subject: [PATCH] Merge branch '基站测距' into ALPHAV1
---
源码/核心板/Src/application/global_param.c | 7
源码/核心板/Src/main.c | 36 +++----
源码/核心板/Src/OnChipDevices/Rcc_Nvic_Systick.h | 2
源码/核心板/Src/stm32f10x_it.c | 70 ++++++++++---
源码/核心板/MDK-ARM/EventRecorderStub.scvd | 9 +
源码/核心板/Src/OnChipDevices/Rcc_Nvic_Systick.c | 33 ++++++
源码/核心板/Src/OnChipDevices/Usart.c | 11 +
源码/核心板/Src/OnChipDevices/Usart.h | 5 +
源码/核心板/Src/application/dw_app.c | 79 +++++++++++----
9 files changed, 188 insertions(+), 64 deletions(-)
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/MDK-ARM/EventRecorderStub.scvd" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/MDK-ARM/EventRecorderStub.scvd"
new file mode 100644
index 0000000..2956b29
--- /dev/null
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/MDK-ARM/EventRecorderStub.scvd"
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<component_viewer schemaVersion="0.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="Component_Viewer.xsd">
+
+<component name="EventRecorderStub" version="1.0.0"/> <!--name and version of the component-->
+ <events>
+ </events>
+
+</component_viewer>
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.c"
index e526fb3..15cffba 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.c"
@@ -145,7 +145,38 @@
NVIC_Init(&NVIC_InitStructure);
}
-
+//?????3?????
+//???????APB1?2?,?APB1?36M
+//arr:??????
+//psc:??????
+//?????????3!
+void TIM3_Int_Init(void)
+{
+ TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
+ NVIC_InitTypeDef NVIC_InitStructure;
+
+ RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); //????
+
+ //???TIM3???
+ TIM_TimeBaseStructure.TIM_Period = 1000-1; //???????????????????????????
+ TIM_TimeBaseStructure.TIM_Prescaler =72-1; //??????TIMx???????????
+ TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //??????:TDTS = Tck_tim
+ TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //TIM??????
+ TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); //??????????TIMx???????
+
+ TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE ); //?????TIM3??,??????
+
+ //?????NVIC??
+ NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; //TIM3??
+ NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //?????0?
+ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //????3?
+ NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ?????
+ NVIC_Init(&NVIC_InitStructure); //???NVIC???
+
+
+ TIM_Cmd(TIM3, ENABLE); //??TIMx
+}
+//???3??????
int Systick_Init(void)
{
int time_retry = 500;
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.h" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.h"
index ace41dc..f709c5f 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.h"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Rcc_Nvic_Systick.h"
@@ -12,4 +12,6 @@
void delay_us(uint32_t nTimer);
void delay_ms(uint32_t nTimer);
void RTC_Configuration(uint16_t interval);
+void TIM3_Int_Init(void);
+int RCC_Configuration(void);
#endif
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Usart.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Usart.c"
index 41efcbd..66396fa 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Usart.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Usart.c"
@@ -17,7 +17,6 @@
volatile uint8_t m_bEUARTTxEn = 0; //使能发送
void (*Usart1ParseDataCallback)(uint8_t);
-
void Usart1InitVariables(void)
{
m_EUART_TxFrm_FreeFrmLen = EUART_TX_FRM_SIZE-1;
@@ -88,9 +87,13 @@
GPIO_Init(EU_RX_GPIO, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = EU_TX_PIN;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //Tx推挽复用输出
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //Tx推挽复用输出 GPIO_Mode_AF_PP
GPIO_Init(EU_TX_GPIO, &GPIO_InitStructure);
+ GPIO_InitStructure.GPIO_Pin = EU_485_PIN;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //Tx推挽复用输出 GPIO_Mode_AF_PP
+ GPIO_Init(EU_485_GPIO, &GPIO_InitStructure);
+ OUT485_DISABLE;
#ifdef UART_GPIO_REMAP_ENABLE
GPIO_PinRemapConfig(UART_GPIO_REMAP, ENABLE);
#endif
@@ -139,6 +142,7 @@
while( m_EUART_DMA_RXPtr != DMACnt && MaxDataLen > 0)
{
Usart1ParseDataCallback(m_EUART_DMA_RXBuf[m_EUART_DMA_RXPtr]);
+ delay_us(10);
m_EUART_DMA_RXPtr++;
if( m_EUART_DMA_RXPtr >= EUART_RX_BUF_SIZE )
{
@@ -175,6 +179,7 @@
{
if(m_bEUARTTxEn)
{
+ OUT485_DISABLE;
m_bEUARTTxEn = 0;
// temp32 = GPIOC->CRH; //C10悬空输入
// temp32 &= ~(0x00000000F<<8);
@@ -185,6 +190,7 @@
m_bEUARTCheckingSend = 0;
return;
}
+ OUT485_ENABLE;
if(!m_bEUARTTxEn)
{
m_bEUARTTxEn = 1;
@@ -193,6 +199,7 @@
// temp32 |= (0x000000009<<8);
// GPIOC->CRH = temp32;// */
}
+
//发送一个字节数据
EXT_UART->DR = m_EUART_TxFrames[m_EUART_TxFrm_Tail].buf[s_count];
s_count++;
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Usart.h" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Usart.h"
index 0cb0059..bdd2c30 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Usart.h"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/OnChipDevices/Usart.h"
@@ -4,6 +4,11 @@
#include "stm32f10x.h"
+#define EU_485_PIN GPIO_Pin_7
+#define EU_485_GPIO GPIOB
+#define OUT485_ENABLE GPIO_WriteBit(EU_485_GPIO, EU_485_PIN, Bit_SET);
+#define OUT485_DISABLE GPIO_WriteBit(EU_485_GPIO, EU_485_PIN, Bit_RESET);
+
//#define UART_GPIO_REMAP_ENABLE
#ifdef UART_GPIO_REMAP_ENABLE
#define UART_GPIO_REMAP GPIO_Remap_USART1
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 7e8f463..6825d03 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"
@@ -64,6 +64,8 @@
#define FINAL_MSG_FINAL_TX_TS_IDX 18
#define FINAL_MSG_TS_LEN 4
+#define SYNC_SEQ_IDX 5
+
#define GROUP_ID_IDX 0
#define ANCHOR_ID_IDX 1
#define TAG_ID_IDX 5
@@ -75,11 +77,13 @@
#define BUTTON_IDX 16
#define SEQUENCE_IDX 17
//respose
-#define TIMECORRE 14
+#define ANCTIMEMS 14
+#define ANCTIMEUS 16
#define POLL 0x01
#define RESPONSE 0x02
#define FINAL 0x03
+#define SYNC 0x04
/*------------------------------------ Variables ------------------------------------------*/
/* Default communication configuration. We use here EVK1000's default mode (mode 3). */
@@ -98,11 +102,12 @@
/* Frames used in the ranging process. See NOTE 2 below. */
static uint8_t tx_poll_msg[20] = {0};
+static uint8_t tx_sync_msg[14] = {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};
//static uint8_t rx_poll_msg[] = {0x00, 0x88, 0, 0xCA, 0xDE, 'W', 'A', 'V', 'E', 0x21, 0, 0};
-static uint8_t tx_resp_msg[18] = {0};
+static uint8_t tx_resp_msg[20] = {0};
//static uint8_t rx_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};
/* Frame sequence number, incremented after each transmission. */
@@ -269,10 +274,12 @@
tx_poll_msg[MESSAGE_TYPE_IDX]=POLL;
tx_resp_msg[MESSAGE_TYPE_IDX]=RESPONSE;
tx_final_msg[MESSAGE_TYPE_IDX]=FINAL;
+ tx_sync_msg[MESSAGE_TYPE_IDX]=SYNC;
+
memcpy(&tx_poll_msg[TAG_ID_IDX], &dev_id, 4);
memcpy(&tx_final_msg[TAG_ID_IDX], &dev_id, 4);
memcpy(&tx_resp_msg[ANCHOR_ID_IDX], &dev_id, 4);
-
+ memcpy(&tx_sync_msg[ANCHOR_ID_IDX], &dev_id, 4);
}
uint16_t Checksum_u16(uint8_t* pdata, uint32_t len)
{
@@ -293,18 +300,31 @@
dwt_configuresleep(0x940, 0x7);
dwt_entersleep();
}
+extern uint8_t g_start_send_flag;
+u8 g_start_sync_flag;
+void SyncPoll(u8 sync_seq)
+{
+ g_start_sync_flag=1;
+ dwt_forcetrxoff();
+ tx_sync_msg[SYNC_SEQ_IDX]=sync_seq;
+ dwt_writetxdata(sizeof(tx_sync_msg), tx_sync_msg, 0);//将Poll包数据传给DW1000,将在开启发送时传出去
+ dwt_writetxfctrl(sizeof(tx_sync_msg), 0);//设置超宽带发送数据长度
+ dwt_starttx(DWT_START_TX_IMMEDIATE);
+}
uint16_t g_Resttimer;
uint8_t result;
u8 tag_succ_times=0;
int32_t hex_dist;
u16 checksum;
int8_t tag_delaytime;
+extern uint16_t sync_timer;
+u16 tmp_time;
void Tag_App(void)//发送模式(TAG标签)
{
uint32_t frame_len;
uint32_t final_tx_time;
u32 start_poll;
- u8 i;
+ u8 i,getsync_flag=0;
//LED0_ON;
dwt_forcetrxoff();
g_Resttimer=0;
@@ -314,7 +334,7 @@
tx_poll_msg[BATTARY_IDX] = Get_Battary();
tx_poll_msg[BUTTON_IDX] = !READ_KEY0;
tx_poll_msg[SEQUENCE_IDX] = frame_seq_nb++;
-
+ GPIO_WriteBit(GPIOA, GPIO_Pin_9, Bit_RESET);
for(i=0;i<g_com_map[MAX_REPORT_ANC_NUM];i++)
{
/* Write frame data to DW1000 and prepare transmission. See NOTE 7 below. */
@@ -361,15 +381,21 @@
poll_tx_ts = get_tx_timestamp_u64(); //获得POLL发送时间T1
resp_rx_ts = get_rx_timestamp_u64(); //获得RESPONSE接收时间T4
- if(i==0)
- {
- tag_delaytime=rx_buffer[TIMECORRE];
- if(tag_delaytime>g_com_map[COM_INTERVAL]/2)
- {
- tag_delaytime=tag_delaytime-g_com_map[COM_INTERVAL];
- }
- }
-
+ if(getsync_flag==0)
+ {
+ getsync_flag=1;
+ memcpy(&sync_timer,&rx_buffer[ANCTIMEMS],2);
+ memcpy(&tmp_time,&rx_buffer[ANCTIMEUS],2);
+ tmp_time=tmp_time+450;
+ if(tmp_time>999)
+ {
+ tmp_time-=999;
+ sync_timer++;
+ if(sync_timer>=1010)
+ {sync_timer=0;}
+ }
+ TIM3->CNT=tmp_time;
+ }
memcpy(&anchor_dist_last_frm[0], &rx_buffer[DIST_IDX], 4);
memcpy(&tx_final_msg[ANCHOR_ID_IDX], &rx_buffer[ANCHOR_ID_IDX], 4);
/* Compute final message transmission time. See NOTE 9 below. */
@@ -400,7 +426,7 @@
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];;
+ hex_dist = anchor_dist_last_frm[0]+(int16_t)g_com_map[DIST_OFFSET];
memcpy(&usart_send[9],&hex_dist,4);
usart_send[13] = battary;
usart_send[14] = button;
@@ -443,7 +469,8 @@
}
int8_t correction_time;
-extern uint8_t g_start_send_flag;
+extern uint8_t sync_seq;
+
void Anchor_App(void)
{
uint32_t frame_len;
@@ -456,7 +483,7 @@
dwt_rxenable(0);//打开接收
/* Poll for reception of a frame or error/timeout. See NOTE 7 below. */
- while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR))&&!g_start_send_flag)//不断查询芯片状态直到接收成功或者出现错误
+ while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR))&&!g_start_send_flag&&!g_start_sync_flag)//不断查询芯片状态直到接收成功或者出现错误
{
IdleTask();
g_Resttimer=0;
@@ -490,10 +517,10 @@
if (rx_buffer[MESSAGE_TYPE_IDX] == POLL&&(anchor_type == rx_buffer[ANC_TYPE_IDX])) //判断是否是poll包数据
{
- 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;
+ tmp_time=TIM3->CNT;
+ memcpy(&tx_resp_msg[ANCTIMEMS],&sync_timer,2);
+ memcpy(&tx_resp_msg[ANCTIMEUS],&tmp_time,2);
+
// if(correction_time>10)
// {correction_time++;}
@@ -609,6 +636,16 @@
/* Clear RX error events in the DW1000 status register. */
dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR);
}
+ }else if(rx_buffer[MESSAGE_TYPE_IDX] == SYNC)
+ {
+ if(rx_buffer[SYNC_SEQ_IDX]<sync_seq)
+ // if(rx_buffer[SYNC_SEQ_IDX]==2)
+ {
+ sync_seq=rx_buffer[SYNC_SEQ_IDX]+1;
+ TIM3->CNT = sync_seq*325%1000+15;
+ sync_timer = sync_seq*325/1000;
+ SyncPoll(sync_seq);
+ }
}
}
else
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 202b222..3a68e3e 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,17 +25,16 @@
if(g_com_map[0] != 0x55AA)
{
g_com_map[0] = 0x55AA;
- g_com_map[VERSION] = 0x0101;
g_com_map[DEV_ID] =0x04;//DEFAULT_DEV_ID; //默认设备ID
g_com_map[COM_INTERVAL]=50;
g_com_map[MAX_REPORT_ANC_NUM]=2;
g_com_map[MIN_REPORT_ANC_NUM]=2;
- g_com_map[DIST_OFFSET]=-26;
+ g_com_map[DIST_OFFSET]=-40;
#ifdef WORK_MODE_TAG
- g_com_map[DEV_ROLE] =0x1;
+ g_com_map[DEV_ROLE] =0x1; //标签
#else
- g_com_map[DEV_ROLE] =0x0;
+ g_com_map[DEV_ROLE] =0x0; //基站
#endif
g_com_map[ANC_POLL]=0;
g_com_map[ALARM_DEV] = 1;
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 872fdb4..ffa53e1 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"
@@ -18,7 +18,8 @@
//SystemInit();
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x5000);
Nvic_Init();
- Systick_Init();
+// Systick_Init();
+ TIM3_Int_Init();
Led_Init();
Beep_Init();
DW_GPIO_Init();
@@ -42,6 +43,7 @@
checksum = Checksum_u16(&hbsend[2],12);
memcpy(&hbsend[14],&checksum,2);
}
+u16 tyncpoll_time;
void Program_Init(void)
{uint16_t i;
Usart1ParseDataCallback = UsartParseDataHandler;
@@ -49,17 +51,25 @@
//deca_sleep(1000);
HeartBeatInit();
dev_id = g_com_map[DEV_ID];
+// g_com_map[DEV_ROLE]=1;
+// g_com_map[DEV_ID]=1;
+// g_com_map[COM_INTERVAL]=10;
+ OUT485_ENABLE;
+ g_com_map[VERSION] = 0x0104;
if(g_com_map[DEV_ROLE])
{
+ tyncpoll_time=g_com_map[DEV_ID]*g_com_map[MAX_REPORT_ANC_NUM]*4/3;
printf("标签ID: %d .\r\n",dev_id);
printf("通讯间隔: %d ms.\r\n",g_com_map[COM_INTERVAL]);
printf("单次通讯基站数量: %d个.\r\n",g_com_map[MAX_REPORT_ANC_NUM]);
}else{
+
anchor_type = dev_id%g_com_map[MAX_REPORT_ANC_NUM];
printf("基站ID: %x .\r\n",dev_id);
printf("基站类型: %c .\r\n",anchor_type+0x41);
printf("单次通讯基站数量: %d个.\r\n",g_com_map[MAX_REPORT_ANC_NUM]);
}
+ OUT485_DISABLE;
// printf("DEVICE PAIRID: %d .\r\n",g_com_map[PAIR_ID]);
// printf("DEVICE ALARM DISTANCE: 1.%d 2.%d 3.%d .\r\n",g_com_map[ALARM_DISTANCE1],g_com_map[ALARM_DISTANCE2],g_com_map[ALARM_DISTANCE3]);
@@ -83,9 +93,11 @@
{
UART_PushFrame(hbsend,16);
}
-u16 heartbeat_timer,poll_timer;
+extern u8 g_start_sync_flag;
+u16 heartbeat_timer,poll_timer,sync_timer;
void IdleTask(void)
{
+ g_start_sync_flag=0;
UART_CheckReceive();
UART_CheckSend();
if(heartbeat_timer>1000)
@@ -94,24 +106,7 @@
if(g_com_map[HEARTBEAT]&&g_com_map[DEV_ROLE]==0)
HeatBeat();
}
- if(poll_timer>=g_com_map[COM_INTERVAL]-tag_delaytime)
- {
- poll_timer=0;
- if(g_com_map[ANC_POLL]||g_com_map[DEV_ROLE])
- {
- if(g_com_map[DEV_ROLE]==0)
- {int8_t correction_time;
- correction_time=tag_timer-g_com_map[DEV_ID]*3;
- tag_delaytime=correction_time;
- if(tag_delaytime>g_com_map[COM_INTERVAL]/2)
- {
- tag_delaytime=tag_delaytime-g_com_map[COM_INTERVAL];
- }
- }
- g_start_send_flag=1;
- }
-
- }
+
if(g_com_map[CNT_UPDATE]==1)
{
uint32_t result = 0;
@@ -140,6 +135,7 @@
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
usart_send[0]=0x55;
usart_send[1]=0xAA;
+
while(1)
{
IdleTask();
diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/stm32f10x_it.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/stm32f10x_it.c"
index ab9ecfb..c1e9ce1 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/stm32f10x_it.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/stm32f10x_it.c"
@@ -28,18 +28,23 @@
#include "beep_logic_app.h"
#include "led.h"
#include "Usart.h"
+#include "dw_app.h"
/* Tick timer count. */
volatile uint32_t time32_incr;
uint8_t tt=0;
-uint8_t g_start_send_flag = 0;
+uint8_t g_start_send_flag = 0,sync_seq=0;
uint16_t sysscal;
u16 tag_recv_timer, tag_timer;
-extern uint16_t g_Resttimer,heartbeat_timer;
+extern uint16_t g_Resttimer,heartbeat_timer,sync_timer;
extern uint8_t g_pairstart;
-
-void SysTick_Handler(void)
+u16 timer3;
+extern u16 tyncpoll_time;
+void TIM3_IRQHandler(void) //TIM3??
{
- time32_incr++;
+ if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) //??TIM3????????
+ {
+ TIM_ClearITPendingBit(TIM3, TIM_IT_Update ); //??TIMx??????
+ time32_incr++;
g_UWB_com_interval++;
heartbeat_timer++;
poll_timer++;
@@ -51,18 +56,51 @@
NVIC_SystemReset();
}
-// if(g_UWB_com_interval > 1000)
-// {
-// dis_after_filter = DEFAULT_DISTANCE;
-// }
-//#ifdef WORK_MODE_ANCHOR
- if(!g_com_map[DEV_ROLE])
- {tag_recv_timer++;
- TagDistClear();
- //if(g_pairstart!=1)
- main_logic();
+
+ sync_timer++;
+
+ if(!g_com_map[DEV_ROLE]) //基站
+ {
+ tag_recv_timer++;
+ TagDistClear();
+ if(sync_timer==10)
+ {
+ GPIO_WriteBit(GPIOA, GPIO_Pin_9, Bit_SET);
+ }else{
+ GPIO_WriteBit(GPIOA, GPIO_Pin_9, Bit_RESET);
+ }
+ if(sync_timer>500&&dev_id!=0)
+ {
+ sync_seq=0xff;
+ }
+ if(sync_timer>=1010)
+ {
+ sync_timer=0;
+ if(dev_id==0)
+ {
+ SyncPoll(0);
+ }
}
-//#endif
+ }else{ //标签同步处理
+ if(sync_timer>=1010)
+ {sync_timer=0;}
+ if((sync_timer-10)%g_com_map[COM_INTERVAL]==tyncpoll_time)
+ {
+ GPIO_WriteBit(GPIOA, GPIO_Pin_9, Bit_SET);
+ }
+ if((sync_timer-10)%g_com_map[COM_INTERVAL]==tyncpoll_time)
+ {
+ g_start_send_flag=1;
+ }
+
+ }
+
+ }
+}
+
+void SysTick_Handler(void)
+{
+
}
--
Gitblit v1.9.3