DW1000 UWB driver based on work of Matthias Grob & Manuel Stalder - ETH Zürich - 2015
Diff: DW1000.h
- Revision:
- 3:1459d2aa6b97
- Parent:
- 1:dcbd071f38d5
- Child:
- 4:5f1025df5530
--- a/DW1000.h Tue Apr 05 11:37:23 2016 +0000 +++ b/DW1000.h Thu Apr 07 14:31:28 2016 +0000 @@ -152,7 +152,22 @@ #define DW1000_SUBADDRESS_FLAG 0x40 // if we have a sub address second Bit has to be 1 #define DW1000_2_SUBADDRESS_FLAG 0x80 // if we have a long sub adress (more than 7 Bit) we set this Bit in the first part -typedef enum {defaultConfig, tunedDefault, user110k} UWBMode; +/* +From user manual 10.5 +Table 59: +DW1000 supported UWB channels and recommended preamble codes + +channel 16MHzPrf 64MHzPrf +1 1,2 9, 10, 11, 12 +2 3, 4 9, 10, 11, 12 +3 5, 6 9, 10, 11, 12 +4 7, 8 17, 18, 19, 20 +5 3, 4 9, 10, 11, 12 +7 7, 8 17, 18, 19, 20 +*/ + + +typedef enum {minPacketSize, tunedDefault, user110k} UWBMode; class DW1000 { @@ -204,11 +219,54 @@ void resetRX(); // soft reset only the tranciever part of DW1000 void setInterrupt(bool RX, bool TX); // set Interrupt for received a good frame (CRC ok) or transmission done + /** Set Transmit gain + * + * @param normalPowercB Normal transmit gain to use. + * @param boost500 Gain to use for 6.8Mb/s packets of under 500ms. + * @param boost250 Gain to use for 6.8Mb/s packets of under 250ms. + * @param boost125 Gain to use for 6.8Mb/s packets of under 125ms. + * + * All gains are in cB (dB * 10). Gains can be between 0 and 335 (33.5dB). + * Boost gains are optional, if not specified boost gains are set to the power for the lower rate (e.g. boost125 is set to the boost250 level). + */ + void setTxPower(uint16_t normalPowercB, uint16_t boost500 = 0, uint16_t boost250 = 0, uint16_t boost125 = 0); + private: void resetAll(); // soft reset the entire DW1000 (some registers stay as they were see User Manual) + + void setupRadio(); + + // system register setup functions + void setupAGC(); + void setupRxConfig(); + void setupLDE(); + void setupChannel(); + void setupTxFrameCtrl(); + void setupAnalogRF(); + void setupFreqSynth(); + void setupTxCalibration(); + void setupSystemConfig(); void loadLDE(); // load the leading edge detection algorithm to RAM, [IMPORTANT because receiving malfunction may occur] see User Manual LDELOAD on p22 & p158 void loadLDOTUNE(); // load the LDO tuning as set in the factory + + uint8_t powerToRegValue(uint16_t powercB); + + enum prf_e {prf16MHz,prf64MHz}; + enum dataRate_e {kbps110,kbps850,kbps6800}; + enum sfd_e {standard, nonStandard}; + enum preamble_e { pre64, pre128, pre256, pre512, pre1024, pre1536, pre2048, pre4096}; + + struct { + unsigned char channel; // 1-5 , 7 + enum prf_e prf; + enum dataRate_e dataRate; + enum sfd_e sfd; + enum preamble_e preamble; + unsigned char preambleCode; // 1-24. See section 10.5 of user manual for details. + bool enableSmartPower; + } systemConfig; + // Interrupt