Tobi's ubw test branch

Dependencies:   mavlink_bridge mbed

Fork of AIT_UWB_Range by Benjamin Hepp

Revision:
4:6240b9c7a033
Parent:
0:f50e671ffff7
Child:
7:e634eeafc4d2
diff -r 69587fadfa87 -r 6240b9c7a033 DW1000/DW1000.cpp
--- a/DW1000/DW1000.cpp	Mon Nov 17 16:00:28 2014 +0000
+++ b/DW1000/DW1000.cpp	Tue Nov 18 12:44:22 2014 +0000
@@ -23,15 +23,32 @@
     writeRegister(DW1000_EUI, 0, (uint8_t*)&EUI, 8);
 }
 
+void DW1000::sendFrame(char* message, int length) {
+    writeRegister(DW1000_TX_BUFFER, 0, (uint8_t*)message, length);  // fill buffer
+    
+    uint16_t framelength = length+2;                                // put length of frame including 2 CRC Bytes
+    writeRegister(DW1000_TX_FCTRL, 0, (uint8_t*)&framelength, 1);
+    
+    uint8_t txstart = 0x02;                                         // trigger sending process
+    writeRegister(DW1000_SYS_CTRL, 0, &txstart, 1);
+}
+
+void DW1000::resetRX() {
+    uint8_t resetrx = 0xE0;     //set rx reset
+    writeRegister(DW1000_PMSC, 3, &resetrx, 1);
+    resetrx = 0xf0;             //clear RX reset
+    writeRegister(DW1000_PMSC, 3, &resetrx, 1);
+}
+
 float DW1000::getVoltage() {
-    uint8_t buffer[7] = {0x80, 0x0A, 0x0F, 0x01, 0x00}; // form DW1000 User Manual p57
+    uint8_t buffer[7] = {0x80, 0x0A, 0x0F, 0x01, 0x00}; // algorithm form DW1000 User Manual p57
     writeRegister(DW1000_RF_CONF, 0x11, buffer, 2);
     writeRegister(DW1000_RF_CONF, 0x12, &buffer[2], 1);
     writeRegister(DW1000_TX_CAL, 0x00, &buffer[3], 1);
     writeRegister(DW1000_TX_CAL, 0x00, &buffer[4], 1);
     readRegister(DW1000_TX_CAL, 0x03, &buffer[5], 2);   // get the 8-Bit readings for Voltage and Temperature
     float Voltage = buffer[5] * 0.0057 + 2.3;
-    float Temperature = buffer[6] * 1.13 - 113.0;      // TODO: getTemperature was always ~35 degree with better formula/calibration see instance_common.c row 391
+    float Temperature = buffer[6] * 1.13 - 113.0;       // TODO: getTemperature was always ~35 degree with better formula/calibration see instance_common.c row 391
     return Voltage;
 }