mirror of
https://github.com/eclipse/upm.git
synced 2025-07-02 01:41:12 +03:00
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:
@ -79,11 +79,6 @@ upm_result_t mpr121_write_bytes(mpr121_context dev, uint8_t reg,
|
||||
for(i=1; i<(len + 1); i++)
|
||||
buf2[i] = buffer[i-1];
|
||||
|
||||
if(mraa_i2c_address(dev->i2c, dev->address) != MRAA_SUCCESS){
|
||||
printf("write byte error address\n");
|
||||
return UPM_ERROR_OPERATION_FAILED;
|
||||
}
|
||||
|
||||
if(mraa_i2c_write(dev->i2c, buf2, len+1) != MRAA_SUCCESS){
|
||||
printf("write byte error while writing\n");
|
||||
return UPM_ERROR_OPERATION_FAILED;
|
||||
|
@ -63,8 +63,6 @@ mraa::Result MPR121::writeBytes(uint8_t reg, uint8_t *buffer, int len)
|
||||
for (int i=1; i<(len + 1); i++)
|
||||
buf2[i] = buffer[i-1];
|
||||
|
||||
m_i2c.address(m_addr);
|
||||
|
||||
return m_i2c.write(buf2, len + 1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user