-
Notifications
You must be signed in to change notification settings - Fork 117
/
BasicConnectivityTest.ino
91 lines (81 loc) · 2.11 KB
/
BasicConnectivityTest.ino
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
/**
@file BasicConnectivityTest.ino
@author rakwireless.com
@brief UWB Connectivity Test
@version 0.1
@date 2022-1-28
@copyright Copyright (c) 2022
**/
#include <SPI.h>
#include <DW1000Ng.hpp>
const uint8_t PIN_SS = SS; // spi select pin
const uint8_t PIN_RST = WB_IO6;
const uint8_t PIN_IRQ = WB_IO5;
device_configuration_t DEFAULT_CONFIG = {
false,
true,
true,
true,
false,
SFDMode::STANDARD_SFD,
Channel::CHANNEL_1,
DataRate::RATE_850KBPS,
PulseFrequency::FREQ_16MHZ,
PreambleLength::LEN_256,
PreambleCode::CODE_3
};
interrupt_configuration_t DEFAULT_INTERRUPT_CONFIG = {
true,
true,
true,
false,
true
};
void setup() {
pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, HIGH); //Turn on the power switch
delay(300);
time_t serial_timeout = millis();
// DEBUG monitoring
Serial.begin(115200);
while (!Serial)
{
if ((millis() - serial_timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}
// initialize the driver
DW1000Ng::initialize(PIN_SS, PIN_IRQ, PIN_RST);
Serial.println(F("DW1000Ng initialized ..."));
// general configuration
DW1000Ng::applyConfiguration(DEFAULT_CONFIG);
DW1000Ng::applyInterruptConfiguration(DEFAULT_INTERRUPT_CONFIG);
DW1000Ng::setDeviceAddress(1);
DW1000Ng::setAntennaDelay(16436);
// general configuration
DW1000Ng::setDeviceAddress(5);
DW1000Ng::setNetworkId(10);
Serial.println(F("Committed configuration ..."));
// wait a bit
delay(1000);
}
void loop() {
// DEBUG chip info and registers pretty printed
char msg[128];
DW1000Ng::getPrintableDeviceIdentifier(msg);
Serial.print("Device ID: "); Serial.println(msg);
DW1000Ng::getPrintableExtendedUniqueIdentifier(msg);
Serial.print("Unique ID: "); Serial.println(msg);
DW1000Ng::getPrintableNetworkIdAndShortAddress(msg);
Serial.print("Network ID & Device Address: "); Serial.println(msg);
DW1000Ng::getPrintableDeviceMode(msg);
Serial.print("Device mode: "); Serial.println(msg);
Serial.println();
// wait a bit
delay(2000);
}