Tobi's ubw test branch

Dependencies:   mavlink_bridge mbed

Fork of AIT_UWB_Range by Benjamin Hepp

Revision:
13:b4d27bf7062a
Parent:
12:985aa9843c3c
Child:
15:e1fea7e2aff1
--- a/DW1000/DW1000.cpp	Sun Nov 23 14:34:31 2014 +0000
+++ b/DW1000/DW1000.cpp	Sun Nov 23 15:07:24 2014 +0000
@@ -54,19 +54,21 @@
 }
 
 void DW1000::sendFrame(uint8_t* message, uint16_t length) {
-    writeRegister(DW1000_TX_BUFFER, 0, message, length);  // fill buffer
+    writeRegister8(DW1000_SYS_CTRL, 0, 0x40);                       // disable tranceiver go back to idle mode TODO: only if receiving!!
+    writeRegister(DW1000_TX_BUFFER, 0, message, length);            // fill buffer
     
-    uint8_t backup = readRegister8(DW1000_TX_FCTRL, 1);
-    length += 2;                                // put length of frame including 2 CRC Bytes
+    uint8_t backup = readRegister8(DW1000_TX_FCTRL, 1);             // put length of frame including 2 CRC Bytes
+    length += 2;
     length = ((backup & 0xFC) << 8) | (length & 0x03FF);
     
     writeRegister(DW1000_TX_FCTRL, 0, (uint8_t*)&length, 2);   // TODO: make that bigger frames than 256 can be sent
     
     writeRegister8(DW1000_SYS_CTRL, 0, 0x02);                       // trigger sending process by setting the TXSTRT bit
+    receiveFrame();                                                 // TODO: only if receiving!!
 }
 
 void DW1000::receiveFrame() {
-    writeRegister8(DW1000_SYS_CTRL, 1, 0x01);                       // start listening for preamble by setting the RXENAB bit
+    writeRegister8(DW1000_SYS_CTRL, 0x01, 0x01);                       // start listening for preamble by setting the RXENAB bit
 }
 
 void DW1000::ISR() {