Personal tools

Log in

Changes

From IGEP - ISEE Wiki

Jump to: navigation, search

How to use GPIOs

1,031 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
For this == Howto chek an GPIO == The gpio-int-test.c program shows one way of using the sysfs file /sys/class/gpio/gpioXX/value to, I usedblock 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 :* IGEPv2 BoardExport GPIOs <pre>echo "GPIO number NN" > /sys/class/gpio/export</pre>* [http* For example:'''echo "156" > /sys/labs.isee.bizclass/gpio/export'''<br><br>* Unexport GPIOs <pre>echo "GPIO number NN" > /sys/imagesclass/6gpio/69unexport</Gpio_examplebeta1.tar.bz2 pre> * Set GPIO direction <pre>echo "out" > /sys/class/gpio/gpioNN/direction</pre>** For example]: '''echo "out" > /sys/class/gpio/gpio156/direction'''<br><br>* Set GPIO value <pre>echo "1" > /sys/class/gpio/gpioNN/value</pre>* Get GPIO 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
echo 1 > value</pre>
=== Result ===
At first remote terminal you should read a message similar like this:
<pre>poll() GPIO 157 interrupt occurred </pre>