I2C

From Chiliboard Wiki
Jump to: navigation, search

user space tools

i2c-tools package is providing following user space commands: i2cdetect, i2cdump, i2cget, i2cset

Check if i2c device exists:

# ls -l /dev/i2c*
crw-------    1 root     root       89,   0 Jan  4 04:16 /dev/i2c-0

To detext all devices on I2C bus #0

i2cdetect -y -r 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --
20: UU -- -- -- UU -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

note: AM335x doesn't support the SMBus Quick Write feature. So you need to pass -r parameter.

Interpretation of output

  • "--". The address was probed but no chip answered.
  • "UU". Probing was skipped, because this address is currently in use by a driver. This strongly suggests that there is a chip at this address.
  • An address number in hexadecimal, e.g. "2d" or "4e". A chip was found at this address.

On output above, you can see all devices addresses which responds on I2C bus.

  • 0x18 - tlv320aic3204 sound codec (no driver loader)
  • 0x20 - mcp23008 gpio
  • 0x24 - tps65217 power controller
  • 0x38 - ft5316 touch screen controller

To dump content of all registers (device 0x18 on i2c bus 0):

i2cdump -y 0 0x18

Get value of register (device address 0x18 on i2c bus 0, register address 0x11, byte access mode):

i2cget -y 0 0x18 0x11 b

Write value to register (device address 0x18 on i2c bus 0, register address 0x11, write byte 0xff):

i2cset -y 0 0x18 0x11 0xff