24c08 linux i2c驱动.pdf

  1. 1、本文档共8页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
24c08 linux i2c驱动

24c08 linux i2c 驱动 at24c08 是1024bytes 与24c02 是256bytes,写24c08 时的页大小是16bytes,写时超过 16bytes,会在当前页覆盖就是这些差别,因此要把24c08 的驱动改成24c02 的就需要改一下 这个差别的地方即可,以下的代码在kernel 2.6.36 上已测试通过。可通过此驱动了解 linux i2c 设备驱动设计的基本思路。 参考文章: /liaozc/article/details/6655082 中是在内核中增加 board info 增加一个i2c 设备client, 以下代码是自动创建一个i2c device client,创建 i2c client 的文章参考:/newger/article/details/6571740 #include linux/delay.h #include linux/init.h #include linux/module.h #include linux/fs.h #include linux/types.h #include linux/i2c.h #include linux/cdev.h #include linux/slab.h #include linux/kernel.h #include linux/file.h #include asm/uaccess.h #define AT24C02_MAJOR 250 #define AT24C02_SIZE 1024 static int at24c02_major = AT24C02_MAJOR; struct i2c_client * my_i2c_client=NULL; struct at24c02_data { struct cdev cdev; struct i2c_client *client; struct mutex update_lock; unsigned char data[AT24C02_SIZE+1]; /* Register values */ }; int number_of_devices = 1; struct file_operations hello_fops = { .owner = THIS_MODULE, }; struct class * my_class=NULL; static struct at24c02_data my_data; static const struct i2c_device_id at24c02_id[] = { { at24c02, 0 }, }; MODULE_DEVICE_TABLE(i2c, at24c02_id); static int at24c02_open(struct inode *inode, struct file *file) { struct at24c02_data *data; printk(KERN_ALERT at24c02_open\n); data=container_of(inode-i_cdev,struct at24c02_data,cdev); file-private_data = data; return 0; } static int at24c02_release(struct inode *inode,struct file *filp) { printk(KERN_ALERT at24c02_release\n); return 0; } #define AT24C02_READ_PAGE_SIZE 256 /* * read only AT24C02_READ_PAGE_SIZE once */ static int at24c02_read(struct file *filp, char __user *buff,size_t co

文档评论(0)

xxj1658888 + 关注
实名认证
内容提供者

教师资格证持证人

该用户很懒,什么也没介绍

领域认证该用户于2024年04月12日上传了教师资格证

1亿VIP精品文档

相关文档