diff --git a/src/lib/drivers/device/qurt/I2C.cpp b/src/lib/drivers/device/qurt/I2C.cpp index c2b70f66d373..49c7cf430320 100644 --- a/src/lib/drivers/device/qurt/I2C.cpp +++ b/src/lib/drivers/device/qurt/I2C.cpp @@ -55,8 +55,6 @@ I2C::_config_i2c_bus_func_t I2C::_config_i2c_bus = NULL; I2C::_set_i2c_address_func_t I2C::_set_i2c_address = NULL; I2C::_i2c_transfer_func_t I2C::_i2c_transfer = NULL; -pthread_mutex_t I2C::_mutex = PTHREAD_MUTEX_INITIALIZER; - I2C::I2C(uint8_t device_type, const char *name, const int bus, const uint16_t address, const uint32_t frequency) : CDev(name, nullptr), _frequency(frequency / 1000) @@ -69,6 +67,8 @@ I2C::I2C(uint8_t device_type, const char *name, const int bus, const uint16_t ad _device_id.devid_s.bus = bus; _device_id.devid_s.address = address; + _mutex = PTHREAD_MUTEX_INITIALIZER; + PX4_INFO("*** I2C Device ID 0x%x %d", _device_id.devid, _device_id.devid); } diff --git a/src/lib/drivers/device/qurt/I2C.hpp b/src/lib/drivers/device/qurt/I2C.hpp index 7f1d59bc0a0b..a7cff9fc7c71 100644 --- a/src/lib/drivers/device/qurt/I2C.hpp +++ b/src/lib/drivers/device/qurt/I2C.hpp @@ -127,7 +127,7 @@ class __EXPORT I2C : public CDev static _config_i2c_bus_func_t _config_i2c_bus; static _set_i2c_address_func_t _set_i2c_address; static _i2c_transfer_func_t _i2c_transfer; - static pthread_mutex_t _mutex; + pthread_mutex_t _mutex; }; } // namespace device