Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DecaWave by
Diff: DW1000/DW1000.h
- Revision:
- 29:019ff388ed76
- Parent:
- 28:a830131560e8
- Child:
- 30:4ecc69d3cf8d
--- a/DW1000/DW1000.h Fri Nov 28 14:40:03 2014 +0000 +++ b/DW1000/DW1000.h Fri Nov 28 16:45:10 2014 +0000 @@ -54,7 +54,13 @@ class DW1000 { public: DW1000(PinName MOSI, PinName MISO, PinName SCLK, PinName CS, PinName IRQ); // constructor, uses SPI class - void setCallbacks(void (*callbackRX)(), void (*callbackTX)()); // setter for callback function pointer fields + 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 + callbackRX.attach(tptr, mptrRX); // possible client code: dw.setCallbacks(this, &A::callbackRX, &A::callbackTX); + callbackTX.attach(tptr, mptrTX); // concept seen in line 100 of http://developer.mbed.org/users/mbed_official/code/mbed/docs/4fc01daae5a5/InterruptIn_8h_source.html + setInterrupt(true,true); + } // Device API uint32_t getDeviceID(); // gets the Device ID which should be 0xDECA0130 (good for testing SPI!) @@ -62,7 +68,6 @@ void setEUI(uint64_t EUI); // sets 64 bit Extended Unique Identifier according to IEEE standard float getVoltage(); // gets the current chip voltage measurement form the A/D converter uint64_t getStatus(); // get the 40 bit device status - void setInterrupt(bool RX, bool TX); // set Interrupt for received a good frame (CRC ok) or transmission done uint64_t getRXTimestamp(); uint64_t getTXTimestamp(); @@ -72,15 +77,16 @@ void startRX(); // start listening for frames void stopTRX(); // disable tranceiver go back to idle mode - private: + //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 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 - void (*callbackRX)(); // function pointer to callback which is called when successfull RX took place - void (*callbackTX)(); // function pointer to callback which is called when successfull TX took place + 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 void ISR(); // interrupt handling method (also calls according callback methods) uint16_t getFramelength(); // to get the framelength of the received frame from the PHY header