How can I use EXT_IRQ or a GPIO from my program?
Most of our boards have one or more EXT_IRQ pins and many of our boards have free GPIOs that can be accessed on an external connector. An EXT_IRQ or GPIO can be used to trigger an interrupt from an external device. To handle an interrupt from such a device in your program, you can attach a Linux signal to the EXT_IRQ or GPIO interrupt. (This requires a small kernel module to access the interrupt.) When the interrupt occurs your program can catch the signal and process the interrupt as needed.
Here is a GPIO example for PXA270 boards (BitsyXb) and here are examples for PXA255 boards(BitsyX, AGX, GCX, and VGX).
Here are examples for SA1110 boards. These examples run on the Graphics Client Plus. (Minor modifications may be necessary to make these examples work for other boards.)
Each example consists of a kernel module and a user program. The GPIO example performs reads and writes and handles interrupts from GPIO lines on the CPU. The external interrupt example just handles interrupts from the EXT_IRQ line.
If you have a choice, use a GPIO instead of an EXT_IRQ for your interrupt. On most of our boards, the EXT_IRQ interrupts are edge triggered but GPIO interrupts can be configured as level triggered (active high or low) or edge triggered (on the rising edge, the falling edge, or both edges). Being able to configure the interrupt in software can simply adapting the external device to your board.
To build the examples, you'll have to modify the Makefile to reference the include directory of your kernel source tree and your arm-linux compiler. Then use 'make' to build the modules and user programs for your board.
See the README file for details on how to install and use the examples.
What else can I do with a GPIO ?
In addition to being used to trigger an interrupt, a GPIO can (of course) also be used for digital input and output. The GPIO examples provided above also demonstrate this capability. Furthermore, some GPIOs can even be used to wake up a system from the suspended (sleep) state. The wake up pin is an example of this. If you need another GPIO to wake up the system - in addition to the wake up pin already provided - and your board has a free, externally available pin for a GPIO that supports wake up, then you can modify the kernel to do this. Contact us for details.
What if I have a board with a level triggered EXT_IRQ interrupt ?
On some of our boards, the EXT_IRQ interrupt is level triggered (active low). This means the interrupt handling routine should take action to clear the interrupt (thus driving the pin high) before returning. If this is not done, another interrupt will immediately be triggered. If your external device on the EXT_IRQ pin cannot be cleared this way, consider using a GPIO interrupt instead (assuming your board has a free GPIO with an external connection). GPIO interrupts can be level or edge triggered. When configured to trigger on the rising, falling, or both edges, a GPIO interrupt does not have to be cleared by the handler.
23-Jun-2004: jlackey - provide more details and add PXA examples
30-Aug-2007: rwhaley - PXA270 example |