diff --git a/src/shared/sensors/BMX160/BMX160.cpp b/src/shared/sensors/BMX160/BMX160.cpp index f175ad87342fb1dbbd7309c69b9a6ab683e20ad4..8d2ee05f3695a5a8a2b0b97c3a11531012940ff2 100644 --- a/src/shared/sensors/BMX160/BMX160.cpp +++ b/src/shared/sensors/BMX160/BMX160.cpp @@ -751,7 +751,7 @@ void BMX160::readFifo(bool headerless) uint64_t timestamp = 0; uint64_t watermarkTimestamp = 0; int idx = 0; - miosix::Lock<miosix::FastMutex> l(fifoMutex); + miosix::Lock<miosix::FastMutex> l(mutex); while (idx < len && buf[idx] != BMX160Defs::FIFO_STOP_BYTE) { diff --git a/src/shared/sensors/L3GD20/L3GD20.h b/src/shared/sensors/L3GD20/L3GD20.h index 5d50608e82ef884ae3ab6352f6580393339b2b5c..30409f27c88bd40bf25ffeb38356c053aca1552c 100644 --- a/src/shared/sensors/L3GD20/L3GD20.h +++ b/src/shared/sensors/L3GD20/L3GD20.h @@ -226,7 +226,7 @@ public: else // FIFO is enabled { // Lock mutex for thread safe Fifo reading - miosix::Lock<miosix::FastMutex> l(fifoMutex); + miosix::Lock<miosix::FastMutex> l(mutex); SPITransaction spi(spislave); // Read last fifo level diff --git a/src/shared/sensors/LSM6DSRX/LSM6DSRX.cpp b/src/shared/sensors/LSM6DSRX/LSM6DSRX.cpp index 9beacbe95f6d58cde5dbe06c80a8c86b915932df..d3d776dd8ac502e31e75536f2bd3c8f245f42001 100644 --- a/src/shared/sensors/LSM6DSRX/LSM6DSRX.cpp +++ b/src/shared/sensors/LSM6DSRX/LSM6DSRX.cpp @@ -793,7 +793,7 @@ float LSM6DSRX::getSensorTimestampResolution() void LSM6DSRX::readFromFifo() { // Lock mutex for thread safe Fifo reading - miosix::Lock<miosix::FastMutex> l(fifoMutex); + miosix::Lock<miosix::FastMutex> l(mutex); SPITransaction spi{spiSlave}; diff --git a/src/shared/sensors/Sensor.h b/src/shared/sensors/Sensor.h index 11cbf3709151a2509c243c5e2d34d86154381978..e740cf85b4c8668c5157ad42026a0f43f2fb3134 100644 --- a/src/shared/sensors/Sensor.h +++ b/src/shared/sensors/Sensor.h @@ -147,14 +147,15 @@ public: template <typename Data, uint32_t FifoSize> class SensorFIFO : public Sensor<Data> { + using Super = Sensor<Data>; + protected: std::array<Data, FifoSize> lastFifo; uint16_t lastFifoLevel = 1; //< number of samples in lastFifo uint64_t lastInterruptTimestamp = 0; uint64_t interruptTimestampDelta = - 0; //< delta between previous interrupt - // timestamp and the last received one - miosix::FastMutex fifoMutex; // thread safe mutex to read FIFO + 0; //< delta between previous interrupt + // timestamp and the last received one public: SensorFIFO() {} @@ -163,8 +164,7 @@ public: : lastFifo{std::move(other.lastFifo)}, lastFifoLevel{std::move(other.lastFifoLevel)}, lastInterruptTimestamp{std::move(other.lastInterruptTimestamp)}, - interruptTimestampDelta{std::move(other.interruptTimestampDelta)}, - fifoMutex{} + interruptTimestampDelta{std::move(other.interruptTimestampDelta)} { } @@ -174,7 +174,7 @@ public: */ const std::array<Data, FifoSize> getLastFifo(uint16_t& lastFifoSize) { - miosix::Lock<miosix::FastMutex> l(fifoMutex); + miosix::Lock<miosix::FastMutex> l(Super::mutex); lastFifoSize = lastFifoLevel; return lastFifo; }