I work on a system with embedded Linux (Kernel 2.6.31).
Inside is the AT91SAM9G20 chip, and some pins are brought out.
Now I want to use them as GPIO inputs.
I read the gpio.txt documentation on using GPIO through the file system, and it works very well, for now. I connected some switches to gpio pins and see the result in /sys/class/gpio/gpioX/value
. But now I would like to respond to the change without expecting a loop. (i.e., the echo "Switch1 has been pressed").
I think I need interrupts, but I could not figure out how to use them without writing my own kernel driver. I am relatively new to Linux and C (I usually program in Java), so I would like to handle interrupts through sysfs as well. But my problem is that in my GPIO directory there is no "edge" -file (I suppose, because this is only from kernel version 2.6. 33+). It is right? Instead of "edge" I have an uevent
file that is not described in gpio.txt
.
The gpio.txt documentation mentions a standard kernel driver: "gpio_keys". Can this be used for my problem?
I think it would be better to work with this driver than to allow the user program to manage kernel tasks. I found many codenippets for writing my own driver, but I could not even figure out which of the 600 gpio.h
files gpio.h
include and how to access the library (the cross-compiler could not find the gpio. H file).
Sorry for the newbie's questions, I hope you could give me some advice.
thank you in advance
source share