GPIO Interrupt

HI,
I'm searching for an example for a GPIO Interrupt in Linux.
If there is no example maybe someone can give me a good intro.

regards

willi

Re: GPIO Interrupt

Which product and kernel version do you use? In most cases you will have to write a kernel driver to use interrupts on a GPIO pin.

Re: GPIO Interrupt

Okay, I will use this thread. I'm trying to get an Interrupt into userspace on the Stamp9G20. For this an little kernel-module was written which configures an GPIO-Pin and provides an Interrupt Handler.
The Task of this Module is to perform a restart or a shutdown if a interrupt occurse.
There are two possibilities:
First is the module restarts Linux. This should be simple but I don't know how to restart the System from in kernelspace.
The second is to notify an userspace program. This could be a little trickier. I tried HOWTOs discribing howto use sysfs. But it does not work for me. I "see" the Interrupts in the MOdule but couldn't pass it to userspace.

Anyone has a hint for me? Or maybe a Link?
Im working on Stamp9G20 and using Kernel 2.6.37.

Re: GPIO Interrupt

In my opinion, the easiest would be to implement a blocking read, which just returns to your application on your interrupt. Your application could then a) either do any action or b) reboot.

Re: GPIO Interrupt

If you use edge triggered interrupts, it might be possible, that you don't even need to write a kernel module. The generic gpio sysfs interface all ready supports "forwarding" egde interrupts to userspace. Just write "both" into the "edge" file of the corresponding gpio in the sysfs interface and then use poll() on the value file in your user space program.

I have not tested it, but according to the documentation, it should work.

Syndicate content