reference:https://learn.adafruit.com/i2c-addresses/the-list Special cases PCA9685 can be used by any address between 0x40 to 0x7F 0x00 - 0x07 and 0x78 - 0x7F are reserved I2C addresses 0x00 - 0x0F 0x00 - Reserved - General Call Address 0x01 - Reserved for CBUS Compatibility 0x02 ...
i2c_driver注册的时候,i2c_core会在所有已经注册的i2c_adapter上探测address_list中的所有地址,硬件探测成功之后后调用i2c_driver的detect成员,然后根据detect填充的info建立一个i2c_client。 例如,MAX1668温度传感器的驱动实现,/drivers/hwmon/max1668.c 登录后复制staticstructi2c_driver max1668_driver = { .class= ...
由于事先并不知道I2C设备在哪个适配器上,所以去"class表示的那一类"I2C适配器上找,用"detect函数"来确定能否找到"address_list里的设备",如果能找到就调用i2c_new_device来注册i2c_client, 这会和i2c_driver的id_table比较,如果匹配,调用probe。 详细代码调用过程: i2c_add_driver i2c_register_driver a. at24c...
int(*detect)(structi2c_client*client,structi2c_board_info*info); constunsignedshort*address_list; structlist_headclients; u32flags; }; 几个重要的成员: driver:是一个structdevice_driver结构体,用于向Linux设备模型注册驱动程序。 probe和remove:指向探测和移除设备的函数指针,通过这两个函数,驱动程序可以在...
const unsigned short *address_list; struct list_head clients; }; #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) I2C slave device结构体 i2c_client这个结构体表示一个I2C从设备。下面是对各个字段的解释: flags: 表示设备的各种标志位,如是否使用数据校验(PEC)、是否为10位地址、...
DLN-series adapters can scan the bus for I2C addresses of the connected slave devices. Call theDlnI2cMasterScanDevices()function to get the list of I2C addresses. Some slave device vendors specify the 8-bit I2C addresses in their documentation. In fact they specify the entire address byte (I2...
detect:I2C 设备探测回调函数,它会识别所支持的设备(返回 0 表示支持, 否则返回-ENODEV);此外,需要定义一个供探测的地址列表(address_list)和 一个设备类型(class),这样使那些仅匹配设备类型的 i2c 总线被探测到。例如, 对于一个自动监测硬件芯片的驱动将会设置它的 class 域为 I2C_CLASS_HWMON,只有那些 class ...
const unsigned short *address_list; struct list_head clients; u32 flags; }; 几个重要的成员: driver:是一个 struct device_driver 结构体,用于向Linux设备模型注册驱动程序。 probe 和 remove:指向探测和移除设备的函数指针,通过这两个函数,驱动程序可以在发现匹配的设备时执行初始化操作,并在设备被移除时执...
const unsigned short *address_list; //设备地址 struct list_head clients; //设备链表 }; 1. 2. 3. 4. 5. 6. 7. 8. 对应的是I2C驱动程序 3、I2C设备 AI检测代码解析 struct i2c_client { unsigned short addr; //设备地址 char name[I2C_NAME_SIZE]; //设备名称 ...
enumi2c_alert_protocol protocol,unsigned int data);int(*command)(struct i2c_client*client,unsigned int cmd,void*arg);struct device_driver driver;conststruct i2c_device_id*id_table;int(*detect)(struct i2c_client*,struct i2c_board_info*);constunsigned short*address_list;struct list_head clients...