mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 01:11:10 +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:
@ -85,13 +85,7 @@ HDC1000::checkID(void)
|
||||
void
|
||||
HDC1000::resetSensor(void)
|
||||
{
|
||||
mraa::Result ret = m_i2ControlCtx.address(m_controlAddr);
|
||||
if (ret != mraa::SUCCESS) {
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_i2c_address() failed");
|
||||
}
|
||||
|
||||
ret = m_i2ControlCtx.writeByte(0);
|
||||
mraa::Result ret = m_i2ControlCtx.writeByte(0);
|
||||
if (ret != mraa::SUCCESS) {
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_i2c_write_byte() failed");
|
||||
@ -108,12 +102,6 @@ HDC1000::sampleData(void)
|
||||
|
||||
resetSensor();
|
||||
|
||||
mraa::Result ret = m_i2ControlCtx.address(m_controlAddr);
|
||||
if (ret != mraa::SUCCESS) {
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_i2c_address() failed");
|
||||
}
|
||||
|
||||
re = m_i2ControlCtx.read(itemp, 4);
|
||||
if (re != 4) {
|
||||
/* not enough bytes were read! */
|
||||
|
Reference in New Issue
Block a user