User GPIO Driver

From Gumstix User Wiki
Revision as of 13:45, 11 February 2010 by Dhylands (Talk | contribs) (Initial version of user-gpio driver page)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page documents the user GPIO driver, which is a reflection of the kernel's gpiolib API into user space.

Overview

The kernel provides an API, called gpiolib, which abstracts access to GPIO pins. It has a mechanism for exporting pins into userspace, and in general this is the preferred method of accessing gpio pins from userspace. This method works particularly well if it is setup for a given overo/daughtercard combination. However, since the kernel is often configured in a more generic manner, using the export method is inconvenient, so the user-gpio driver was created.

WARNING: It is possible to damage your overo chip if you do things incorrectly. This code has no way of knowing for example, if a pin is physically connected to an output or not. If, for example, a GPIO pin was connected to Vcc, and you choose to configure that pin as an output and drive it low, you've essentially created a short circuit, and this can stress or damagethe pin, possibly bricking your processor. You have been warned.

Driver Sources

The source code can be found here. The app directory contains the example user mode application. The lib directory contains the usermode library which translates the C API into the appropriate ioctl calls into the kernel driver, and the module directory contains the loadable kernel module. The Makefiles have been setup such that if you define the environment variable OVEROTOP then you should be able to just type make in top level directory and both the app and module will be built.

There are also some bitbake recipes in the gpio-app, gpio-lib and gpio-event-module directories.