Tobi's ubw test branch
Dependencies: mavlink_bridge mbed
Fork of AIT_UWB_Range by
Diff: MMRanging/MMRanging.h
- Revision:
- 39:bb57aa77b015
- Parent:
- 37:40f94c634c3e
- Child:
- 40:5ce51b7e3118
--- a/MMRanging/MMRanging.h Sun Feb 22 11:41:18 2015 +0000 +++ b/MMRanging/MMRanging.h Sun Feb 22 17:40:38 2015 +0000 @@ -6,8 +6,10 @@ #include "mbed.h" #include "DW1000.h" -#define MMRANGING_TIMEUNIT_US 1/(128*499.2) // conversion between LSB of TX and RX timestamps and microseconds -#define MMRANGING_TIMEUNIT_NS 1000/(128*499.2) // conversion between LSB of TX and RX timestamps and nanoseconds +#define MMRANGING_TIMEUNIT_US 1/(128*499.2) // conversion between LSB of TX and RX timestamps and microseconds +#define MMRANGING_TIMEUNIT_NS 1000/(128*499.2) // conversion between LSB of TX and RX timestamps and nanoseconds + +#define MMRANGING_2POWER40 1099511627776 // decimal value of 2^40 to correct timeroverflow between timestamps class MMRanging { public: @@ -19,8 +21,9 @@ void callbackRX(); void callbackTX(); void sendRangingframe(uint8_t destination, uint8_t sequence_number, uint8_t type, uint64_t time_difference_receiver); + uint64_t timeDifference40Bit(uint64_t early, uint64_t late); // Method to calculate the difference between two 40-Bit timestamps correcting timer overflow reset between the timestamps - uint8_t address; + uint8_t address; // Identifies the node, source and destination in rangingframes struct rangingframe { uint8_t source; uint8_t destination; @@ -29,16 +32,13 @@ uint64_t time_difference_receiver; }; + rangingframe TX; // buffer in class for sending a frame (not made locally because then we can recall in the interrupt what was sent) uint64_t rangingtimingsSender[10][2]; uint64_t rangingtimingsReceiver[10][2]; - uint64_t tofs[10]; - - rangingframe TX; + uint64_t tofs[10]; // Array containing time of flights for each node (index is address of node) // draft for first test bool receiver; - uint64_t TX_timestamp; - uint64_t RX_timestamp; int event_i; char event[10][20]; uint8_t counter;