* devfs Gpio and interrupt
@ 2011-02-09 14:22 Mancausoft
2011-03-22 15:01 ` Mancausoft
0 siblings, 1 reply; 2+ messages in thread
From: Mancausoft @ 2011-02-09 14:22 UTC (permalink / raw)
To: linux-newbie
[-- Attachment #1: Type: text/plain, Size: 1253 bytes --]
I read gpio.txt in Documentation of kernel and try to use it.
I use:
# echo 13 > /sys/class/gpio/export
# echo in > /root/tasto1/direction
# cat /root/tasto1/direction
in
# cat /root/tasto1/value
1
when the button is pressed:
# cat /root/tasto1/value
0
# cat /root/tasto1/edge
none
# echo both > /root/tasto1/edge
# cat /sys/kernel/debug/gpio
[...]
B5 gpio-13 (sysfs ) in hi irq-77 edge-both
[...]
# cat /proc/irq/77/spurious p
count 15
unhandled 0
last_unhandled 0 ms
cat: p: No such file or directory
Ture:~# cat /proc/irq/77/spurious
count 15
unhandled 0
last_unhandled 0 ms
I try the follow code in a while (1):
// /root/tasto1 is a symbolic link to /sys/class/gpio/gpio13/
pfd.fd = open("/root/tasto1/value", O_RDONLY);
pfd.events = POLLPRI | POLLERR;
//ready = poll(&pfd, 1, -1);
ready = poll(&pfd, 1, 100000);
lseek (pfd.fd, 0, SEEK_SET);
val = read(pfd.fd, buf, 254);
//the output are: 1, 10, 10
printf ("%d, %d, %d\n", ready, pfd.revents, pfd.events);
printf ("%d, %s\n", val, buf );
close(pfd.fd);
But it don't wait for an edge but they exit immediatly.
Why? where is the problem?
--
Mancausoft - http://www.mancausoft.org/
GPG key: B53F90F2
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: devfs Gpio and interrupt
2011-02-09 14:22 devfs Gpio and interrupt Mancausoft
@ 2011-03-22 15:01 ` Mancausoft
0 siblings, 0 replies; 2+ messages in thread
From: Mancausoft @ 2011-03-22 15:01 UTC (permalink / raw)
To: linux-newbie
[-- Attachment #1: Type: text/plain, Size: 966 bytes --]
On 15:22 Wed 09 Feb , Mancausoft wrote:
> I read gpio.txt in Documentation of kernel and try to use it.
> pfd.fd = open("/root/tasto1/value", O_RDONLY);
> pfd.events = POLLPRI | POLLERR;
>
> //ready = poll(&pfd, 1, -1);
> ready = poll(&pfd, 1, 100000);
>
> lseek (pfd.fd, 0, SEEK_SET);
>
> val = read(pfd.fd, buf, 254);
> //the output are: 1, 10, 10
> printf ("%d, %d, %d\n", ready, pfd.revents, pfd.events);
>
> printf ("%d, %s\n", val, buf );
>
> close(pfd.fd);
>
> But it don't wait for an edge but they exit immediatly.
> Why? where is the problem?
My Bad!
now work:
pfd.fd = open("/root/ledverde/value", O_RDWR );
while (1)
{
pfd.events = POLLPRI | POLLERR; // | POLLWRBAND;
lseek (pfd.fd, 0, SEEK_SET);
val = read(pfd.fd, buf, 254);
buf[val] = 0;
//printf ("%d, %s\n", val, buf );
ready = poll(&pfd, 1, -1);
printf("%d\n", ++i);
}
--
Mancausoft - http://www.mancausoft.org/
GPG key: B53F90F2
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-22 15:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-09 14:22 devfs Gpio and interrupt Mancausoft
2011-03-22 15:01 ` Mancausoft
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox