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:
@ -115,11 +115,6 @@ upm_result_t tsl2561_get_lux(const tsl2561_context dev, float* lux){
|
||||
|
||||
upm_result_t tsl2561_i2c_write_reg(tsl2561_context dev, uint8_t reg,
|
||||
uint8_t value){
|
||||
// Start transmission to device
|
||||
if(mraa_i2c_address(dev->i2c, dev->address) != MRAA_SUCCESS){
|
||||
return UPM_ERROR_OPERATION_FAILED;
|
||||
}
|
||||
|
||||
// Write register to I2C
|
||||
if(mraa_i2c_write_byte(dev->i2c, reg) != MRAA_SUCCESS){
|
||||
return UPM_ERROR_OPERATION_FAILED;
|
||||
@ -136,11 +131,6 @@ upm_result_t tsl2561_i2c_write_reg(tsl2561_context dev, uint8_t reg,
|
||||
|
||||
upm_result_t tsl2561_i2c_read_reg(tsl2561_context dev, uint8_t reg,
|
||||
uint8_t* data){
|
||||
// Start transmission to dev
|
||||
if(mraa_i2c_address(dev->i2c, dev->address) != MRAA_SUCCESS){
|
||||
return UPM_ERROR_OPERATION_FAILED;
|
||||
}
|
||||
|
||||
// Send address of register to be read.
|
||||
if(mraa_i2c_write_byte(dev->i2c, reg) != MRAA_SUCCESS){
|
||||
return UPM_ERROR_OPERATION_FAILED;
|
||||
|
@ -195,12 +195,6 @@ TSL2561::i2cWriteReg (uint8_t reg, uint8_t value)
|
||||
{
|
||||
mraa::Result error = mraa::SUCCESS;
|
||||
|
||||
// Start transmission to device
|
||||
error = m_i2ControlCtx.address (m_controlAddr);
|
||||
if (error != mraa::SUCCESS) {
|
||||
fprintf(stderr, "Error: on i2c bus address setup in i2cWriteReg()\n");
|
||||
return error;
|
||||
}
|
||||
// Write register to I2C
|
||||
error = m_i2ControlCtx.writeByte (reg);
|
||||
if (error != mraa::SUCCESS) {
|
||||
@ -225,13 +219,6 @@ TSL2561::i2cReadReg(uint8_t reg, uint8_t &data)
|
||||
{
|
||||
mraa::Result error = mraa::SUCCESS;
|
||||
|
||||
// Start transmission to device
|
||||
error = m_i2ControlCtx.address(m_controlAddr);
|
||||
if (error != mraa::SUCCESS) {
|
||||
fprintf(stderr, "Error: on i2c bus address setup in i2cReadReg()\n");
|
||||
return error;
|
||||
}
|
||||
|
||||
// Send address of register to be read.
|
||||
error = m_i2ControlCtx.writeByte(reg);
|
||||
if (error != mraa::SUCCESS) {
|
||||
|
Reference in New Issue
Block a user