Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mavlink_bridge mbed
Fork of AIT_UWB_Range by
Diff: main.cpp
- Revision:
- 5:111f11c95d27
- Parent:
- 4:6240b9c7a033
- Child:
- 6:d5864a1b9e17
--- a/main.cpp Tue Nov 18 12:44:22 2014 +0000
+++ b/main.cpp Tue Nov 18 13:35:48 2014 +0000
@@ -10,6 +10,8 @@
}*/
+//#define SENDER
+
int main() {
int i=0;
pc.printf("DecaWave 0.1\r\nup and running!\r\n");
@@ -25,10 +27,21 @@
pc.printf("%d System Configuration: %X\r\n", i, conf);
wait(5);
+
+#ifndef SENDR
+ uint8_t dataframereadyinterrupt = 0x20; // only good frame would be 0x40
+ dw.writeRegister(DW1000_SYS_MASK, 1, &dataframereadyinterrupt, 1);
+ DigitalIn button(USER_BUTTON);
+ while(1) {
+ pc.printf("Status: %X\r\n", (int)button);
+ wait(0.1);
+ }
+#endif
+
while(1) {
i++;
-# if 0 // to make one node sender and one receiver
+# ifdef SENDER // to make one node sender and one receiver
// Send something
char message[20] = "HELLO WORLD!";
sprintf((char*)message, "HELLO WORLD! %d", i);
@@ -48,16 +61,17 @@
while (frameready == 0 /*& 0x20) != 0x20*/) { // while no frame ready
i++;
- pc.printf("%d Waiting for frame... \r\n", i);
+ pc.printf("%d Waiting for frame... ", i);
dw.readRegister(DW1000_SYS_STATUS, 1, &frameready, 1);
- pc.printf("Status: %X\r\n", frameready);
+ pc.printf("Status: %X ", frameready);
uint8_t receive[20] = "NOTHING IN!!"; // get data from buffer
dw.readRegister(DW1000_RX_BUFFER, 0, receive, 20);
pc.printf("Message would be: %s\r\n", receive);
wait(0.3);
}
- uint8_t receive[20] = "NOTHING IN!!"; // get data from buffer
+ // get data from buffer
+ uint8_t receive[20] = "NOTHING IN!!";
dw.readRegister(DW1000_RX_BUFFER, 0, receive, 20);
pc.printf("Message received: %s -------------------------\r\n", receive);
