Tobi's ubw test branch
Dependencies: mavlink_bridge mbed
Fork of AIT_UWB_Range by
main.cpp@34:f56962030c5c, 2014-12-27 (annotated)
- Committer:
- manumaet
- Date:
- Sat Dec 27 14:37:12 2014 +0000
- Revision:
- 34:f56962030c5c
- Parent:
- 33:6ea4c3dd504d
- Child:
- 35:95d838d33bf5
when merging to eclipse & svn
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 | 30:4ecc69d3cf8d | 8 | DW1000 dw(PA_7, PA_6, PA_5, PB_6, PB_9); // Device driver instanceSPI pins: (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 | 0:f50e671ffff7 | 13 | int main() { |
manumaet | 27:71178fdb78e1 | 14 | pc.printf("DecaWave 0.2\r\nup and running!\r\n"); |
manumaet | 30:4ecc69d3cf8d | 15 | dw.setEUI(0xFAEDCD01FAEDCD01); // basic methods called to check if we have a working SPI connection |
manumaet | 28:a830131560e8 | 16 | pc.printf("DEVICE_ID register: 0x%X\r\n", dw.getDeviceID()); |
manumaet | 28:a830131560e8 | 17 | pc.printf("EUI register: %016llX\r\n", dw.getEUI()); |
manumaet | 28:a830131560e8 | 18 | pc.printf("Voltage: %f\r\n", dw.getVoltage()); |
manumaet | 34:f56962030c5c | 19 | pc.printf("Size of Frame: %d\r\n", sizeof(r.TX)); |
manumaet | 34:f56962030c5c | 20 | |
manumaet | 34:f56962030c5c | 21 | uint16_t setdelay = 65500; |
manumaet | 34:f56962030c5c | 22 | dw.writeRegister16(DW1000_TX_ANTD, 0, setdelay); |
manumaet | 34:f56962030c5c | 23 | pc.printf("Antenna Delay TX: %d\r\n", dw.readRegister16(DW1000_TX_ANTD, 0)); |
manumaet | 34:f56962030c5c | 24 | pc.printf("Antenna Delay RX: %d\r\n", dw.readRegister16(DW1000_LDE_CTRL, 0x1804)); |
manumaet | 34:f56962030c5c | 25 | r.receiver = true; |
manumaet | 32:041dd02e0e3b | 26 | |
manumaet | 31:6f76f3d518ac | 27 | bool senderstart = true; |
manumaet | 0:f50e671ffff7 | 28 | while(1) { |
manumaet | 26:a65c6f26c458 | 29 | for(int j = 0; j < 10; j++) |
manumaet | 34:f56962030c5c | 30 | pc.printf("%d ", (unsigned int)r.tofs[j]); |
manumaet | 31:6f76f3d518ac | 31 | pc.printf("\r\n"); |
manumaet | 31:6f76f3d518ac | 32 | for(int j = 0; j < 10; j++) |
manumaet | 28:a830131560e8 | 33 | if(r.event[j][0] == '!') { |
manumaet | 34:f56962030c5c | 34 | pc.printf("%s Time: %lldus\r\n", r.event[j], r.eventtimes[j]); |
manumaet | 28:a830131560e8 | 35 | r.event[j][0] = 'X'; |
manumaet | 24:6f25ba679490 | 36 | } |
manumaet | 28:a830131560e8 | 37 | if (!r.receiver) { |
manumaet | 31:6f76f3d518ac | 38 | if(senderstart) |
manumaet | 31:6f76f3d518ac | 39 | r.requestRanging(); |
manumaet | 31:6f76f3d518ac | 40 | else |
manumaet | 31:6f76f3d518ac | 41 | r.requestTime(); |
manumaet | 31:6f76f3d518ac | 42 | senderstart = !senderstart; |
manumaet | 28:a830131560e8 | 43 | } |
manumaet | 31:6f76f3d518ac | 44 | pc.printf("Status: %llX\r\n", dw.getStatus()); |
manumaet | 31:6f76f3d518ac | 45 | wait(2); |
manumaet | 0:f50e671ffff7 | 46 | } |
manumaet | 0:f50e671ffff7 | 47 | } |