Simple driver for DWM1000 modules.

Revision:
2:12a2907957b8
Child:
3:6a9372463510
diff -r 19b5bef7ecf4 -r 12a2907957b8 DW1000Utils.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DW1000Utils.h	Fri Feb 05 13:48:42 2016 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+#include "DW1000.h"
+
+class DW1000Utils
+{
+public:
+    static void setNLOSSettings(DW1000* dw_ptr)
+    {
+        // Channel control (PRF setting).
+        uint32_t prf_mask = (0x1 << 19) | (0x1 << 18);
+        uint32_t prf = 0x01 << 18; // 16 MHz
+        uint32_t v = dw_ptr->readRegister32(DW1000_CHAN_CTRL, 0x00);
+        v &= ~prf_mask;
+        v |= prf;
+        dw_ptr->writeRegister32(DW1000_CHAN_CTRL, 0x00, v);
+        // Setting for Noise Threshold Multiplier 1
+        dw_ptr->writeRegister8(DW1000_LDE_CTRL, 0x0806, 0x07);              //LDE_CFG1
+        // Setting for Noise Threshold Multiplier 2
+        dw_ptr->writeRegister16(DW1000_LDE_CTRL, 0x1806, 0x0003);           //LDE_CFG2 for 16 MHz PRF
+        //dw_ptr->writeRegister16(DW1000_LDE_CTRL, 0x1806, 0x1603);           //LDE_CFG2 for 64 MHz PRF
+        // Set preamble length to 1024 (see page 76 of user manual)
+        uint32_t tx_ctrl;
+        tx_ctrl = dw_ptr->readRegister32(DW1000_TX_FCTRL, 0x00);
+        uint32_t tx_ctrl_mask = (0x1 << 19);
+        tx_ctrl &= ~tx_ctrl_mask;
+        tx_ctrl |= tx_ctrl_mask;
+        dw_ptr->writeRegister32(DW1000_TX_FCTRL, 0x00, tx_ctrl);
+    }
+};