Simple driver for DWM1000 modules.
DW1000Utils.h@2:12a2907957b8, 2016-02-05 (annotated)
- Committer:
- bhepp
- Date:
- Fri Feb 05 13:48:42 2016 +0000
- Revision:
- 2:12a2907957b8
- Child:
- 3:6a9372463510
Added methods
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bhepp | 2:12a2907957b8 | 1 | #include "mbed.h" |
bhepp | 2:12a2907957b8 | 2 | #include "DW1000.h" |
bhepp | 2:12a2907957b8 | 3 | |
bhepp | 2:12a2907957b8 | 4 | class DW1000Utils |
bhepp | 2:12a2907957b8 | 5 | { |
bhepp | 2:12a2907957b8 | 6 | public: |
bhepp | 2:12a2907957b8 | 7 | static void setNLOSSettings(DW1000* dw_ptr) |
bhepp | 2:12a2907957b8 | 8 | { |
bhepp | 2:12a2907957b8 | 9 | // Channel control (PRF setting). |
bhepp | 2:12a2907957b8 | 10 | uint32_t prf_mask = (0x1 << 19) | (0x1 << 18); |
bhepp | 2:12a2907957b8 | 11 | uint32_t prf = 0x01 << 18; // 16 MHz |
bhepp | 2:12a2907957b8 | 12 | uint32_t v = dw_ptr->readRegister32(DW1000_CHAN_CTRL, 0x00); |
bhepp | 2:12a2907957b8 | 13 | v &= ~prf_mask; |
bhepp | 2:12a2907957b8 | 14 | v |= prf; |
bhepp | 2:12a2907957b8 | 15 | dw_ptr->writeRegister32(DW1000_CHAN_CTRL, 0x00, v); |
bhepp | 2:12a2907957b8 | 16 | // Setting for Noise Threshold Multiplier 1 |
bhepp | 2:12a2907957b8 | 17 | dw_ptr->writeRegister8(DW1000_LDE_CTRL, 0x0806, 0x07); //LDE_CFG1 |
bhepp | 2:12a2907957b8 | 18 | // Setting for Noise Threshold Multiplier 2 |
bhepp | 2:12a2907957b8 | 19 | dw_ptr->writeRegister16(DW1000_LDE_CTRL, 0x1806, 0x0003); //LDE_CFG2 for 16 MHz PRF |
bhepp | 2:12a2907957b8 | 20 | //dw_ptr->writeRegister16(DW1000_LDE_CTRL, 0x1806, 0x1603); //LDE_CFG2 for 64 MHz PRF |
bhepp | 2:12a2907957b8 | 21 | // Set preamble length to 1024 (see page 76 of user manual) |
bhepp | 2:12a2907957b8 | 22 | uint32_t tx_ctrl; |
bhepp | 2:12a2907957b8 | 23 | tx_ctrl = dw_ptr->readRegister32(DW1000_TX_FCTRL, 0x00); |
bhepp | 2:12a2907957b8 | 24 | uint32_t tx_ctrl_mask = (0x1 << 19); |
bhepp | 2:12a2907957b8 | 25 | tx_ctrl &= ~tx_ctrl_mask; |
bhepp | 2:12a2907957b8 | 26 | tx_ctrl |= tx_ctrl_mask; |
bhepp | 2:12a2907957b8 | 27 | dw_ptr->writeRegister32(DW1000_TX_FCTRL, 0x00, tx_ctrl); |
bhepp | 2:12a2907957b8 | 28 | } |
bhepp | 2:12a2907957b8 | 29 | }; |