i2c_algorithm 中的关键函数master_xfer()用于产生 I2C 访问周期需要的信号,以 i2c_msg(即 I2C 消息) 为单位。 i2c_msg 结构体也非常关键。 i2c_msg结构体 (2) i2c_driver 与 i2c_client。 i2c_driver 对应一套驱动方法,是纯粹的用于辅助作用的数据结构,它不对应于任何的物理实体。 i2c_client 对应于真实的...
实现i2c_bus_type, i2c_client_type i2c_adapter_type等结构体及内部填充函数 实现了i2c_add_adapter, i2c_del_adapter, i2c_register_driver, i2c_del_driver等注册/注销 i2c_adapter, i2c_driver函数 基于algo->master_xfer 实现了读写数据的API: i2c_transfer, i2c_master_send, i2c_master_recv 实现了i2c...
i2c_write_bytes可以发送多个字节数据,在linux的应用层来操作I2C设备,具体代码如下: staticinti2c_write_bytes(intfd,uint8_tslave_addr,uint8_treg_addr,uint8_t*values,uint8_tlen){uint8_t*outbuf =NULL;structi2c_rdwr_ioctl_datapackets;structi2c_msgmessages[1];outbuf =malloc(len +1);if(!outbuf...
比如 Functionality flag: I2C_FUNC_SMBUS_QUICK,表示需要 I2C 控制器支持 SMBus Quick Command。 (1)symbols(符号) S (1 bit) : Start bit(开始位)Sr (1 bit) : 重复的开始位P (1 bit) : Stop bit(停止位)R/W# (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.(读写位)A, N (1...
I2C总线是作为一个模块进行初始化 postcore_initcall(i2c_init); #define postcore_initcall(fn) __define_initcall(fn, 2) 由此可见,platform 总线不可或缺,I2C总线是可以被裁剪的。 I2C总线的全局变量如下: I2C适配器(控制器)设备、I2C设备 每一个soc上基本都会有一个或者多个I2C控制器,每一个I2C控制器下面接...
在Linux内核中,i2c_transfer函数用于在I2C总线上执行数据传输操作。当你调用这个函数时,你需要提供一个指向I2C适配器的指针、一个指向I2C消息数组的指针,以及消息的数量(msg_num)。 针对你的问题,“linux i2c_transfer msg_num = 2 发了几条i2c指令”,我们可以从以下几个方面进行解析: msg_num的含义: msg_num...
i2c.h文件中除定义上述4个重要结构之外,还定义了一个非常重要的结构体:i2c_msg,其定义如下: 1. struct i2c_msg { 2. __u16 addr; /* slave address*/ 3. __u16 flags; 4. #define I2C_M_TEN 0x0010 /* this is a ten bit chip address */ ...
int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num); int i2c_master_send(struct i2c_client *client,const char *buf ,int count); int i2c_master_recv(struct i2c_client *client, char *buf ,int count); 上边三个函数用于实现与I2C设备之间的数据交换。i2c_transfer函数...
linux下I2C驱动架构全面分析【转】,I2C是philips提出的外设总线.I2C只有两条线,一条串行数据线:SDA,一条是时钟线SCL ,使用SCL,SDA这两根信号线就实现了设备之间的数据交互