diff options
author | David Crocker <dcrocker@eschertech.com> | 2022-03-31 13:28:59 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2022-03-31 13:28:59 +0300 |
commit | 84fa543a3d4b32494420653964b555f1d882ade6 (patch) | |
tree | 786a96cb0d060a57331305c0f5ed5ad08a464a47 | |
parent | 7de38b71a81428698c2f0be07958c9150e64e06a (diff) |
Added missing error check when collecting accelerometer data
-rw-r--r-- | src/Accelerometers/LIS3DH.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Accelerometers/LIS3DH.cpp b/src/Accelerometers/LIS3DH.cpp index 8602ea25..b92bfcbd 100644 --- a/src/Accelerometers/LIS3DH.cpp +++ b/src/Accelerometers/LIS3DH.cpp @@ -167,14 +167,17 @@ bool LIS3DH::Configure(uint16_t& samplingRate, uint8_t& resolution) noexcept void Int1Interrupt(CallbackParameter p) noexcept; // forward declaration -// Start collecting data +// Start collecting data, returning true if successful bool LIS3DH:: StartCollecting(uint8_t axes) noexcept { // Clear the fifo uint8_t val; while (ReadRegister(LisRegister::FifoSource, val) && (val & (1u << 5)) == 0) // while fifo not empty { - ReadRegisters(LisRegister::OutXL, 6); + if (!ReadRegisters(LisRegister::OutXL, 6)) + { + return false; + } } totalNumRead = 0; |