The usual way to respond to an edge-triggered GPIO interrupt, using the old sysfs GPIO interface, is like this:
repeat forever
poll() on POLLPRI event on GPIO fd
lseek() back to 0 on GPIO fd
read() current state from GPIO fd
If I put the code that actually handles the interrupt after the read()
, is it guaranteed that any new interrupt that happens before poll()
is called again will cause that next poll()
to return immediately? In other words, what step re-arms the interrupt? The return from poll()
, the call to lseek()
, the call to read()
, or the next call to poll()
? If it's the last of these, I don't see any way to guarantee that an interrupt can't get lost.
Also, is it necessary to do the read()
? I don't care about the state, just the edge event. And if I don't need read()
, does lseek()
do anything useful? This is hard to test in real life, because it would require generating interrupts in rapid succession on the existing hardware. None of the docs seem to explain this.