I2CMaster_SetDefaultTargetAddress Function

Header: #include <applibs/i2c.h>

Sets the address of the subordinate device that is targeted by calls to read(2) and write(2) POSIX functions on the I2C master interface.

Note

I2CMaster_SetDefaultTargetAddress is not required when using I2CMaster_Read, I2CMaster_Write, or I2CMaster_WriteThenRead, and has no impact on the address parameter of those functions.

int I2CMaster_SetDefaultTargetAddress(int fd, I2C_DeviceAddress address);

Parameters

  • fd The file descriptor for the I2C master interface.

  • address The address of the subordinate I2C device that is targeted by read(2) and write(2) function calls.

Return value

Returns 0 for success, or -1 for failure, in which case errno will be set to the error value. This function doesn't verify whether the device exists, so if the address is well formed, it can return success for an invalid subordinate device.

Application manifest requirements

To access an I2c interface, your application must identify it in the I2cMaster field of the application manifest.