你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux下i2c与时钟芯片PCF8563的通信

[日期:2013-01-25] 来源:Linux社区  作者:hdw10 [字体:大 中 小]

运行结果如下:

 

root@(none):/han# ./i2c-test /dev/i2c-20
 Hello i2c-test![ 5536.661954] i2c-mux.c: msgs = 51 , num = 2

enter i2c_open OK!
 i2c.c: i2c_open: fd = 3
enter __i2c_set [ 5536.669209] i2c-mux.c: msgs = 51 , num = 1
OK!
__i2c_set done!
here is i2c_read_data function in main.c
[ 5536.677154] i2c-mux.c: msgs = 51 , num = 2
 __i2c_send: data->msgs[0].addr = 51,data->msgs[0].buf[0] = 4
 i2c_read_data success, val = 15

 here is i2c_write_data function in main.c
the data to write val = 8
 __i2c_send: data->msgs[0].addr = 51,data->msgs[0].buf[0] = 4
i2c_write_data success,val1 = 8

here is i2c_read_data function in main.c
 __i2c_send: data->msgs[0].addr = 51,data->msgs[0].buf[0] = 4
 i2c_read_data success, val = 8

root@(none):/han# date
Fri Jul  6 15:49:25 UTC 2012
root@(none):/han# hwclock -r
Fri Jul  6 08:49:28 2012  -0.628861 seconds

 

                成功了!!!                   

i2c-test 成功地读写到了地址为0x51,  偏移地址为0x04的 寄存器内容!!!

linux
相关资讯       Linux I2C  PCF8563 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款