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)


你可能感兴趣的:(application,i2c)