Simple driver for DWM1000 modules.

DW1000Utils.h

Committer:
bhepp
Date:
2016-02-05
Revision:
2:12a2907957b8
Child:
3:6a9372463510

File content as of revision 2:12a2907957b8:

#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);
    }
};