An in-deep explanation on how the GPIO lines work and how to manage them faster is available on:
This is a small group of Linux utilities for the Atmel AT91SAM9G25 and AT91SAM9G20 microcontroller units (MCUs). The utilities target The Aria G25 and the FoxG20 boards from Acme Systems and will most likely work on other boards based on the same MCUs. Some of the utilities have the same names as those from the earlier FoxLX board from Acme System; that board was based on the Etrax LX processor from Axis communications.
These utilities mainly work with individual GPIO lines and may be extended to other protocols that can be implemented by "bit banging" GPIO lines. These include I2C (a.k.a. TWI), "one wire" (known as "w1" by the Linux kernel) from Dallas Semiconductor (now Maxim), and the two wire protocol for the SHT-71 .
Download on your board the latest utilities version from the D.Gilbert web server
~# wget http://sg.danny.cz/foxg20/ag25g20_utils-0.97r14.tgz
Uncompress the .tgz file
~# tar xvzf ag25g20_utils-0.97r14.tgz
Compile and install them
~# cd ag25g20_utils-0.97r14 ~/ag25g20_utils-0.97r14# make ~/ag25g20_utils-0.97r14# make install
Refer to the original README file to learn how to use these utilities
Following is a list of quick examples:
~# g25gpio_status -h
~# g25gpio_status -a -p A PA0: PIO status: 0 (peripheral ACTIVE) PIO output status: 0 (line pure input) input filter status: 0 (glitch filter DISabled) output data status: 0 pin data status: 0 interrupt mask: 0 (DISabled) multi driver status: 0 (pin driven high and low) pad pull-up status: 0 (ENabled) peripheral A function [sr1:0, sr2:0] input filter slow clock status: 0 (master-fast) pad pull down status: 1 (DISabled) additional interrupt modes mask: 0 (Both edges) edge/level status: 0 (edge detection) fall/rise - low/high status: 0 (falling edge or low level detection) locked status: 0 (not locked) write protect mode: WPEN: 0 (DISabled) schmitt trigger status: 0 (ENabled ) IO drive: 0 (HI_DRIVE) ...
of course it is possible to read all the other ports
~# g25gpio_status -a -p B ~# g25gpio_status -a -p C
~# g25gpio_set -h
~# g25gpio_set -p B -b 11 -u ~# g25gpio_set -p B -b 12 -u ~# g25gpio_set -p B -b 13 -u ~# g25gpio_set -p B -b 14 -u