Tobi's ubw test branch
Dependencies: mavlink_bridge mbed
Fork of AIT_UWB_Range by
Diff: DW1000/DW1000.h
- Revision:
- 48:5999e510f154
- Parent:
- 44:2e0045042a59
- Child:
- 54:a59803fcce58
--- a/DW1000/DW1000.h Thu Mar 19 12:54:28 2015 +0000 +++ b/DW1000/DW1000.h Tue Nov 24 16:41:23 2015 +0000 @@ -4,6 +4,7 @@ #define DW1000_H #include "mbed.h" +#include "InterruptMultiplexer.h" // register addresses // Mnemonic Address Bytes Description @@ -53,7 +54,8 @@ class DW1000 { public: - DW1000(PinName MOSI, PinName MISO, PinName SCLK, PinName CS, PinName IRQ); // constructor, uses SPI class + DW1000(SPI& spi, InterruptMultiplexer& irq_mp, PinName CS, PinName RESET = NC); // constructor, uses SPI class + void setCallbacks(void (*callbackRX)(void), void (*callbackTX)(void)); // setter for callback functions, automatically enables interrupt, if NULL is passed the coresponding interrupt gets disabled template<typename T> void setCallbacks(T* tptr, void (T::*mptrRX)(void), void (T::*mptrTX)(void)) { // overloaded setter to treat member function pointers of objects @@ -70,6 +72,15 @@ uint64_t getStatus(); // get the 40 bit device status uint64_t getRXTimestamp(); uint64_t getTXTimestamp(); + + uint16_t DW1000::getStdNoise(); + uint16_t DW1000::getPACC(); + uint16_t DW1000::getFPINDEX(); + uint16_t DW1000::getFPAMPL1(); + uint16_t DW1000::getFPAMPL2(); + uint16_t DW1000::getFPAMPL3(); + uint16_t DW1000::getCIRPWR(); + uint8_t DW1000::getPRF(); void sendString(char* message); // to send String with arbitrary length void receiveString(char* message); // to receive char string (length of the buffer must be 1021 to be safe) @@ -81,10 +92,12 @@ //private: void loadLDE(); // load the leading edge detection algorithm to RAM, [IMPORTANT because receiving malfunction may occur] see User Manual LDELOAD on p22 & p158 void resetRX(); // soft reset only the tranciever part of DW1000 + static void hardwareReset(PinName reset_pin); void resetAll(); // soft reset the entire DW1000 (some registers stay as they were see User Manual) // Interrupt - InterruptIn irq; // Pin used to handle Events from DW1000 by an Interrupthandler + InterruptMultiplexer& irq_mp; + int irq_index; FunctionPointer callbackRX; // function pointer to callback which is called when successfull RX took place FunctionPointer callbackTX; // function pointer to callback which is called when successfull TX took place void setInterrupt(bool RX, bool TX); // set Interrupt for received a good frame (CRC ok) or transmission done @@ -92,11 +105,13 @@ uint16_t getFramelength(); // to get the framelength of the received frame from the PHY header // SPI Inteface - SPI spi; // SPI Bus + SPI& spi; // SPI Bus DigitalOut cs; // Slave selector for SPI-Bus (here explicitly needed to start and end SPI transactions also usable to wake up DW1000) + DigitalOut reset; uint8_t readRegister8(uint8_t reg, uint16_t subaddress); // expressive methods to read or write the number of bits written in the name uint16_t readRegister16(uint8_t reg, uint16_t subaddress); + uint32_t readRegister32(uint8_t reg, uint16_t subaddress); uint64_t readRegister40(uint8_t reg, uint16_t subaddress); void writeRegister8(uint8_t reg, uint16_t subaddress, uint8_t buffer); void writeRegister16(uint8_t reg, uint16_t subaddress, uint16_t buffer); @@ -108,6 +123,8 @@ void setupTransaction(uint8_t reg, uint16_t subaddress, bool write); // sets up an SPI read or write transaction with correct register address and offset void select(); // selects the only slave for a transaction void deselect(); // deselects the only slave after transaction + void enable_irq(); + void disable_irq(); }; #endif \ No newline at end of file