i2c-tools使用

1、下载i2c-tools工具

地址:https://mirrors.edge.kernel.org/pub/software/utils/i2c-tools/

2、安装i2c-tools

modprobe i2c-dev

3、i2c-tools使用

(1)列出i2c总线:i2cdetect -l

(2)列出某个i2c总线上的i2c设备:i2cdetect -y -r 0

(3)显示寄存器值:i2cdump -y 0 0x56

(4)i2c读寄存器:i2cget -y 0 0x70 0x00

(5)i2c写寄存器:i2cset -y 0 0x70 0x00 0x01

(6)i2c读数据:i2ctransfer 0 w2@0x56 0x00 0x00 r256

(7)i2c写数据:i2ctransfer 0 w3@0x56 0x00 0x00 0x01

 

posted @ 2022-07-19 18:06  annan00  阅读(606)  评论(0)    收藏  举报