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:
@ -77,10 +77,8 @@ uint8_t
|
||||
MAX44000::i2cReadReg_8 (int reg) {
|
||||
uint8_t data;
|
||||
|
||||
m_i2cMaxControlCtx.address(m_maxControlAddr);
|
||||
m_i2cMaxControlCtx.writeByte(reg);
|
||||
|
||||
m_i2cMaxControlCtx.address(m_maxControlAddr);
|
||||
m_i2cMaxControlCtx.read(&data, 0x1);
|
||||
|
||||
return data;
|
||||
@ -90,10 +88,8 @@ uint16_t
|
||||
MAX44000::i2cReadReg_16 (int reg) {
|
||||
uint16_t data;
|
||||
|
||||
m_i2cMaxControlCtx.address(m_maxControlAddr);
|
||||
m_i2cMaxControlCtx.writeByte(reg);
|
||||
|
||||
m_i2cMaxControlCtx.address(m_maxControlAddr);
|
||||
m_i2cMaxControlCtx.read((uint8_t *)&data, 0x2);
|
||||
|
||||
return data;
|
||||
@ -104,7 +100,6 @@ MAX44000::i2cWriteReg (uint8_t reg, uint8_t value) {
|
||||
mraa::Result error = mraa::SUCCESS;
|
||||
|
||||
uint8_t data[2] = { reg, value };
|
||||
error = m_i2cMaxControlCtx.address (m_maxControlAddr);
|
||||
error = m_i2cMaxControlCtx.write (data, 2);
|
||||
|
||||
return error;
|
||||
|
Reference in New Issue
Block a user