diff --git a/drivers/include/drivers/I2C.h b/drivers/include/drivers/I2C.h index 96bf440..664e699 100644 --- a/drivers/include/drivers/I2C.h +++ b/drivers/include/drivers/I2C.h @@ -231,12 +231,10 @@ #if !defined(DOXYGEN_ONLY) protected: - void aquire(); i2c_t _i2c; - static I2C *_owner; int _hz; - static SingletonPtr _mutex; + SingletonPtr _mutex; PinName _sda; PinName _scl; diff --git a/drivers/source/I2C.cpp b/drivers/source/I2C.cpp index 4dd80b2..ae03c99 100644 --- a/drivers/source/I2C.cpp +++ b/drivers/source/I2C.cpp @@ -27,9 +27,6 @@ namespace mbed { -I2C *I2C::_owner = NULL; -SingletonPtr I2C::_mutex; - I2C::I2C(PinName sda, PinName scl) : #if DEVICE_I2C_ASYNCH _irq(this), _usage(DMA_USAGE_NEVER), _deep_sleep_locked(false), @@ -42,8 +39,6 @@ _scl = scl; recover(sda, scl); i2c_init(&_i2c, _sda, _scl); - // Used to avoid unnecessary frequency updates - _owner = this; unlock(); } @@ -59,8 +54,6 @@ _scl = static_pinmap.scl_pin; recover(static_pinmap.sda_pin, static_pinmap.scl_pin); i2c_init_direct(&_i2c, &static_pinmap); - // Used to avoid unnecessary frequency updates - _owner = this; unlock(); } @@ -72,18 +65,6 @@ // We want to update the frequency even if we are already the bus owners i2c_frequency(&_i2c, _hz); - // Updating the frequency of the bus we become the owners of it - _owner = this; - unlock(); -} - -void I2C::aquire() -{ - lock(); - if (_owner != this) { - i2c_frequency(&_i2c, _hz); - _owner = this; - } unlock(); } @@ -91,7 +72,6 @@ int I2C::write(int address, const char *data, int length, bool repeated) { lock(); - aquire(); int stop = (repeated) ? 0 : 1; int written = i2c_write(&_i2c, address, data, length, stop); @@ -112,7 +92,6 @@ int I2C::read(int address, char *data, int length, bool repeated) { lock(); - aquire(); int stop = (repeated) ? 0 : 1; int read = i2c_read(&_i2c, address, data, length, stop); @@ -137,7 +116,6 @@ void I2C::start(void) { lock(); - aquire(); i2c_start(&_i2c); unlock(); } @@ -215,7 +193,6 @@ return -1; // transaction ongoing } lock_deep_sleep(); - aquire(); _callback = callback; int stop = (repeated) ? 0 : 1;