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

@ -104,12 +104,6 @@ Adxl345::Adxl345(int bus) : m_i2c(bus)
return;
}
if ( m_i2c.address(ADXL345_I2C_ADDR) != mraa::SUCCESS ){
throw std::invalid_argument(std::string(__FUNCTION__) +
": i2c.address() failed");
return;
}
m_buffer[0] = ADXL345_DATA_FORMAT;
m_buffer[1] = ADXL345_16G | ADXL345_FULL_RES;
if( m_i2c.write(m_buffer, 2) != mraa::SUCCESS){
@ -148,10 +142,8 @@ Adxl345::getScale(){
uint8_t result;
m_i2c.address(ADXL345_I2C_ADDR);
m_i2c.writeByte(ADXL345_DATA_FORMAT);
m_i2c.address(ADXL345_I2C_ADDR);
result = m_i2c.readByte();
return pow(2, (result & 0x03) + 1);
@ -160,10 +152,8 @@ Adxl345::getScale(){
mraa::Result
Adxl345::update(void)
{
m_i2c.address(ADXL345_I2C_ADDR);
m_i2c.writeByte(ADXL345_XOUT_L);
m_i2c.address(ADXL345_I2C_ADDR);
m_i2c.read(m_buffer, DATA_REG_SIZE);
// x