How to use GPIO signals: Difference between revisions
Line 59: | Line 59: | ||
* elinux.org/images/d/d4/Celf-gpio.odp | * elinux.org/images/d/d4/Celf-gpio.odp | ||
* http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:gpio-sysfs | * http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:gpio-sysfs | ||
==== LeopoardBoard 365 GPIO 0 connection ==== | |||
On the LeopardBoard 365, the only GPIO I could find that was usable for interrupt input is GPIO0, also called CMOS_TRIGGER in the schematics. In looking at the schematics resistor R12 is not loaded and one of the pads connects to CMOS_TRIGGER. This R12 pad is the one closest to R11. If you hold the leopardboard 365 with the SD card slot facing you and rotate the board until the SD card slot is on the bottom edge, the the R12 pads are to the right of J6 and to the left of the SD card slot upper left corner. | |||
[[File:Leopardboard365-gpio0-haywire.jpg|200px]] | |||
== Viewing GPIO Configuration == | == Viewing GPIO Configuration == |
Revision as of 16:05, 23 February 2011
References
GPIO Usage from a Linux Application
Configure the kernel for GPIO support in sysfs
Symbol: GPIO_SYSFS [=y] Prompt: /sys/class/gpio/... (sysfs interface) Defined at drivers/gpio/Kconfig:51 Depends on: GPIOLIB && SYSFS && EXPERIMENTAL Location: -> Kernel configuration -> Device Drivers -> GPIO Support (GPIOLIB [=y])
Enable GPIO from user space
GPIO=22 cd /sys/class/gpio ls echo $GPIO > export ls
Notice on the first ls that gpio22 doesn't exist, but does after you export GPIO 22 to user space.
cd /sys/class/gpio/gpio$GPIO ls
There are files to set the direction and retrieve the current value.
echo "in" > direction cat value
You can configure the GPIO for output and set the value as well.
echo "out" > direction echo 1 > value
GPIO interrupts from user space
Reference
- http://bec-systems.com/site/281/how-to-implement-an-interrupt-driven-gpio-input-in-linux
- http://www.spinics.net/lists/linux-newbie/msg01028.html
- elinux.org/images/d/d4/Celf-gpio.odp
- http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:gpio-sysfs
LeopoardBoard 365 GPIO 0 connection
On the LeopardBoard 365, the only GPIO I could find that was usable for interrupt input is GPIO0, also called CMOS_TRIGGER in the schematics. In looking at the schematics resistor R12 is not loaded and one of the pads connects to CMOS_TRIGGER. This R12 pad is the one closest to R11. If you hold the leopardboard 365 with the SD card slot facing you and rotate the board until the SD card slot is on the bottom edge, the the R12 pads are to the right of J6 and to the left of the SD card slot upper left corner.
Viewing GPIO Configuration
You can use debugfs to videw the current GPIO configuration. You may also be able to use debugfs to see if the GPIO pin is multiplex as a GPIO or is dedicated to some other function.
Configure the kernel to enable debugfs:
Symbol: DEBUG_FS [=y] Prompt: Debug Filesystem Defined at lib/Kconfig.debug:77 Depends on: SYSFS Location: -> Kernel configuration -> Kernel hacking
Boot the target hardware and mount debugfs:
mount -t debugfs none /sys/kernel/debug
Dump the GPIO configuration.
cat /sys/kernel/debug/gpio
Dump the pin multiplexing configuration.
cat /sys/kernel/debug/omap_mux/board