> 文章列表 > 【IoT】嵌入式驱动开发:IIC子系统

【IoT】嵌入式驱动开发:IIC子系统

【IoT】嵌入式驱动开发:IIC子系统

IIC有三种接口实现方式

三种时序对比:

图1

IIC子系统组成

图2

 图3

IIC操作流程

设备

1.i2c_get_adapter
2.i2c_new_device(相当于register设备)
3.I2c_put_adapter

驱动端

1.填充i2c_driver
2.i2c_add_driver(相当于register驱动)
3.在probe中建立访问方式

client相关函数

获得i2c_adapter结构
struct i2c_adapter *i2c_get_adapter(int id)
参数:第几个adapter(0-2)
返回值:获得的i2c_adapter结构体指针

创建并注册i2c_client
struct i2c_client * i2c_new_device(struct i2c_adapter*adap,
struct i2c_board_info