mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 09:21: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:
@ -144,12 +144,6 @@ short *MMA7455::readData() {
|
||||
|
||||
int
|
||||
MMA7455::i2cReadReg (unsigned char reg, uint8_t *buffer, int len) {
|
||||
if (mraa::SUCCESS != m_i2ControlCtx.address(m_controlAddr)) {
|
||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": mraa_i2c_address() failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mraa::SUCCESS != m_i2ControlCtx.writeByte(reg)) {
|
||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": mraa_i2c_write_byte() failed");
|
||||
@ -167,12 +161,6 @@ MMA7455::i2cWriteReg (unsigned char reg, uint8_t *buffer, int len) {
|
||||
data[0] = reg;
|
||||
memcpy(&data[1], buffer, len);
|
||||
|
||||
error = m_i2ControlCtx.address (m_controlAddr);
|
||||
if (error != mraa::SUCCESS) {
|
||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": mraa_i2c_address() failed");
|
||||
return error;
|
||||
}
|
||||
error = m_i2ControlCtx.write (data, len + 1);
|
||||
if (error != mraa::SUCCESS) {
|
||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
|
Reference in New Issue
Block a user