Transclusion: Debian: GPIO

From Compulab Mediawiki
Revision as of 10:52, 15 February 2017 by Ilya (talk) (New page: Linux provides simple and convenient GPIO access via {{filename|sysfs}} interface. A GPIO should be exported using {{filename|/sys/class/gpio/export}}. After the GPIO is exported it is pos...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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
Admolition note.png 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.