Tobi's ubw test branch
Dependencies: mavlink_bridge mbed
Fork of AIT_UWB_Range by
main.cpp
- Committer:
- manumaet
- Date:
- 2015-03-05
- Revision:
- 44:2e0045042a59
- Parent:
- 43:d89fe237a684
- Child:
- 45:01a33363bc21
File content as of revision 44:2e0045042a59:
// by Matthias Grob & Manuel Stalder - ETH Zürich - 2015 #include "mbed.h" #include "PC.h" // Serial Port via USB for debugging with Terminal #include "DW1000.h" // our DW1000 device driver #include "MM2WayRanging.h" // our self developed ranging application #define myprintf pc.printf // to make the code adaptable to other outputs that support printf PC pc(USBTX, USBRX, 921600); // USB UART Terminal DW1000 dw(PA_7, PA_6, PA_5, PB_6, PB_9); // Device driver instanceSPI pins: (MOSI, MISO, SCLK, CS, IRQ) MM2WayRanging node(dw); // Instance of the two way ranging algorithm void rangeAndDisplayAll(){ node.requestRangingAll(); // Request ranging to all anchors for (int i = 1; i <= 4; i++) { // Output Results myprintf("D: %f, ", node.distances[i]); myprintf("T:%f", node.roundtriptimes[i]); myprintf("\r\n"); } myprintf("\r\n\n"); } int main() { pc.printf("\r\nDecaWave 1.0 up and running!\r\n"); // Splashscreen dw.setEUI(0xFAEDCD01FAEDCD01); // basic methods called to check if we have a working SPI connection pc.printf("DEVICE_ID register: 0x%X\r\n", dw.getDeviceID()); pc.printf("EUI register: %016llX\r\n", dw.getEUI()); pc.printf("Voltage: %fV\r\n", dw.getVoltage()); node.isAnchor = true; // declare as anchor or beacon if (node.isAnchor) { node.address = 1; myprintf("This node is Anchor node %d \r\n", node.address); } else { node.address = 0; myprintf("This node is a Beacon. "); } while(1) { if (!node.isAnchor) rangeAndDisplayAll(); else myprintf(".\r"); wait(0.3); } }