资料下载
代码语言: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的内部实现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以上就是Linux系统驱动之通用驱动i2c-dev分析的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号