Simple driver for DWM1000 modules.
Diff: DW1000.cpp
- Revision:
- 4:faf802b4af85
- Parent:
- 2:12a2907957b8
- Child:
- 5:c34ebc7f650c
--- a/DW1000.cpp Thu Feb 11 10:49:11 2016 +0000 +++ b/DW1000.cpp Tue Mar 29 10:00:23 2016 +0000 @@ -127,6 +127,21 @@ writeRegister16(DW1000_SYS_STATUS, 0, 0x6F00); // clearing of receiving status bits } +bool DW1000::hasTransmissionStarted() { + uint64_t status = getStatus(); + return status & 0x10; +} + +bool DW1000::hasSentPreamble() { + uint64_t status = getStatus(); + return status & 0x20; +} + +bool DW1000::hasSentPHYHeader() { + uint64_t status = getStatus(); + return status & 0x40; +} + bool DW1000::hasSentFrame() { uint64_t status = getStatus(); return status & 0x80; @@ -222,8 +237,7 @@ } void DW1000::sendDelayedFrame(uint8_t* message, uint16_t length, uint64_t TxTimestamp) { - if (TxTimestamp > CONST_2POWER40) - { + if (TxTimestamp > CONST_2POWER40) { TxTimestamp -= CONST_2POWER40; } @@ -236,9 +250,10 @@ length = ((backup & 0xFC) << 8) | (length & 0x03FF); writeRegister16(DW1000_TX_FCTRL, 0, length); + stopTRX(); // stop receiving + writeRegister40(DW1000_DX_TIME, 0, TxTimestamp); //write the timestamp on which to send the message - stopTRX(); // stop receiving writeRegister8(DW1000_SYS_CTRL, 0, 0x02 | 0x04); // trigger sending process by setting the TXSTRT and TXDLYS bit startRX(); // enable receiver again } @@ -248,7 +263,7 @@ } void DW1000::stopTRX() { - writeRegister8(DW1000_SYS_CTRL, 0, 0x40); // disable tranceiver go back to idle mode + writeRegister8(DW1000_SYS_CTRL, 0, 0x40); // disable tranceiver go back to idle mode by setting the TRXOFF bit } // PRIVATE Methods ------------------------------------------------------------------------------------