
59 RSB-4210 User Manual
Chapter 3 Software Functionality
buf[0] = register;
buf[1] = 0x43;
buf[2] = 0x65;
if (write(file, buf, 3) ! =3) {
/* ERROR HANDLING: i2c transaction failed */
}
/* Using I2C Read, equivalent of i2c_smbus_read_byte(file) */
if (read(file, buf, 1) != 1) {
/* ERROR HANDLING: i2c transaction failed */
} else {
/* buf[0] contains the read byte */
}
Note that only a subset of the I2C and SMBus protocols can be achieved by the
means of read() and write() calls. In particular, so-called combined transactions (mix-
ing read and write messages in the same transaction)
aren't supported. For this reason, this interface is almost never used by user-space
programs.
3.11.2.1 Full interface description
The following IOCTLs are defined:
ioctl(file, I2C_SLAVE, long addr)
Change slave address. The address is passed in the 7 lower
bits of the argument (except for 10 bit addresses, passed in
the 10 lower bits in this case).
ioctl(file, I2C_TENBIT, long select)
Selects ten bit addresses if select not equals 0, selects
normal 7 bit addresses if select equals 0. Default 0. This
request is only valid if the adapter has I2C_FUNC_10BIT_ADDR.
ioctl(file, I2C_PEC, long select)
Selects SMBus PEC (packet error checking) generation and verification if select not
equals 0, disables if select equals 0. Default 0. Used only for SMBus transactions.
This request only has an effect if the the adapter has I2C_FUNC_SMBUS_PEC; it is
still safe if not, it just doesn't have any effect.
ioctl(file, I2C_FUNCS, unsigned long *funcs)
Gets the adapter functionality and puts it in *funcs.
ioctl(file, I2C_RDWR, struct i2c_rdwr_ioctl_data *msgset)
Note! Because of the use of inline functions, you *have* to use '-O' or some
variation when you compile your program!
Komentáře k této Příručce