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

@ -240,7 +240,6 @@ void LP8860::allowMaxCurrent()
void LP8860::i2cWriteByte(int reg, int value)
{
i2c->address(LP8860_I2C_ADDR);
status = i2c->writeReg(static_cast<uint8_t>(reg), static_cast<uint8_t>(value));
if (status != mraa::SUCCESS)
UPM_THROW("i2cWriteByte failed");
@ -250,7 +249,6 @@ void LP8860::i2cWriteByte(int reg, int value)
uint8_t LP8860::i2cReadByte(uint8_t reg)
{
uint8_t value;
i2c->address(LP8860_I2C_ADDR);
if (i2c->readBytesReg(reg, &value, 1) != 1)
UPM_THROW("i2cReadByte failed");
return value;
@ -264,7 +262,6 @@ void LP8860::i2cWriteBuffer(int reg, uint8_t* buf, int length)
uint8_t* writeBuf = new unsigned char[length + 1];
writeBuf[0] = reg;
memcpy(&writeBuf[1], buf, length);
i2c->address(LP8860_I2C_ADDR);
status = i2c->write(writeBuf, length + 1);
delete[] writeBuf;
}
@ -277,7 +274,6 @@ void LP8860::i2cWriteBuffer(int reg, uint8_t* buf, int length)
void LP8860::i2cReadBuffer(int reg, uint8_t* buf, int length)
{
i2c->address(LP8860_I2C_ADDR);
if (i2c->readBytesReg(reg, buf, length) != length)
UPM_THROW("i2cReadBuffer failed");
}