This code is okay and will work over a wide range of different
kernel-versions. If you can live with the fact that you can't wait for a
gpio-event without a active polling loop, then go for it.
There are other ways to do it in a more efficient way: Using
sys/class/gpio with events or binding your GPIO to the input system via
gpio_keys. These may be more efficient but the interface still changes
from kernel-version to kernel-version.
One note to your code: You may not need your fseek-call. It will most
likely work without it.
> Read somewhere about gpiolib.
> But i cant find linux/gpio.h in my toolchain's folder.
> :s
gpiolib is the official kernel-interface to GPIO. It is not accessable
from user-space.
> Am i missing some basic thing here?
No.
Nils
--
You received this message because you are subscribed to the Google Groups "Beagle Board" group.
To post to this group, send email to beagl...@googlegroups.com.
To unsubscribe from this group, send email to beagleboard...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/beagleboard?hl=en.
On Sun, May 8, 2011 at 9:42 AM, Nils Pipenbrinck <n...@planetarc.de> wrote:
> On 05/08/2011 03:02 PM, ZubairLK wrote:
>> I am trying to access gpio's from userspace in c++.
>> Toolchain = the one downloaded from narcissus.
...snip...
>> Read somewhere about gpiolib.
>> But i cant find linux/gpio.h in my toolchain's folder.
>> :s
> gpiolib is the official kernel-interface to GPIO. It is not accessable
> from user-space.
I created a driver which reflects the gpiolib API into user space.
You can find it on my subversion repository here:
http://svn.hylands.org/linux/gpio/
There is a kernel driver, a user-mode library, and an example test app
which uses the library.
I originally did it for the gumstix, and I wrote up a wiki page here:
http://wiki.gumstix.org/index.php?title=User_GPIO_Driver
It should be generic and work on the beagleboard. There isn't anything
gumstix specific in it. I wrote it before the /sys interface existed.
I think it's slightly more efficient as there are fewer kernel to user
transitions, but that's just a gues, not based on any profiling.
--
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com