This article explains how to manage the General Purpose Input Output (GPIO) lines on the Acme Boards
The Linux Kernel defines a standard way to manages the GPIO lines an application running in user mode called Sysfs. This method follows the classic Unix phylosophy where "Everything is a file" where also the GPIOs are simple files exposed through the filesystem.
For example the logic state of the physical line W9 on the Aria G25 module can be changed writing on the file /sys/class/gpio/gpio54/value. So to turn on the led shown below simply use this command:
echo 1 > /sys/class/gpio/gpio54/value
and to turn off:
echo 0 > /sys/class/gpio/gpio54/value

To read a GPIO line, for example the pushbutton on W15, simply read the value:
cat /sys/class/gpio/gpio54/value
The numeric part of the path name used in these examples (54 and 60) are unique identification numbers provided by the GPIO Linux driver called Kernel ID.
You need to know the right Kernel ID for any line. On the boards pinout pages you can find the pins/Kernel IDs maps for all the Acme boars and modules pins.
Before using a GPIO line you have to ask to sysfs driver to create its file tree in the file systems. To do that write the kernel ID on the file /sys/class/gpio/export.
echo 54 > /sys/class/gpio/export echo 60 > /sys/class/gpio/export
After that you have to tell to the driver the GPIO direction (Input or Output) by writing on the direction file inside the new files tree:
echo out > /sys/class/gpio/gpio54/direction echo in > /sys/class/gpio/gpio60/direction
Other files are available inside the file tree created for any GPIO, please refer to the GPIO Kernel documentation for more details.
Using the Python ablib module available in the code playground repository it is possible to manage the GPIO using its pin name instead of the Kernel ID. Let's see some examples.
On the Aria G25 SoM the GPIO lines are available on PCB pads identified by the side letter and pad number (pinout).
This example set the line W9 line as output and change its state using the on() and off() methods of Pin class:
import ablib
led = ablib.Pin('W','9','low')
led.on()
led.off()
On the FOX Board G20 the GPIO lines are available on J6 and J7 group of pads identified by the group name and the pad number (pinout).
This example set the line J7.3 line as output and change its state using the on() and off() methods of Pin class:
import ablib
led = ablib.Pin('J7','3','low')
led.on()
led.off()
On the FOX Board G20 with the DAISY-1 adapter mounted on top the GPIO lines are available on the Daisy connectors (pinout).
In is possible to get a GPIO line using for example a DAISY-12 protoboard and set the GPIO line using the on() and off() methods of Pin class:
import ablib
led = ablib.Pin('D5','2','low')
led.on()
led.off()
On the TERRA Board the GPIO lines are available on the Daisy connectors (pinout).
In is possible to get a GPIO line using for example a DAISY-12 protoboard and set the GPIO line using the on() and off() methods of Pin class:
import ablib
led = ablib.Pin('D11','2','low')
led.on()
led.off()
If you are using a Daisy module with leds, relays or other output devices you can use directly the name of the devices written on the PCB silk screen.
Following is an example to turn on a led on the DAISY-11 eight leds module:
import ablib
led = ablib.Daisy11('D11','L1')
led.on()
led.off()
This is an example with a Daisy-8 relay board plugged on D12 connector
import ablib
relay = ablib.Daisy8('D12','first','RL0')
relay.on()
relay.off()
The 'first' parms indicated that the Daisy8 used is plugged as first board on the flat cable. Up to board can be wired on the same daisy cable: 'first' and 'second'.
In the same way it is possible to read a GPIO lines using two methods:
This mode consists to check the actual state of the line calling the get_value() method. This is an example on Aria G25 SoM:
import ablib
PB=ablib.Pin('W','15','in')
#Never ending loop
while True:
if (PB.get_value()==0):
print "Pressed"
while PB.get_value()==0:
pass
This mode consists to register a callback function with the set_edge() method that will call when the GPIO lines changes its state.
import time, ablib
def pressed():
print "Pressed"
PB=ablib.Pin('W','15','in')
PB.set_edge("falling",pressed)
#Never ending loop
i=0
while True:
print i
i=i+1
time.sleep(0.5)
On Aria G25 and Terra it is possible to register the callback for different condition:
On FOX Board G20 only the both condition is available.
The Atmel CPUs used on the Acme boards arranges the GPIO in ports of 32 lines each called Port A, Port B, Port C, etc.
Most of the CPU pins are muxed with other peripherals (UART, I2C, SPI, etc.) and can be configured as simple GPIO line changing the Kernel configuration at boot time.
![]() | Aria G25 is a small and low-cost multi-chip module that integrates:
| More info... | |
![]() | TERRA is a carrier board conceived both to evaluate the Aria G25 SoM and to make prototypes or small production batches of OEM equipments using the Daisy cabling system. |
![]() | FOX Board G20 is a "ready-to-run" Embedded Linux System perfect to use as a solid state WEB server or as a core engine for your embedded appliances. A fully Open Source environment is available to customize and build your own kernel image or to develop user applications using standard GNU tools. Version with Atmel AT91SAM9G20 with 256KB of FLASH memory, 64MB of RAM and up to 16GB of microSD. FOXG20 needs some extra accessories in order to be operative:
An evalution kit with all the accessories you need to get started with FOX Board G20 is available on-line on this link: COMBO-2. | More info... | |
|
|
Atmel© Certified Partner |
Documentation Terms of Use
Acme Systems provides this documentation "as is" without warranty or guarantees of any kind.
The mantainer of this site (Sergio Tanzilli), has gone to a great deal
of effort into making this documentation as correct as possible.
Acme Systems doesn't provide any direct support for the Open Source preinstalled software but provides, through
these pages and forum posts, all the information required to obtain the sources, install, use and update the
Open Source softwares runnable on the FOX Board, NetusG20, AriaG25 and Terra platforms.
Please note that all the preinstalled softwares, used on the Acme Systems products, are Open Source and you will
have to check the license terms provided (usually the GPL) by each author before using it in any commercial or non-commercial
product, by yourself.
Before sending emails or calling the Acme staff here are our contacts
please note that WE ARE MAINLY HARDWARE DESIGNERS and NOT LINUX GURUS so could be better to post
your questions directly to the forum listed below to be sure that all the contributors of this site and
the large software developers community will read and reply to your questions.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.