I2C: Removing multiple address calls

~20 UPM modules have multiple I2C calls in them. As per MRAA API
the I2C address is set in the MRAA I2C context and used from there
for all I2C transactions. Setting the I2C address alone does not
actually result in an I2C transaction. This makes multiple set
address calls pointless. This commit removes these superflous set
address calls from the UPM modules. Setting the address once per
context per device should be enough, unless there are multiple
addresses or multiple devices with different addresses.

Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
This commit is contained in:
Abhishek Malik
2017-05-31 11:47:23 -07:00
parent da18bac925
commit 50bb4ae1be
22 changed files with 2 additions and 161 deletions

View File

@ -54,7 +54,6 @@ void
HTU21D::resetSensor(void)
{
uint8_t data = HTU21D_SOFT_RESET;
m_i2ControlCtx.address (m_controlAddr);
m_i2ControlCtx.write (&data, 1);
usleep(20000);
}
@ -259,7 +258,6 @@ HTU21D::i2cWriteReg (uint8_t reg, uint8_t value) {
mraa::Result error = mraa::SUCCESS;
uint8_t data[2] = { reg, value };
m_i2ControlCtx.address (m_controlAddr);
error = m_i2ControlCtx.write (data, 2);
if ( error != mraa::SUCCESS)
throw std::invalid_argument(std::string(__FUNCTION__) +
@ -270,13 +268,11 @@ HTU21D::i2cWriteReg (uint8_t reg, uint8_t value) {
uint16_t
HTU21D::i2cReadReg_16 (int reg) {
m_i2ControlCtx.address(m_controlAddr);
return m_i2ControlCtx.readWordReg(reg);
}
uint8_t
HTU21D::i2cReadReg_8 (int reg) {
m_i2ControlCtx.address(m_controlAddr);
return m_i2ControlCtx.readReg(reg);
}