linuxi2c驱动架构 写在前面 由于IIC总线只需要两根线就可以完成读写操作,而且通信协议简单,一条总线上可以挂载多个设备,因此被广泛使用。但是IIC总线有一个缺点,就是传输速率比较低。本文基于Linux-2.6.36版本,说说IIC子系统在Linux中的实现。 IIC子系统框架分为3各部分: 1.I2C核心:I2C总线和I2C设备驱动的中间枢纽,它为
You need to create a private structure that will store the I2C I/O device specific information. In this driver, the first field of the private structure is astruct i2c_clientstructure used to handle the I2C device. The second field of the private structure is astruct miscdevicestructure...
In the Linux kernel, the I2C subsystem provides support for I2C bus drivers, I2C controller drivers, and I2C client drivers. The I2C bus drivers manage the physical I2C buses on the system, while the I2C controller drivers handle the communication between the I2C bus and the devices connected ...
的方式intaddr=0x40;/* The I2C address */if(ioctl(file,I2C_SLAVE,addr)<0){/* ERROR HANDLING; you can check errno to see what went wrong */exit(1);}Well,youareallsetupnow.YoucannowuseSMBuscommandsorplainI2Ctocommunicatewithyourdevice.SMBuscommandsarepreferredifthedevicesupportsthem.Bothareil...
65. /* Convert old I2C block commands to the new 66. convention. This preserves binary compatibility. */ 67. data_arg.size = I2C_SMBUS_I2C_BLOCK_DATA; 68. if (data_arg.read_write == I2C_SMBUS_READ) 69. temp.block[0] = I2C_SMBUS_BLOCK_MAX; ...
/* /dev/i2c-X ioctl commands. The ioctl's parameter is always an * unsigned long, except for: * - I2C_FUNCS, takes pointer to an unsigned long * - I2C_RDWR, takes pointer to struct i2c_rdwr_ioctl_data * - I2C_SMBUS, takes pointer to struct i2c_smbus_ioctl_data */ #define I2C...
command预定义的一些组合: I2C_FUNC_SMBUS_BYTE Handles the SMBus read_byte and write_byte commands I2C_FUNC_SMBUS_BYTE_DATA Handles the SMBus read_byte_data and write_byte_data commands I2C_FUNC_SMBUS_WORD_DATA Handles the SMBus read_word_data and write_word_data commands I2C_FUNC_SMBUS...
00000379 /* Convert old I2C block commands to the new 00000380 convention. This preserves binary compatibility. */ 00000381 data_arg.size = I2C_SMBUS_I2C_BLOCK_DATA; 00000382 if (data_arg.read_write == I2C_SMBUS_READ) 00000383 temp.block[0] = I2C_SMBUS_BLOCK_MAX; ...
/* I2C commands */ enum ljca_i2c_cmd { LJCA_I2C_INIT = 1, LJCA_I2C_XFER, LJCA_I2C_START, LJCA_I2C_STOP, LJCA_I2C_READ, LJCA_I2C_WRITE, }; enum ljca_xfer_type { LJCA_I2C_WRITE_XFER_TYPE, LJCA_I2C_READ_XFER_TYPE, }; /* I2C raw commands: Init/Start/Read/Write/Stop...
linux_i2c.csource code for i2c control in linux device node.linux_i2c.hheader file for i2c control in linux.ssd1306.ci2c protocol functions to control oled SSD1306.ssd1306.hheader file for i2c protocol functions and defined commands in SSD1306.font.hfont header file define 5x7 small font an...