DW1000 UWB driver based on work of Matthias Grob & Manuel Stalder - ETH Zürich - 2015
Revision 10:f1e3c04080d6, committed 2016-08-01
- Comitter:
- AndyA
- Date:
- Mon Aug 01 08:45:36 2016 +0000
- Parent:
- 9:326bf149c8bc
- Child:
- 12:da4b09aff6af
- Commit message:
Changed in this revision
DW1000.cpp | Show annotated file Show diff for this revision Revisions of this file |
DW1000.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/DW1000.cpp Wed Apr 20 11:03:41 2016 +0000 +++ b/DW1000.cpp Mon Aug 01 08:45:36 2016 +0000 @@ -588,6 +588,17 @@ writeRegister32(DW1000_TX_FCTRL,0,frameCtrlValue); } +void DW1000::getFullQualityMetrics(uint16_t *std_noise, uint16_t *fp_amp1, uint16_t *fp_amp2, uint16_t *fp_amp3, + uint16_t *cir_pwr, uint16_t *preAmbleAcc, uint16_t *preAmbleAcc_NoSat) +{ + *fp_amp1 = readRegister16(DW1000_RX_TIME,7); + *std_noise = readRegister16(DW1000_RX_FQUAL,0); + *fp_amp2 = readRegister16(DW1000_RX_FQUAL,2); + *fp_amp3 = readRegister16(DW1000_RX_FQUAL,4); + *cir_pwr = readRegister16(DW1000_RX_FQUAL,6); + *preAmbleAcc = readRegister16(DW1000_RX_FINFO,4) >> 4; + *preAmbleAcc_NoSat = readRegister16(DW1000_DRX_CONF,DWDRX_RXPAC_NOSAT); +} #define SQR(x) ((float)(x) * (float)(x)) @@ -633,21 +644,14 @@ } -float DW1000::getRxQuality(uint16_t *sigAmp, uint16_t *noiseAmp) +#undef SQR + +void DW1000::getFirstPath(uint16_t *fp_amp2,uint16_t *fp_amp3) { - uint16_t firstPathAmp2 = readRegister16(DW1000_RX_FQUAL,2); - uint16_t noise = readRegister16(DW1000_RX_FQUAL,0); - if (sigAmp) - *sigAmp = firstPathAmp2; - if (noiseAmp) - *noiseAmp = noise; + *fp_amp2 = readRegister16(DW1000_RX_FQUAL,2); + *fp_amp3 = readRegister16(DW1000_RX_FQUAL,4); +} - if (noise > 0) - return SQR(firstPathAmp2)/(noise*100000.0f); - else - return 100; -} -#undef SQR void DW1000::setRxDelay(uint16_t ticks)
--- a/DW1000.h Wed Apr 20 11:03:41 2016 +0000 +++ b/DW1000.h Mon Aug 01 08:45:36 2016 +0000 @@ -45,7 +45,7 @@ /** Set the Extended Unique ID * @param EUI The EUID to use * - * Note - ID is only valid until the next power cycle and overrides the value in the OTP memory. + * @note ID is only valid until the next power cycle and overrides the value in the OTP memory. * To set a value that is automatically loaded on startup set OTP memory addresses 0 and 1. */ void setEUI(uint64_t EUI); // sets 64 bit Extended Unique Identifier according to IEEE standard @@ -112,9 +112,10 @@ * @return True if the write was sucessful. * * Writes the supplied data to the OTP memory and then reads it back to verify it was sucessfully programmed. - * WARNING - this is a one time operation for each memory address. + * @warning This is a one time operation for each memory address. * See Section 6.3.1 of the user manual for the memory map. - * It is recommened that the device is reset or power cycled after programing. + * + * @note It is recommened that the device is reset or power cycled after programing. */ bool writeOTP(uint16_t word_address,uint32_t data); // program a value in the OTP. It is recommended to reset afterwards. @@ -165,15 +166,10 @@ */ void getRxSignalPower(float *direct, float *total); - /** Get a metric of timestamp accuracy - * - * @param sigAmp Optional location to return the raw signal amplitude - * @param noiseAmp Optional location to return the raw channel noise level - * @return Timestamp quality metric - * - * The quality metric is a somewhat arbitary number based on channel noise and direct path strength - */ - float getRxQuality(uint16_t *sigAmp = NULL, uint16_t *noiseAmp = NULL); + + void getFullQualityMetrics(uint16_t *std_noise, uint16_t *fp_amp1, uint16_t *fp_amp2, uint16_t *fp_amp3, + uint16_t *cir_pwr, uint16_t *preAmbleAcc, uint16_t *preAmbleAcc_NoSat); + protected: @@ -309,10 +305,19 @@ * * The setup object supplied is copied and can be disposed of after the call. * If the supplied setup fails DW1000Setup::check() then it is ignored and the function returns false. - * Note - this will reset the radio. You must re-enable interupts, receiver etc. after calling it. + * @note This will reset the radio. You must re-enable interupts, receiver etc. after calling it. */ bool applySetup(DW1000Setup *setup); + + /** Get the first path amplitude values + * @param fp_amp2 Will be set to first path second peak amplitude + * @param fp_amp3 Will be set to first path third peak amplitude + * + * Reads the two registers for the last packet recieved. Used for quality metrics. + */ + void getFirstPath(uint16_t *fp_amp2,uint16_t *fp_amp3); + private: void resetAll(); // soft reset the entire DW1000 (some registers stay as they were see User Manual)