Tobi's ubw test branch

Dependencies:   mavlink_bridge mbed

Fork of AIT_UWB_Range by Benjamin Hepp

MMRanging/MMRanging.h

Committer:
manumaet
Date:
2015-02-20
Revision:
36:883de6f9a73b
Parent:
35:95d838d33bf5
Child:
37:40f94c634c3e

File content as of revision 36:883de6f9a73b:

// by Matthias Grob & Manuel Stalder - ETH Zürich - 2015

#ifndef MMRANGING_H
#define MMRANGING_H

#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

class MMRanging {
    public:
        MMRanging(DW1000& DW);
        void requestRanging(uint8_t destination);
    //private:
        DW1000& dw;
        
        void callbackRX();
        void callbackTX();
        void sendRangingframe(uint8_t destination, uint8_t sequence_number, uint8_t type, uint64_t time_difference_receiver);
        
        uint8_t address;
        struct rangingframe {
            uint8_t source;
            uint8_t destination;
            uint8_t sequence_number;
            uint8_t type;
            uint64_t time_difference_receiver;
        };
        
        uint64_t rangingtimingsSender[10][2];
        uint64_t rangingtimingsReceiver[10][2];
        uint64_t tofs;
        
        rangingframe TX;
        
        // draft for first test
        bool receiver;
        uint64_t TX_timestamp;
        uint64_t RX_timestamp;
        int event_i;
        char event[10][20];
        uint8_t counter;
};

#endif