Copyright 2017. All rights reserved. Advantech Co. Ltd.
Page 36
0
SW Defined led
Red LED, 0: on, 1: off
1
SW Defined led
Green LED, 0: on, 1: off
Step 2
: Control LEDs
# i2cset -y 5 0x20 0x01 0xff (lights out)
# i2cset -y 5 0x20 0x01 0xfe (led 0 on)
# i2cset -y 5 0x20 0x01 0xfd (led 1 on)
# i2cset -y 5 0x20 0x01 0xfc (led 0 and 1 both on)
“5” is smbus number and “0x20” is device address. “0x01” is offset and “0xff” is value
combined to control led on/off.
“0xff” is hex of binary “1111 1111”, which means all bit is set to “1” (all off);
“0xfe” is hex of binary “1111 1110”, which means bit 0 is set to “0” (led 0 on);
“0xfd” is hex of binary “1111 1101”, which means bit 1 is set to “0” (led 1 on);
“0xfc” is hex of binary “1111 1100”, which means bit 0 and 1 are set to “0” (led 0 and 1 on);
3.7.1.2
Kernel GPIO sysfs to control led
The other interface to control LED from user space is by kernel GPIO sysfs. GPIO sysfs also
depends on i2c driver thus i2c_i801 must be loaded. It will use smbus number and device
address of IO expander located in previous chapter.
For more detail, please refer to kernel document:
https://www.kernel.org/doc/Documentation/gpio/sysfs.txt
Step 1
: Add IO expander device to gpio sysfs
# echo tca9554 0x20 > /sys/bus/i2c/devices/i2c-5/new_device
“i2c-5” is target to smbus number 5 and “0x20” is device address. "tca9554" is name of this
IO expander.
Step 2
: GPIO base-port file under /sys/class/gpio (gpiochip259) appears after device are
added. However there might be several other gpio base port file, so it’s necessary to locate
which gpio base-port file.
# for L in `ls /sys/class/gpio/gpio*/label`; do echo $L; cat $L; done
/sys/class/gpio/gpiochip259/label
tca9554
/sys/class/gpio/gpiochip267/label
INT3452:03