diff options
author | Constantin Musca <constantin.musca@intel.com> | 2016-01-08 11:34:52 +0200 |
---|---|---|
committer | Bruce Beare <bruce.j.beare@intel.com> | 2016-01-09 07:47:11 -0800 |
commit | ff4b53d72766ac6a0d38acbe114ebc5170324c3e (patch) | |
tree | 6245a1733b26e23d2b7edbd81c1a80cd92ad796d | |
parent | 43c4d9da3dad3eff534e1a161b33af0170f78264 (diff) | |
download | intel-ff4b53d72766ac6a0d38acbe114ebc5170324c3e.tar.gz |
sensors: SensorUtils: use mraa to get default i2c bus
BUG=none
Change-Id: I967971bd76a31bb042a456a7aa7c2b61d6538d45
Tracked-On: https://jira01.devtools.intel.com/browse/BP-187
Signed-off-by: Constantin Musca <constantin.musca@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
-rw-r--r-- | peripheral/sensors/edison_arduino/SensorUtils.cpp | 30 | ||||
-rw-r--r-- | peripheral/sensors/edison_arduino/SensorUtils.hpp | 11 |
2 files changed, 2 insertions, 39 deletions
diff --git a/peripheral/sensors/edison_arduino/SensorUtils.cpp b/peripheral/sensors/edison_arduino/SensorUtils.cpp index 43a832b..662321e 100644 --- a/peripheral/sensors/edison_arduino/SensorUtils.cpp +++ b/peripheral/sensors/edison_arduino/SensorUtils.cpp @@ -17,34 +17,6 @@ #include <mraa.hpp> #include "SensorUtils.hpp" -const int kTriStateAllGpioPin = 214; -const int kArduinoI2cBusNumber = 6; -const int kNonArduinoI2cBusNumber = 1; - -bool SensorUtils::initialized = false; -int SensorUtils::i2cBusNumber = -1; - int SensorUtils::getI2cBusNumber() { - init(); - - return i2cBusNumber; -} - -void SensorUtils::init() { - if (!SensorUtils::initialized) { - mraa::Gpio *gpio = nullptr; - - try { - gpio = new mraa::Gpio(kTriStateAllGpioPin, true, true); - } catch(...) {} - - if (gpio == nullptr) { - i2cBusNumber = kNonArduinoI2cBusNumber; - } else { - delete gpio; - i2cBusNumber = kArduinoI2cBusNumber; - } - - SensorUtils::initialized = true; - } + return mraa_get_default_i2c_bus(MRAA_MAIN_PLATFORM_OFFSET); } diff --git a/peripheral/sensors/edison_arduino/SensorUtils.hpp b/peripheral/sensors/edison_arduino/SensorUtils.hpp index 96c835f..dcd48bb 100644 --- a/peripheral/sensors/edison_arduino/SensorUtils.hpp +++ b/peripheral/sensors/edison_arduino/SensorUtils.hpp @@ -18,7 +18,7 @@ #define SENSOR_UTILS_HPP /** - * Instantiable factory design pattern class for sensor utils + * Sensor utils class * * It supports retrieving the i2c sensors bus number */ @@ -29,15 +29,6 @@ class SensorUtils { * @return i2c bus number */ static int getI2cBusNumber(); - - private: - /* - * Initialize static members - */ - static void init(); - - static bool initialized; - static int i2cBusNumber; }; #endif // SENSOR_UTILS_HPP |