Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mavlink_bridge mbed
Fork of AIT_UWB_Range by
Diff: DW1000/DW1000.cpp
- Revision:
- 29:019ff388ed76
- Parent:
- 28:a830131560e8
- Child:
- 31:6f76f3d518ac
diff -r a830131560e8 -r 019ff388ed76 DW1000/DW1000.cpp
--- a/DW1000/DW1000.cpp Fri Nov 28 14:40:03 2014 +0000
+++ b/DW1000/DW1000.cpp Fri Nov 28 16:45:10 2014 +0000
@@ -17,9 +17,18 @@
irq.rise(this, &DW1000::ISR); // attach Interrupt handler to rising edge
}
-void DW1000::setCallbacks(void (*callbackRX)(), void (*callbackTX)()) {
- DW1000::callbackRX = callbackRX;
- DW1000::callbackTX = callbackTX;
+void DW1000::setCallbacks(void (*callbackRX)(void), void (*callbackTX)(void)) {
+ bool RX = false;
+ bool TX = false;
+ if (callbackRX) {
+ DW1000::callbackRX.attach(callbackRX);
+ RX = true;
+ }
+ if (callbackTX) {
+ DW1000::callbackTX.attach(callbackTX);
+ TX = true;
+ }
+ setInterrupt(RX,TX);
}
uint32_t DW1000::getDeviceID() {
@@ -54,10 +63,6 @@
return readRegister40(DW1000_SYS_STATUS, 0);
}
-void DW1000::setInterrupt(bool RX, bool TX) {
- writeRegister16(DW1000_SYS_MASK, 0, RX*0x4000 | TX*0x0080); // RX good frame 0x4000, TX done 0x0080
-}
-
uint64_t DW1000::getRXTimestamp() {
return readRegister40(DW1000_RX_TIME, 0);
}
@@ -117,17 +122,19 @@
writeRegister8(DW1000_PMSC, 3, 0xF0); // clear All reset
}
+
+void DW1000::setInterrupt(bool RX, bool TX) {
+ writeRegister16(DW1000_SYS_MASK, 0, RX*0x4000 | TX*0x0080); // RX good frame 0x4000, TX done 0x0080
+}
+
void DW1000::ISR() {
uint64_t status = getStatus();
if (status & 0x4000) { // a frame was received
- if (callbackRX != NULL)
- callbackRX();
+ callbackRX.call();
writeRegister16(DW1000_SYS_STATUS, 0, 0x6F00); // clearing of receiving status bits
}
if (status & 0x80) { // sending complete
- //startRX(); // enable receiver again if we need to preserve state TODO: have to do it here??
- if (callbackTX != NULL)
- callbackTX();
+ callbackTX.call();
writeRegister8(DW1000_SYS_STATUS, 0, 0xF8); // clearing of sending status bits
}
}
