Tobi's ubw test branch

Dependencies:   mavlink_bridge mbed

Fork of AIT_UWB_Range by Benjamin Hepp

Revision:
8:7a9c61242e2f
Parent:
7:e634eeafc4d2
Child:
9:c8839de428ac
--- a/main.cpp	Tue Nov 18 14:06:48 2014 +0000
+++ b/main.cpp	Tue Nov 18 15:41:33 2014 +0000
@@ -5,25 +5,18 @@
 PC          pc(USBTX, USBRX, 921600);   // USB UART Terminal
 DW1000      dw(D11, D12, D13, D10, D14);     // SPI1 on Nucleo Board (MOSI, MISO, SCLK, CS, IRQ)
 
-/*uint32_t read32Bit(uint8_t reg, uint16_t subaddress) {
-    uint32_t result = 0;
-    
-}*/
-
-//#define SENDER
+#define SENDER
 
 void Interrupthandler() {
-    pc.printf("Interrupt!!!!!!!!!!!!!!!!!!!!!!!!\r\n");
     uint8_t frameready = 0;
     dw.readRegister(DW1000_SYS_STATUS, 1, &frameready, 1);
-    pc.printf("Status: %X\r\n", frameready);
+    pc.printf("Interrupt status: %X\r\n", frameready);
     // 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);
+    pc.printf("Message received: %s\r\n", receive);
     dw.resetRX();
-    uint8_t rxenable = 0x01;                // start listening
-    dw.writeRegister(DW1000_SYS_CTRL, 1, &rxenable, 1);
+    dw.receiveFrame();
 }
 
 int main() {
@@ -42,14 +35,13 @@
     
     wait(1);
     
+    dw.callbackRX = &Interrupthandler;
 #ifndef SENDR
     uint8_t dataframereadyinterrupt = 0x20; // only good frame would be 0x40
     dw.writeRegister(DW1000_SYS_MASK, 1, &dataframereadyinterrupt, 1);
-    dw.callbackRX = &Interrupthandler;
     
     // Receive something
-    uint8_t rxenable = 0x01;                // start listening
-    dw.writeRegister(DW1000_SYS_CTRL, 1, &rxenable, 1);
+    dw.receiveFrame();
 #endif
     
     while(1) {
@@ -57,14 +49,17 @@
         
 # ifdef SENDER                      // to make one node sender and one receiver
         // Send something
-        char message[20] = "HELLO WORLD!";
+        char message[20];
         sprintf((char*)message, "HELLO WORLD! %d", i);
         dw.sendFrame(message, 20);
         
-        uint8_t messagecheck[20];
+        uint8_t messagecheck[20] = "HELLO WORLD!";
         dw.readRegister(DW1000_TX_BUFFER, 0, messagecheck, 20);
         pc.printf("Message in buffer: %s\r\n", messagecheck);
-        wait(2);   
+        wait(2);
+#else
+        pc.printf("%d Waiting...\r\n", i);
+        wait(5);
 # endif
         
     }