Functionality flag: I2C_FUNC_SMBUS_WRITE_BYTE_DATA (8)SMBus Write Word I2C-tools 中的函数:i2c_smbus_write_word_data()。先发出 Command Code(它一般表示芯片内部的寄存器地址),再发出 1 个字节的数据。 Functionality flag: I2C_FUNC_SMBUS_WRITE_WORD_DATA (9)SMBus Block Read I2C-tools 中的函数...
static u32 i2c_imx_func(struct i2c_adapter *adapter) { // 每一个宏代表一个具体的i2c通信协议 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_READ_BLOCK_DATA; } 1. 2. 3. 4. 5. 6. 7. 8、i2c_imx_xfer()函数 drivers/i2c/busses/i2c-imx.c static int i2c_imx_xfer...
典型的仅SMBus适配器将列出它支持的所有SMBus事务。这个例子来自于i2c-piix4驱动程序: static u32 piix4_func(struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA; } 1. 2. ...
return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK | (isich4 ? I2C_FUNC_SMBUS_HWPEC_CALC : 0); } ● 字符驱动的具体实现 struct file_operations pca953x_fops =...
Count (8 bits): A data byte containing the length of a block operation. [..]: Data sent by I2C device, as opposed to data sent by the host adapter. Simple send transaction 标准写操作 === This corresponds to i2c_master_send. S Addr Wr [A] Data [A] ...
__s32 i2c_smbus_read_block_data(intfile, __u8 command, __u8 *values); __s32 i2c_smbus_write_block_data(intfile, __u8 command, __u8 length, __u8*values); 所有这些事务在失败时返回-1;您可以读取errno来查看发生了什么。“写”事务成功返回0;' read '事务返回读的值,read_block则返回读...
i2c_smbus_write_word_data() 向设备指定偏移处写入二个字节 i2c_smbus_read_block_data() 从设备指定偏移处读取一块数据. i2c_smbus_write_block_data() 向设备指定偏移处写入一块数据. (<= 32字节) 总线事务 在实现驱动例子之前,通过放大镜观察导线,让我们来更好的理解I2C协议。清单8.1展示了和I2C EEPRO...
.smbus_xfer= i801_access, .functionality= i801_func, }; static u32 i801_func(struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK...
5. #define I2C_M_RD 0x0001 /* read data, from slave to master */ 6. #define I2C_M_NOSTART 0x4000 /* if I2C_FUNC_PROTOCOL_MANGLING */ 7. #define I2C_M_REV_DIR_ADDR 0x2000 /* if I2C_FUNC_PROTOCOL_MANGLING */ 8. #define I2C_M_IGNORE_NAK 0x1000 /* if I2C_FUNC_PROTOCOL_...
3 .functionality = bit_func, 4 }; 5 6 static int i2c_bit_prepare_bus(struct i2c_adapter *adap) 7 { 8 ... ... 9 adap->algo = &i2c_bit_algo; 10 ... ... 11 return 0; 12 } 13 14 int i2c_bit_add_bus(struct i2c_adapter *adap) ...