Personal tools

Log in

Changes

From IGEP - ISEE Wiki

Jump to: navigation, search

How to use GPIOs

1,034 bytes added, 16:59, 22 September 2015
no edit summary
__TOC__
== Overview ==
This How-To is meant to be a starting point for people to learn use GPIOs for IGEP devices as quickly and easily as possible. For this How-To I used [http://labs.isee.biz/index.php/IGEP_firmware_Yocto IGEP firmware Yocto]
There are more ways to use GPIOs, but this one is very . This article show two simpleways to use gpios: bash commandline and C-code.
== Feedback and Contributing ==For this How-To I used [http://labs.isee.biz/index.php/IGEP_firmware_Yocto IGEP firmware Yocto]
=== Feedback and Contributing ===At any point, if you see a mistake you can contribute to this How-To.Edit yourself !
== Requirements ==
For this How-to, I used:
* IGEPv2 Board
* Only for C-program example it also needed:
** Add shortcircuit cable between J990:20 and J990:22 pins. By default, GPIO 156 (J990:20) and GPIO 157 (J990:22) are available on these J990 pins.
 
Another boards tested:
 
*IGEP COM MODULE
*IGEP COM AQUILA
 
== How to chek an GPIO ==
 
The gpio-int-test.c program shows one way of using the sysfs file /sys/class/gpio/gpioXX/value to block program execution using poll() until the input level on GPIOXX changes.
 
[[File:GPIO_TEST.tar]]
== Bash commandline ==Basic gpio operations could be done using bash and sysfs :* Export GPIOs <pre>echo "GPIO number NN" > /sys/class/gpio/export</pre>** For this How-to, I usedexample:'''echo "156" > /sys/class/gpio/export'''<br><br>* IGEPv2 BoardUnexport GPIOs <pre>echo "GPIO number NN" > /sys/class/gpio/unexport</pre> * [httpSet GPIO direction <pre>echo "out" > /sys/class/gpio/gpioNN/direction</pre>** For example:'''echo "out" > /sys/labs.isee.bizclass/imagesgpio/6gpio156/69direction'''<br><br>* Set GPIO value <pre>echo "1" > /Gpio_examplebeta1.tar.bz2 sys/class/gpio/gpioNN/value</pre>* Get GPIO example]value <pre>cat /sys/class/gpio/gpioNN/value</pre>* Configure hardware interrupts <pre>echo "rising" > /sys/class/gpio/gpioNN/edge</pre>
== Configure IGEPv2==
By default, GPIO 156 (J990:20) and GPIO 157 (J990:22) are available, connect J990:20 and J990:22 with a cable.
== C-program Example program ==
C-program Example program contains some libraries C-functions to control GPIOs, libraries . These also can do:
* Export and unexport GPIOs
* Set GPIO direction
............. </pre>
=== Generate interrupts ===
Open a second remote terminal and type:
<pre>cd /sys/class/gpio/
echo 0 > value
echo 1 > value</pre>
 === Result ===
At first remote terminal you should read a message similar like this:
<pre>poll() GPIO 157 interrupt occurred </pre>