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
|
| #include "Rcc_Nvic_Systick.h"
| #include "Usart.h"
| #include "Spi.h"
| #include "led.h"
| #include "beep.h"
| #include "dw_driver.h"
| #include "dw_app.h"
|
| //#define WORK_MODE_TAG
| #define WORK_MODE_ANCHOR
|
| void Device_Init(void)
| {
| Rcc_Init();
| Nvic_Init();
| Systick_Init();
| Led_Init();
| Beep_Init();
| DW_GPIO_Init();
| Usart_Init();
| Spi_Init();
|
| GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
| }
|
| /*! ------------------------------------------------------------------------------------------------------------------
| * @fn main()
| *
| * @brief Application entry point.
| *
| * @param none
| *
| * @return none
| */
| int main(void)
| {
|
| Device_Init();
| Dw1000_Init();
|
| /* Loop forever initiating ranging exchanges. */
| while(1)
| {
| #ifdef WORK_MODE_TAG
| Tag_App();
| #else
| Anchor_App();
| #endif
| //³ýUWBÖ®ÍâµÄÆäËû´úÂë...
| if(dist_cm<=100)
| {
| BEEP_ON;
| }
| else
| {
| BEEP_OFF;
| }
|
| }
| }
|
|