Matthias Grob & Manuel Stalder / Mbed 2 deprecated DecaWave

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
manumaet
Date:
Fri Feb 20 13:21:06 2015 +0000
Parent:
36:883de6f9a73b
Child:
38:8ef3b8d8b908
Commit message:
implemented source/destination adresses and filtering

Changed in this revision

DW1000/DW1000.cpp Show annotated file Show diff for this revision Revisions of this file
MMRanging/MMRanging.cpp Show annotated file Show diff for this revision Revisions of this file
MMRanging/MMRanging.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/DW1000/DW1000.cpp	Fri Feb 20 09:07:52 2015 +0000
+++ b/DW1000/DW1000.cpp	Fri Feb 20 13:21:06 2015 +0000
@@ -7,7 +7,7 @@
     spi.format(8,0);                    // Setup the spi for standard 8 bit data and SPI-Mode 0 (GPIO5, GPIO6 open circuit or ground on DW1000)
     spi.frequency(1000000);             // with a 1MHz clock rate (worked up to 49MHz in our Test)
     
-    //resetAll();                         // we do a soft reset of the DW1000 everytime the driver starts
+    resetAll();                         // we do a soft reset of the DW1000 everytime the driver starts
     loadLDE();                          // important everytime DW1000 initialises/awakes otherwise the LDE algorithm must be turned of or there's receiving malfunction see User Manual LDELOAD on p22 & p158
     
     // Configuration TODO: make method for that
@@ -83,10 +83,22 @@
     if (length >= 1021) length = 1021;                              // check for maximim length a frame can have            TODO: 127 Byte mode?
     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);
+    #if 0 // switch draft for slower data rate and original working 6.8Mbps
+        uint8_t backup = readRegister8(DW1000_TX_FCTRL, 1);             // put length of frame
+        length += 2;                                                    // including 2 CRC Bytes
+        //length = ((backup & 0xFC) << 8) | (length & 0x03FF);
+        length = ((0xA0 & 0xFC) << 8) | (length & 0x03FF); // for slower data rate and therefore more range   TODO: put in a modular configuration not a fixed value
+        writeRegister16(DW1000_TX_FCTRL, 0, length);
+        
+        backup = readRegister8(DW1000_TX_FCTRL, 2); // change preamble length
+        uint8_t preamble_reg = (backup & 0xC0) | (0x29 & 0x3F); // for longer preamble to match slower data rate   TODO: put in a modular configuration not a fixed value
+        writeRegister8(DW1000_TX_FCTRL, 2, preamble_reg);
+    #else
+        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);
+    #endif
     
     stopTRX();                                                      // stop receiving
     writeRegister8(DW1000_SYS_CTRL, 0, 0x02);                       // trigger sending process by setting the TXSTRT bit
--- a/MMRanging/MMRanging.cpp	Fri Feb 20 09:07:52 2015 +0000
+++ b/MMRanging/MMRanging.cpp	Fri Feb 20 13:21:06 2015 +0000
@@ -28,7 +28,7 @@
                 sendRangingframe(RX.source, RX.sequence_number, 4, rangingtimingsReceiver[RX.source][1] - rangingtimingsReceiver[RX.source][0]);
                 break;
             case 4:
-                tofs = (rangingtimingsSender[RX.source][1] - rangingtimingsSender[RX.source][0] - RX.time_difference_receiver);
+                tofs[RX.source] = (rangingtimingsSender[RX.source][1] - rangingtimingsSender[RX.source][0] - RX.time_difference_receiver);
                 break;
             default : break;
         }
--- a/MMRanging/MMRanging.h	Fri Feb 20 09:07:52 2015 +0000
+++ b/MMRanging/MMRanging.h	Fri Feb 20 13:21:06 2015 +0000
@@ -31,7 +31,7 @@
         
         uint64_t rangingtimingsSender[10][2];
         uint64_t rangingtimingsReceiver[10][2];
-        uint64_t tofs;
+        uint64_t tofs[10];
         
         rangingframe TX;
         
--- a/main.cpp	Fri Feb 20 09:07:52 2015 +0000
+++ b/main.cpp	Fri Feb 20 13:21:06 2015 +0000
@@ -39,8 +39,8 @@
         // Output bar on console
         for(int j = 0; j < 1; j++)
             //pc.printf("%f ", r.tofs[j]*MMRANGING_TIMEUNIT_NS);
-            pc.printf("%lld [", r.tofs);
-        int dots = r.tofs*70/1400;
+            pc.printf("%lld [", r.tofs[1]);
+        int dots = r.tofs[1]*70/1400;
         if (abs(dots) < 100000)
             for(int j = 0; j < dots; j++)
                 pc.printf("=");
@@ -55,9 +55,9 @@
             r.event_i = 0;
         #endif
         pc.printf("Status: %llX\r\n", dw.getStatus());
-        pc.printf("Status: %llX\r\n", dw.readRegister40(DW1000_TX_FCTRL, 0));
+        pc.printf("TX Control: %llX\r\n", dw.readRegister40(DW1000_TX_FCTRL, 0));
         
         wait(0.01);
-        wait(0.3);
+        wait(0.2);
     }
 }
\ No newline at end of file