Transclusion: Debian: GPIO
Linux provides simple and convenient GPIO access via sysfs interface. A GPIO should be exported using /sys/class/gpio/export. After the GPIO is exported it is possible to change its direction and value using /sys/class/gpio/gpioX/direction and /sys/class/gpio/gpioX/value attributes.
Example
The following example demonstrates how to configure GPIO 140 as output and set value to high:
# echo 140 > /sys/class/gpio/export # echo out > /sys/class/gpio/gpio140/direction # echo 1 > /sys/class/gpio/gpio140/value
The above example assumes that the pinmux configuration of the corresponding pin is set to GPIO mode and the GPIO 140 is not requested in the Linux kernel. |