免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2703 | 回复: 6
打印 上一主题 下一主题

[驱动] I2C驱动小小一问 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-11-01 09:56 |只看该作者 |倒序浏览
struct i2c_driver {
  unsigned int class;
  int (* attach_adapter) (struct i2c_adapter *);
  int (* detach_adapter) (struct i2c_adapter *);
  int (* probe) (struct i2c_client *, const struct i2c_device_id *);
  int (* remove) (struct i2c_client *);
  void (* shutdown) (struct i2c_client *);
  int (* suspend) (struct i2c_client *, pm_message_t mesg);
  int (* resume) (struct i2c_client *);
  int (* command) (struct i2c_client *client, unsigned int cmd, void *arg);
  struct device_driver driver;
  const struct i2c_device_id * id_table;
  int (* detect) (struct i2c_client *, int kind, struct i2c_board_info *);
  const struct i2c_client_address_data * address_data;
  struct list_head clients;
};  

在I2C驱动中,command这一项是不是能用ioctl把命令传到函数中!跟ioctl一样使用!

论坛徽章:
0
2 [报告]
发表于 2011-11-01 10:52 |只看该作者
我的意思是我用 ./ioctl + device + cmd 是不是能把这个 cmd 能传到这个device 的I2C驱动的command函数中做处理!

我要想用应用程序控制 I2C 把参数CMD传入驱动中,应该怎么办?

论坛徽章:
2
CU十二周年纪念徽章
日期:2013-10-24 15:41:34处女座
日期:2013-12-27 22:22:41
3 [报告]
发表于 2011-11-01 11:38 |只看该作者
看了一下,好像不是你所想的。I2C设备文件能接受的ioctl命令已经写死了,这个command应该是驱动提供的比用read/write发控制命令更友好的接口。

论坛徽章:
0
4 [报告]
发表于 2011-11-01 14:09 |只看该作者
回复 3# tempname2


    那你的意思是没法传命令进去了吗?不能吧,

论坛徽章:
0
5 [报告]
发表于 2011-11-01 15:46 |只看该作者
到底有没有法获得COMMAND函数的接口呢

论坛徽章:
0
6 [报告]
发表于 2011-11-01 16:32 |只看该作者
再注册一个char或者misc设备,通过它的write、ioctl函数去操i2c
或者给你们i2c device增加个device_attribute,通过写它也可以实现

方法那么多,非要在一个树上吊死啊

论坛徽章:
0
7 [报告]
发表于 2011-11-02 08:33 |只看该作者
回复 6# senioryzc


    谢谢了,我通过write把I2C的command的接口弄好了!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP