* [[:|Wiki Home]]
* [[:cheat_sheet|Cheat Sheet]]
* [[:compiling_on_virtualbox|Precompiled virtual tools]]
* [[:carambola_where_to_start|Where to start]]
* [[:carambola_connecting|Connecting to carambola]]
* [[:carambola_using_and_customizing|Using and Customizing]]
* [[:carambola_demo_projects|Demo projects/examples]]
* [[:carambola_hardware|Hardware]]
====== About ======
This short tutorial describes how to get GPIO working. For this you need tool called ''gpioctl''. Table describing which pin is where can be found here: [[carambola_pinout|]].
====== Building/installing ======
* Type ''make menucongfig''
* Under ''Utilities'' select package ''gpioctl'' and build carambola firmware (although you can do it directly on carambola typing ''opkg update; opkg install gpioctl'')
* In latest revisions gpioctl become deprecated. If you still need to use it, install from [[http://pkg.8devices.com/v2.2/carambola/packages/gpioctl_1.0-1_ramips.ipk|older repository]].
====== Testing ======
===== Prepare GPIO as output =====
gpioctl dirout 1; gpioctl dirout 2
===== Set both to 1 =====
gpioctl set 1; gpioctl set 2
===== Clear both =====
gpioctl clear 1; gpioctl clear 2
===== Read status =====
gpioctl dirin 1; gpioctl dirin 2; gpioctl get 1; gpioctl get 2
====== Controlling gpio pins as files in /sys ======
Another method for controlling gpios using files instead of commands:
cd /sys/class/gpio
echo 1 > export
this will make the virtual directory "gpio1" available in /sys/class/gpio/gpio1
inside "gpio1" you will find, among others:
* direction ("in" or "out")
* value (0 or 1)
Just write/read those file to do I/O.
For example
echo out > direction
echo 1 > value
will put the pin in output mode and high
echo in > direction
cat value
will read the pin instead