General Purpose Input Output
General Purpose Input Output (GPIO)
==
General-purpose input/output (GPIO) is a generic pin on an integrated circuit whose behavior—including whether it is an input or output pin—is controllable by the user at run time. Wikipedia
Kernel Integration
Kernel Display Message
root@edison:~# dmesg | grep -i gpio
[ 0.000000] SFI: GPIO E3A27, 0964 (v1 INTEL INTELFDK)
[ 0.189472] wifi_platform_data: GPIO == 64
[ 0.189618] IPC bus, name = msic_gpio, irq = 0x31
[ 0.209216] virtio_rpmsg_bus virtio0: creating channel rpmsg_msic_gpio addr 0x5
[ 1.584512] vwlan gpio 96
[ 1.971456] info[ 0]: name = power_btn, gpio = -1
[ 1.971473] info[ 1]: name = SW1UI4, gpio = 61
[ 2.004409] input: gpio-keys as /devices/platform/gpio-keys/input/input0Userspace Interfaces
You are seeing 3 kind of entries:
Control interfaces used to get userspace control over GPIOs;
GPIOs themselves; and
GPIO controllers ("gpio_chip" instances).
Watching it change (a primer on GPIO and GPIO configuration this content is moving to GPIO Subsystem)
To see the status of our exported pins in the Edison, type this your Edison's terminal:
Basically, it will output the configured GPIO's to console every second:
The gpio's displayed above, are the ones reserved (AKA exported) by default in a newly flashed yocto image Poky (Yocto Project Reference Distro) 1.7.2 edison, kernel 3.10.17-poky-edison+
To reserve and use a GPIO, Before:
let's say 48 lets type the following:
by this mechanism, a new directory is created in /sys/class/gpio, which should be gpio48: After:
This directory, is a control interface used to get userspace control over GPIO48, therefore can have the following read/write attributes:
Exercise Change GPIO Direction
As explained before the GPIO control interface has some read/write attributes, so lets go ahead and change the default direction of the GPIO48.
Review the current GPIO direction using the command to debug GPIO statuses; If the direction is "out" let's change it to "in", if it is "in", change it to "out"
To change it, from "in" to "out " we only have to write "out" to attribute GPIO48/direction like this:
Then checking again the GPIO status we can see, that direction has changed. Here is a table that shows the direction before and after the change:
Exercise Use Python Bindings
Lab
Blinks the Edison LED Here
Last updated