For more information on this (if anybody is interested) I got it to work as
follows:
fd = open("/proc/irq/69/irq", O_RDONLY, S_IREAD); // (1)
//............................................................. while
(1) {
read(fd, (int *)buffer, sizeof(int)); // (2)
set( GPIOFEOI , 1<<3); // (3)
// process interrupt here
}
//.............................................................
close(fd); // (4)
Notes:
(1) Various other web posts on this topic have fd = open("/proc/irq/69/irq",
O_RDONLY|O_NONBCLOCK); which causes read() to return always without blocking!
i.e. remove O_NONBLOCK.
(2) The thread will block here until the IRQ pin has gone high. The return
value in 'buffer' is the number of interrupts missed, which can be useful!
(3) Interrupts are level sensitive, not edge sensitive, so read() will block
when the IRQ pin is low and return continuously when the IRQ pin is high! Extra
facilities should be added here to make the hardware return the IRQ pin level
back to zero. (the code shown is for the EP9302 chip).
(4) Important! The file "/proc/irq/78" must be programatically closed somehow
(not shown here) when the program ends. I found that if the application exits
unexpectedly (easily done under development), the handle for this file will
hang and the program will fail if it is called again, necessitating a full
power reboot. It is possible to dislodge the handle from the shell with 'fuser
-k /proc/irq/69/irq' but I haven't found a way to do this programmatically.
(any ideas?)
Hope this is of use.
Tom
>
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|