VAR-SOM-AM33 GPIO: Difference between revisions
(Created page with "{{PageHeader|VAR-SOM-AM33 - GPIO}} {{DocImage|category1=VAR-SOM-AM33|category2=Yocto}} __toc__ = GPIO state = The current state of the systems' GPIOs can be obtained in user...") |
|||
Line 8: | Line 8: | ||
The above command on Variscite's VAR-DVK-MX6 will show the following: | The above command on Variscite's VAR-DVK-MX6 will show the following: | ||
<pre> | <pre> | ||
root@ | root@varsomam33:~# cat /sys/kernel/debug/gpio | ||
GPIOs 0-31, platform/ | GPIOs 0-31, platform/44e07000.gpio, gpio: | ||
GPIOs 32-63, platform/ | GPIOs 32-63, platform/4804c000.gpio, gpio: | ||
gpio-60 (cd ) in lo IRQ | |||
GPIOs 64-95, platform/ | GPIOs 64-95, platform/481ac000.gpio, gpio: | ||
gpio- | gpio-82 (wp ) in lo | ||
GPIOs 96-127, platform/ | GPIOs 96-127, platform/481ae000.gpio, gpio: | ||
gpio- | gpio-100 (button0 ) in hi IRQ | ||
gpio- | gpio-105 (kim ) out lo | ||
gpio- | gpio-117 (wlan-en-regulator ) out lo | ||
GPIOs | GPIOs 510-511, platform/50000000.gpmc, omap-gpmc: | ||
gpio-510 (ready ) in hi | |||
root@varsomam33:~# | |||
gpio- | |||
</pre> | </pre> | ||
Each GPIO is defined as in or out and the state is shown as lo or hi. | Each GPIO is defined as in or out and the state is shown as lo or hi. |
Revision as of 12:44, 22 December 2015
GPIO state
The current state of the systems' GPIOs can be obtained in user-mode, as shown in the following example:
$ cat /sys/kernel/debug/gpio
The above command on Variscite's VAR-DVK-MX6 will show the following:
root@varsomam33:~# cat /sys/kernel/debug/gpio GPIOs 0-31, platform/44e07000.gpio, gpio: GPIOs 32-63, platform/4804c000.gpio, gpio: gpio-60 (cd ) in lo IRQ GPIOs 64-95, platform/481ac000.gpio, gpio: gpio-82 (wp ) in lo GPIOs 96-127, platform/481ae000.gpio, gpio: gpio-100 (button0 ) in hi IRQ gpio-105 (kim ) out lo gpio-117 (wlan-en-regulator ) out lo GPIOs 510-511, platform/50000000.gpmc, omap-gpmc: gpio-510 (ready ) in hi root@varsomam33:~#
Each GPIO is defined as in or out and the state is shown as lo or hi.
For example pin 110 is the SD-Card card-detect.
When SD-Card is removed the state will be:
gpio-110 (2194000.usdhc cd ) in hi
When the SD-Card is plugged the state will be:
gpio-110 (2194000.usdhc cd ) in lo
Manipulating a single GPIO via /sys/class/gpio
GPIOs in i.MX6 are grouped in groups of 32 pins.
For example GPIO1_3 belong to the first group pin 3. Its absolute number will be 3.
GPIO7_4 will be (7-1)*32+4=196.
Lets assume that you defined this GPIO in the device tree. We will show in the following sections how to define it.
To configure as output:
$ echo 196 > /sys/class/gpio/export $ echo out > /sys/class/gpio/gpio196/direction
Set GPIO high:
$ echo 1 > /sys/class/gpio/gpio196/value
Set GPIO low:
$ echo 0 > /sys/class/gpio/gpio196/value
To configure as input:
$ echo 196 > /sys/class/gpio/export $ echo in > /sys/class/gpio/gpio196/direction
$ cat /sys/class/gpio/gpio196/value
Will read the current value.