技术专栏
【海思开源篇】-(3)i2c-tools
【海思开源篇】-(3)i2c-tools
1 源码下载
https://mirrors.edge.kernel.org/pub/software/utils/i2c-tools/
下载版本为i2c-tools-4.1.tar.gz
根文件系统中已经通过busybox生成了i2c-tools,赞!!!
2 编译
make clean;make CC=arm-himix400-linux-gcc
拷贝i2cdetect i2cdump i2cget i2cset i2ctransfer
3 工具使用
3.1 i2cdetect
~ # i2cdetect -l
i2c-1 i2c hibvt-i2c I2C adapter
i2c-0 i2c hibvt-i2c I2C adapter
/home # i2cdetect
BusyBox v1.30.1 (2020-05-28 08:57:22 CST) multi-call binary.
Usage: i2cdetect -l | -F I2CBUS | [-ya] [-q|-r] I2CBUS [FIRST LAST]
Detect I2C chips
-l List installed buses
-F BUS# List functionalities on this bus
-y Disable interactive mode
-a Force scanning of non-regular addresses
-q Use smbus quick write commands for probing (default)
-r Use smbus read byte commands for probing
FIRST and LAST limit probing range
~ # i2cdetect -r -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: 30 31 -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
i2c0上挂载两颗,由此推出i2c 地址分别为0x60,0x62(左移一位)
/home # i2cdetect -r -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
从而可知i2c1上挂载有三个设备0x68
3.2 i2cdump
/home # i2cdump
BusyBox v1.30.1 (2020-05-28 08:57:22 CST) multi-call binary.
Usage: i2cdump [-fy] [-r FIRST-LAST] BUS ADDR [MODE]
Examine I2C registers
I2CBUS I2C bus number
ADDRESS 0x03-0x77
MODE is:
b Byte (default)
w Word
W Word on even register addresses
i I2C block
s SMBus block
c Consecutive byte
Append p for SMBus PEC
-f Force access
-y Disable interactive mode
-r Limit the number of registers being accessed
/home # i2cdump -f -y 1 0x68
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: d1 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?!..............
10: 00 00 00 00 00 00 00 00 5f f8 dc 10 00 00 00 00 ........_???....
20: 00 80 00 00 80 00 00 00 00 00 00 00 00 00 00 00 .?..?...........
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
40: 28 03 28 00 0b 88 80 10 00 00 00 20 80 42 4c 00 (?(.????... ?BL.
50: 00 00 00 00 00 00 00 00 00 00 07 30 81 0b c0 00 ..........?0???.
60: 14 14 24 04 0a 18 48 08 11 00 00 00 00 00 00 00 ??$???H??.......
70: 00 00 00 00 4c a1 14 00 00 00 15 03 00 00 00 00 ....L??...??....
80: d1 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?!..............
90: 00 00 00 00 00 00 00 00 8d 02 dd 10 00 00 00 00 ........????....
a0: 00 80 00 00 80 00 00 00 00 00 00 00 00 00 00 00 .?..?...........
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
c0: 28 03 28 00 0b 88 80 10 00 00 00 20 80 42 4c 00 (?(.????... ?BL.
d0: 00 00 00 00 00 00 00 00 00 00 07 30 81 0b c0 00 ..........?0???.
e0: 14 14 24 04 0a 18 48 08 11 00 00 00 00 00 00 00 ??$???H??.......
f0: 00 00 00 00 4c a1 14 00 00 00 15 03 00 00 00 00 ....L??...??....
3.3 i2cset
/home # i2cset
BusyBox v1.30.1 (2020-05-28 08:57:22 CST) multi-call binary.
Usage: i2cset [-fy] [-m MASK] BUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]
Set I2C registers
I2CBUS I2C bus number
ADDRESS 0x03-0x77
MODE is:
c Byte, no value
b Byte data (default)
w Word data
i I2C block data
s SMBus block data
Append p for SMBus PEC
-f Force access
-y Disable interactive mode
-r Read back and compare the result
-m MASK Mask specifying which bits to write
/home # i2cset -f -y 1 0x68 0x7a 0x15
3.4 i2cget
/home # i2cget
BusyBox v1.30.1 (2020-05-28 08:57:22 CST) multi-call binary.
Usage: i2cget [-fy] BUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]
Read from I2C/SMBus chip registers
I2CBUS I2C bus number
ADDRESS 0x03-0x77
MODE is:
b Read byte data (default)
w Read word data
c Write byte/read byte
Append p for SMBus PEC
-f Force access
-y Disable interactive mo
/home # i2cget -f -y 1 0x68 0xfa
0x15
声明:本文内容由易百纳平台入驻作者撰写,文章观点仅代表作者本人,不代表易百纳立场。如有内容侵权或者其他问题,请联系本站进行删除。
红包
1
3
评论
打赏
- 分享
- 举报
评论
0个
手气红包
暂无数据
相关专栏
-
浏览量:3787次2020-08-30 09:57:38
-
浏览量:1353次2023-09-18 11:05:06
-
2020-08-05 20:23:18
-
浏览量:634次2023-11-15 17:25:34
-
浏览量:4776次2018-05-07 20:47:52
-
浏览量:2390次2020-08-30 12:39:35
-
浏览量:10606次2021-03-03 17:39:18
-
浏览量:4533次2021-05-14 09:48:13
-
浏览量:1306次2023-10-12 14:39:21
-
浏览量:6344次2020-08-30 12:34:17
-
浏览量:871次2023-06-12 14:34:15
-
浏览量:3565次2020-08-29 16:50:56
-
浏览量:1696次2020-06-23 17:33:04
-
浏览量:5211次2021-05-19 15:43:27
-
浏览量:5370次2020-08-29 21:41:37
-
浏览量:4077次2020-08-30 12:27:19
-
浏览量:1162次2024-02-05 11:02:54
-
浏览量:3502次2018-02-06 10:43:46
-
浏览量:3059次2020-08-29 21:36:16
置顶时间设置
结束时间
删除原因
-
广告/SPAM
-
恶意灌水
-
违规内容
-
文不对题
-
重复发帖
打赏作者
xclshwd
您的支持将鼓励我继续创作!
打赏金额:
¥1
¥5
¥10
¥50
¥100
支付方式:
微信支付
打赏成功!
感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
审核成功
发布时间设置
发布时间:
请选择发布时间设置
是否关联周任务-专栏模块
审核失败
失败原因
请选择失败原因
备注
请输入备注