信息发布→ 登录 注册 退出

Linux系统驱动之通用驱动i2c-dev分析

发布时间:2025-06-27

点击量:

资料下载

coding无法使用浏览器打开,必须用git工具下载:

代码语言:javascript代码运行次数:0运行复制
git clone https://e.coding.net/weidongshan/linux/doc_and_source_for_drivers.git
视频观看

百问网驱动大全

通用驱动i2c-dev分析

参考资料:

Linux驱动程序: drivers/i2c/i2c-dev.cI2C-Tools-4.2: https://mirrors.edge.kernel.org/pub/software/utils/i2c-tools/AT24cxx.pdf1. 回顾字符设备驱动程序

怎么编写字符设备驱动程序?

确定主设备号创建file_operations结构体 在里面填充drv_open/drv_read/drv_ioctl等函数注册file_operations结构体 register_chrdev(major, &fops, name)谁调用register_chrdev?在入口函数调用有入口自然就有出口 在出口函数unregister_chrdev辅助函数(帮助系统自动创建设备节点) class_createdevice_create2. i2c-dev.c注册过程分析2.1 register_chrdev的内部实现
2.2 i2c-dev驱动的注册过程
3. file_operations函数分析

i2c-dev.c的核心:

代码语言:javascript代码运行次数:0运行复制
static const struct file_operations i2cdev_fops = {.owner= THIS_MODULE,.llseek= no_llseek,.read= i2cdev_read,.write= i2cdev_write,.unlocked_ioctl= i2cdev_ioctl,.compat_ioctl= compat_i2cdev_ioctl,.open= i2cdev_open,.release= i2cdev_release,};

主要的系统调用:open, ioctl:

要理解这些接口,记住一句话:APP通过I2C Controller与I2C Device传输数据。

3.1 i2cdev_open
3.2 i2cdev_ioctl: I2C_SLAVE/I2C_SLAVE_FORCE
3.3 i2cdev_ioctl: I2C_RDWR
3.4 i2cdev_ioctl: I2C_SMBUS
3.5 总结
标签:# 设备驱动程序  # evenodd  # currentcolor  # rule  # 资料下载  # 参考资料  # 句话  # 工具下载  # 在里面  # 就有  # linux  # https  # 接口  # 结构体  # edge  # JavaScript  # 工具  # 浏览器  # git  
在线客服
服务热线

服务热线

4008888355

微信咨询
二维码
返回顶部
×二维码

截屏,微信识别二维码

打开微信

微信号已复制,请打开微信添加咨询详情!