Kernel Gpio Sysfs To Control Led - Advantech FWA-T011 Getting Started Manual

Quickstart linux image
Hide thumbs Also See for FWA-T011:
Table of Contents

Advertisement

0
1
Step 2: Control LEDs
# i2cset -y 5 0x20 0x01 0xff
# i2cset -y 5 0x20 0x01 0xfe
# i2cset -y 5 0x20 0x01 0xfd
# i2cset -y 5 0x20 0x01 0xfc
"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
Copyright 2017. All rights reserved. Advantech Co. Ltd.
SW Defined led
SW Defined led
(lights out)
(led 0 on)
(led 1 on)
(led 0 and 1 both on)
Page 36
Red LED, 0: on, 1: off
Green LED, 0: on, 1: off

Advertisement

Table of Contents
loading

Table of Contents