zhyinch
2020-05-16 0dfe35b40cdcea88d1f4727df66feb1b4d4cf467
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
 
#ifndef __DW_APP_H__
#define __DW_APP_H__
 
#include <string.h>
#include "main.h"
 
#include "ADC.h"
#include "TrackingDiff.h"
 
//#define WORK_MODE_TAG
#define WORK_MODE_ANCHOR
 
//#define NEWBOARD
//#define TAG_OUTPUT
#define HEX_OUTPUT
 
#define REPOET_ANC_NUM 1
#define REPOET_ANC_NUM_MIN 1
#define TAG_ID_START         0// 0x00980000
#define GROUP_TAG_NUM 2
#define TAG_NUM_IN_SYS                25
#define DFT_RAND_DLY_TIM_MS            1
#define THRESHOLD_CHANGE_MAINBASE_DIST   50
#define MIN_ANCHOR_NUM 2
#define SYNC_SEQ_IDX                5
 
 
#define POLL                                 0x01
#define RESPONSE                             0x02
#define FINAL                               0x03
#define SYNC                                   0x04
#define NEAR_MSG                           0x05
#define NEAR_POLL                       0x06
#define NEAR_RESPONSE               0x07
#define NEAR_FINAL                       0x08
//General
#define GROUP_ID_IDX                   0
#define ANCHOR_ID_IDX                1
#define TAG_ID_IDX                    5
#define MESSAGE_TYPE_IDX             9    
//Poll
#define ANC_TYPE_IDX                     14
//respose
#define DIST_IDX                             10
#define ANCTIMEMS             14
#define ANCTIMEUS             16
#define TAGSLOTPOS                        7
//Final
#define FINAL_MSG_POLL_TX_TS_IDX 10
#define FINAL_MSG_RESP_RX_TS_IDX 14
#define FINAL_MSG_FINAL_TX_TS_IDX 18
#define FINAL_MSG_RESP_RX_NEARBASE_IDX  22
#define FINAL_MSG_TS_LEN 4
//SYNC
#define SYNC_SEQ_IDX                5
//NEAR MSG
#define NEARBASENUM_INDEX    10
#define NEARBASEID_INDEX         11
//NEAR POLL
#define BATTARY_IDX                        1
#define BUTTON_IDX                        2
#define SEQUENCE_IDX                    3
 
#define DW_CTRL_GPIO                    GPIOA
#define DW_ENABLE   HAL_GPIO_WritePin(DW_CTRL_GPIO, DW_CTRL_Pin, GPIO_PIN_RESET)
#define DW_DISABLE  HAL_GPIO_WritePin(DW_CTRL_GPIO, DW_CTRL_Pin, GPIO_PIN_SET)
extern TrackingDiffClass *pUWBDistanceTrackingDiff;
extern uint16_t poll_timer,tag_timer;
extern int8_t tag_delaytime;
extern uint32_t dev_id;
extern uint8_t anchor_type;
extern  uint32_t time32_incr;
extern uint16_t tag_recv_timer;
extern double dist_cm;
extern uint32_t g_UWB_com_interval;
extern float dis_after_filter;
 
extern uint8_t usart_send[25];
 
void IdleTask(void);
uint16_t Checksum_u16(uint8_t* pdata, uint32_t len);
void Dw1000_Init(void);
void Tag_App(void);
void Anchor_App(void);
void tag_sleep_configuraion(void);
extern int32_t g_Tagdist[TAG_NUM_IN_SYS];
 
extern void TagDistClear(void);
void Dw1000_App_Init(void);
#endif