Tobi's ubw test branch
Dependencies: mavlink_bridge mbed
Fork of AIT_UWB_Range by
Diff: DW1000/DW1000.cpp
- Revision:
- 22:576ee999b004
- Parent:
- 21:23bf4399020d
- Child:
- 23:661a79e56208
--- a/DW1000/DW1000.cpp Wed Nov 26 12:10:09 2014 +0000 +++ b/DW1000/DW1000.cpp Thu Nov 27 13:28:18 2014 +0000 @@ -72,22 +72,21 @@ length = ((backup & 0xFC) << 8) | (length & 0x03FF); writeRegister16(DW1000_TX_FCTRL, 0, length); - /*if (receiving)*/ stopTRX(); // stop receiving if we are in this state - //sending = true; - wait(0.01); - writeRegister8(DW1000_SYS_CTRL, 0, 0x02); // trigger sending process by setting the TXSTRT bit - wait(0.01); + if (receiving) stopTRX(); // stop receiving if we are in this state + sending = true; + //writeRegister8(DW1000_SYS_CTRL, 0, 0x02); // trigger sending process by setting the TXSTRT bit + //if (receiving) startRX(); } void DW1000::startRX() { //while(sending); // block until sending finished TODO: the right way?? - //receiving = true; + receiving = true; writeRegister8(DW1000_SYS_CTRL, 0x01, 0x01); // start listening for preamble by setting the RXENAB bit } void DW1000::stopRX() { + receiving = false; stopTRX(); - //receiving = false; } // PRIVATE Methods ------------------------------------------------------------------------------------ @@ -116,18 +115,18 @@ void DW1000::ISR() { uint64_t status = getStatus(); - if (status & 0x4000) { + if (status & 0x4000) { // a frame was received if (callbackRX != NULL) callbackRX(getFramelength()); + writeRegister16(DW1000_SYS_STATUS, 0, 0x6F00); // clearing of receiving status bits } - if (status & 0x80) { + if (status & 0x80) { // sending complete sending = false; - wait(0.1); - /*if (receiving)*/ startRX(); // enable receiver again if we need to preserve state TODO: have to do it here?? + if (receiving) startRX(); // enable receiver again if we need to preserve state TODO: have to do it here?? if (callbackTX != NULL) callbackTX(); + writeRegister8(DW1000_SYS_STATUS, 0, 0xF8); // clearing of sending status bits } - //writeRegister16(DW1000_SYS_STATUS, 0, 0x1111); // TODO: clearing status bits not necessary? } uint16_t DW1000::getFramelength() {