From: Dave H. <dhy...@gm...> - 2010-11-08 01:51:26
|
Hi Bertho, On Sun, Nov 7, 2010 at 6:21 AM, Bertho Stultiens <be...@va...> wrote: > Hi, > > I'm looking for examples for gpio input events using poll(2). I'm > running on an Overo/Chesnut and the (unstable) overo-branch on kernel > 2.6.34. > > Gpio 186 (on the extension board) is set to input and I want to hang > until it goes from 1 to 0. It looks like the kernel supports this by > exporting the "edge" file in sysfs and setting it to "falling". At > least, according to what I understand from the kernel documentation. > However, example code for userspace, it seems, is in rare supply. I am a > bit mystified by what parameters poll is expecting and how it interacts > with read. This document: <http://lwn.net/images/pdf/LDD3/ch06.pdf> describes poll and select from the driver perspective. What poll does is to determine which file descriptors, from a set of file descriptors, has data to be read. This is useful if you're waiting for data from many different file descriptors. Poll also only works For the gpio-event driver, you can just issue a read and it will block until an event is available. You can also put the file descriptor into non-blocking mode, in which case, the read will always return immediately, whether an event is available or not. I normally just launch a thread that does blocking reads waiting for an event. > The input works when I can cat the value from a shell, but I'm quite > lost on the event system. Any pointers appreciated. > > BTW, some documentation I found was about gpio-event (recipe in branch), > but that does not compile and it seems that it is for older kernels. The gpio event driver mentioned over here: <http://www.gumstix.net/wiki/index.php?title=GPIO_Event_Driver> should compile under bit-bake. It probably needs some tweaks to work as a standalone build (I designed it to build without needing bitbake, but it depends on knowing where the crosscompiler and stuff is, and I'm pretty sure that those changed since I wrote it). The event stuff in the /sys tree is not related to gpio-event. At least I think it is (it depends on exactly which keys you're talking about). I'll download the latest stuff for the gumstix and see what build issues I run into. Feel free to ask questions about gpio-event. -- Dave Hylands Shuswap, BC, Canada http://www.DaveHylands.com/ |