Site Tools


software:programming:i2c:shell

This is an old revision of the document!


controlling i2c gpio via shell

Using kernel driver

For mcp23008:

p=232; z=/sys/class/gpio; echo $p > ${z}/export; echo out > "${z}/gpio${p}/direction"; echo 1 > "${z}/gpio${p}/value"; sleep 1; echo 0 > "${z}/gpio${p}/value"; echo $p > "${z}/unexport"

Using user space via i2c

For mcp23017: <code bash> # find out which i2c address the device listens to: i2cdetect -y 0

# you should find 0x20

# Set all bits from port a to output: i2cset -y 0 0x20 0x00 0x00

# Write value to register GPIOA (0x12) oder OLATA (0x14) # For example: for bit 0, write: i2cset -y 0 0x20 0x12 0x01

software/programming/i2c/shell.1488893845.txt.gz · Last modified: 2017/03/07 14:37 by admin