This is the DW1000 driver and our self developed distance measurement application based on it. We do this as a semester thesis at ETH Zürich under the Automatic Control Laboratory in the Department of electrical engineering.
main.cpp@28:a830131560e8, 2014-11-28 (annotated)
- Committer:
- manumaet
- Date:
- Fri Nov 28 14:40:03 2014 +0000
- Revision:
- 28:a830131560e8
- Parent:
- 27:71178fdb78e1
- Child:
- 29:019ff388ed76
after setting up a test MMRanging class, problem with member function pointers
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
manumaet | 24:6f25ba679490 | 1 | // by Matthias Grob & Manuel Stalder - ETH Zürich - 2015 |
manumaet | 0:f50e671ffff7 | 2 | #include "mbed.h" |
manumaet | 26:a65c6f26c458 | 3 | #include "PC.h" // Serial Port via USB for debugging with Terminal |
manumaet | 27:71178fdb78e1 | 4 | #include "DW1000.h" // our DW1000 device driver |
manumaet | 27:71178fdb78e1 | 5 | #include "MMRanging.h" // our self developed raning application |
manumaet | 0:f50e671ffff7 | 6 | |
manumaet | 26:a65c6f26c458 | 7 | PC pc(USBTX, USBRX, 921600); // USB UART Terminal |
manumaet | 26:a65c6f26c458 | 8 | DW1000 dw(PA_7, PA_6, PA_5, PB_6, PB_9); // SPI1 on Nucleo Board (MOSI, MISO, SCLK, CS, IRQ) |
manumaet | 28:a830131560e8 | 9 | MMRanging r(dw); // Ranging class for getting distances and later positions |
manumaet | 14:8041c9b68406 | 10 | |
manumaet | 28:a830131560e8 | 11 | char message[100] = ""; |
manumaet | 6:d5864a1b9e17 | 12 | |
manumaet | 28:a830131560e8 | 13 | void callbackRX() {r.callbackRX();} // TODO: solve cast from memebr function pointer to function pointer |
manumaet | 28:a830131560e8 | 14 | void callbackTX() {r.callbackTX();} |
manumaet | 18:bbc7ca7d3a95 | 15 | |
manumaet | 0:f50e671ffff7 | 16 | int main() { |
manumaet | 27:71178fdb78e1 | 17 | pc.printf("DecaWave 0.2\r\nup and running!\r\n"); |
manumaet | 20:257d56530ae1 | 18 | dw.setEUI(0xFAEDCD01FAEDCD01); // basic methods called to check if we have a working SPI connection |
manumaet | 28:a830131560e8 | 19 | pc.printf("DEVICE_ID register: 0x%X\r\n", dw.getDeviceID()); |
manumaet | 28:a830131560e8 | 20 | pc.printf("EUI register: %016llX\r\n", dw.getEUI()); |
manumaet | 28:a830131560e8 | 21 | pc.printf("Voltage: %f\r\n", dw.getVoltage()); |
manumaet | 28:a830131560e8 | 22 | |
manumaet | 28:a830131560e8 | 23 | r.receiver = true; |
manumaet | 26:a65c6f26c458 | 24 | dw.setCallbacks(&callbackRX, &callbackTX); |
manumaet | 5:111f11c95d27 | 25 | |
manumaet | 0:f50e671ffff7 | 26 | while(1) { |
manumaet | 26:a65c6f26c458 | 27 | for(int j = 0; j < 10; j++) |
manumaet | 28:a830131560e8 | 28 | if(r.event[j][0] == '!') { |
manumaet | 28:a830131560e8 | 29 | pc.printf("%s Time: %fus\r\n", r.event[j], r.eventtimes[j]*MMRANGING_TIMEUNIT); |
manumaet | 28:a830131560e8 | 30 | r.event[j][0] = 'X'; |
manumaet | 24:6f25ba679490 | 31 | } |
manumaet | 28:a830131560e8 | 32 | if (!r.receiver) { |
manumaet | 28:a830131560e8 | 33 | r.requestRanging(); |
manumaet | 28:a830131560e8 | 34 | wait(1); |
manumaet | 28:a830131560e8 | 35 | } |
manumaet | 0:f50e671ffff7 | 36 | } |
manumaet | 0:f50e671ffff7 | 37 | } |