Tobi's ubw test branch

Dependencies:   mavlink_bridge mbed

Fork of AIT_UWB_Range by Benjamin Hepp

Revision:
53:79a72d752ec4
Parent:
50:50b8aea54a51
Child:
60:43be9228b3b9
--- a/DW1000/DW1000.cpp	Fri Nov 27 16:17:53 2015 +0000
+++ b/DW1000/DW1000.cpp	Mon Jan 04 12:45:37 2016 +0000
@@ -9,9 +9,15 @@
 DW1000::DW1000(SPI& spi, InterruptMultiplexer& irq_mp, PinName CS, PinName RESET) : spi(spi), cs(CS), irq_mp(irq_mp), reset(RESET) {
     irq_index = irq_mp.addCallback(this, &DW1000::ISR, false);
 
+   
     setCallbacks(NULL, NULL);
-
-    deselect();                         // Chip must be deselected first
+    deselect();
+    //wait(2);
+    select(); 
+   
+    //wait(2);
+    deselect(); 
+    //wait(2);              // Chip must be deselected first
     resetAll();                         // we do a soft reset of the DW1000 everytime the driver starts
 
     // Configuration TODO: make method for that
@@ -168,15 +174,14 @@
     //if (length >= 1021) length = 1021;                            // check for maximim length a frame can have with 1024 Byte frames [not used, see constructor]
     if (length >= 125) length = 125;                                // check for maximim length a frame can have with 127 Byte frames
     writeRegister(DW1000_TX_BUFFER, 0, message, length);            // fill buffer
-    
     uint8_t backup = readRegister8(DW1000_TX_FCTRL, 1);             // put length of frame
     length += 2;                                                    // including 2 CRC Bytes
     length = ((backup & 0xFC) << 8) | (length & 0x03FF);
     writeRegister16(DW1000_TX_FCTRL, 0, length);
-    
-    stopTRX();                                                      // stop receiving
+    stopTRX();                                              // stop receiving
     writeRegister8(DW1000_SYS_CTRL, 0, 0x02);                       // trigger sending process by setting the TXSTRT bit
-    startRX();                                                      // enable receiver again
+    //wait(0.1);
+    startRX();                                                   // enable receiver again
 }
 
 void DW1000::sendDelayedFrame(uint8_t* message, uint16_t length, uint64_t TxTimestamp) {
@@ -271,6 +276,7 @@
         callbackTX.call();
         writeRegister8(DW1000_SYS_STATUS, 0, 0xF8);                 // clearing of sending status bits
     }
+     //printf("irq_index: %d \n\r",this->irq_index);
 }
 
 uint16_t DW1000::getFramelength() {
@@ -362,7 +368,7 @@
 }
 
 void DW1000::enable_irq() {     // always called to start an SPI transmission
-    //pc.printf("Enabling irq %d\r\n", irq_index);
+    //printf("Enabling irq %d\r\n", irq_index);
     irq_mp.enableCallback(irq_index);
     //irq_mp.enable_irq();
 }