i2c tools usage

1. get the source code of i2c tools

reference: http://lm-sensors.org/wiki/I2CTools

$ wget http://dl.lm-sensors.org/i2c-tools/releases/i2c-tools-3.1.0.tar.bz2


2. compile the source code

$ tar -jxvf i2c-tools-3.1.0.tar.bz2

$ cd i2c-tools-3.1.0

$ CC=arm-none-linux-gnueabi-gcc make (if not for embedded system, so without CC=arm-none-linux-gnueabi-gcc)

Then you will get i2cdetct, i2cget, i2cset, i2cdump under tools directory.


3. copy these tools to embedded system and use them

3.1 i2cdetect -- detect i2c devices

$ ./i2cdetect -r 0 


3.2 i2cdump -- dump i2c device information (EEPROM as an example)

$ ./i2cdump -f -y 0 0x50 (0 is i2c bus number, 0x50 is the EEPROM i2c address)


3.3 i2cset -- write some where (device 0x50, offset 0x3, value 0x5)

$ ./i2cset -f -y 0 0x50 0x3 0x5 (write address 0x3 with value 0x5 on i2c bus 0, the i2c device address is 0x50)


3.4 i2cget -- read some where (device 0x50, offset 0x3)

$ ./i2cget -f -y 0 0x50 0x3 (read address 0x3 on i2c bus 0, the i2c device address is 0x50)


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值