1STRUCT I2C_MSG(9) I2C and SMBus Subsystem STRUCT I2C_MSG(9)
2
3
4
6 struct_i2c_msg - an I2C transaction segment beginning with START
7
9 struct i2c_msg {
10 __u16 addr;
11 __u16 flags;
12 #define I2C_M_TEN 0x0010
13 #define I2C_M_RD 0x0001
14 #define I2C_M_NOSTART 0x4000
15 #define I2C_M_REV_DIR_ADDR 0x2000
16 #define I2C_M_IGNORE_NAK 0x1000
17 #define I2C_M_NO_RD_ACK 0x0800
18 #define I2C_M_RECV_LEN 0x0400
19 __u16 len;
20 __u8 * buf;
21 };
22
24 addr
25 Slave address, either seven or ten bits. When this is a ten bit
26 address, I2C_M_TEN must be set in flags and the adapter must
27 support I2C_FUNC_10BIT_ADDR.
28
29 flags
30 I2C_M_RD is handled by all adapters. No other flags may be provided
31 unless the adapter exported the relevant I2C_FUNC_* flags through
32 i2c_check_functionality.
33
34 len
35 Number of data bytes in buf being read from or written to the I2C
36 slave address. For read transactions where I2C_M_RECV_LEN is set,
37 the caller guarantees that this buffer can hold up to 32 bytes in
38 addition to the initial length byte sent by the slave (plus, if
39 used, the SMBus PEC); and this value will be incremented by the
40 number of block data bytes received.
41
42 buf
43 The buffer into which data is read, or from which it's written.
44
46 An i2c_msg is the low level representation of one segment of an I2C
47 transaction. It is visible to drivers in the i2c_transfer() procedure,
48 to userspace from i2c-dev, and to I2C adapter drivers through the
49 i2c_adapter.master_xfer() method.
50
51 Except when I2C “protocol mangling” is used, all I2C adapters implement
52 the standard rules for I2C transactions. Each transaction begins with a
53 START. That is followed by the slave address, and a bit encoding read
54 versus write. Then follow all the data bytes, possibly including a byte
55 with SMBus PEC. The transfer terminates with a NAK, or when all those
56 bytes have been transferred and ACKed. If this is the last message in a
57 group, it is followed by a STOP. Otherwise it is followed by the next
58 i2c_msg transaction segment, beginning with a (repeated) START.
59
60 Alternatively, when the adapter supports I2C_FUNC_PROTOCOL_MANGLING
61 then passing certain flags may have changed those standard protocol
62 behaviors. Those flags are only for use with broken/nonconforming
63 slaves, and with adapters which are known to support the specific
64 mangling options they need (one or more of IGNORE_NAK, NO_RD_ACK,
65 NOSTART, and REV_DIR_ADDR).
66
68Kernel Hackers Manual 2.6. November 2011 STRUCT I2C_MSG(9)