nanogui: Button interaction over GPIO
Subject:
Button interaction over GPIO
From:
Raph HP ####@####.####
Date:
6 Nov 2006 10:37:39 +0000
Message-Id: <454F025F.2070302@gmx.fr>
Hello,
I am looking for a way to have some interaction with Nano-X through
buttons connected via general purpose I/O (GPIO) to an ARM9 board
running Linux 2.6.15.
By now, I am launching a thread that simply reads all GPIO ports all
30ms (the code is below). But it does not work well, it lasts a long
time until Nano-X reacts to the pressing of a key.
I guess it would be the best to use Nano-X's event handling. But in
order to achieve that, I suppose that I need a driver, don't I?
Any help would be very appreciated
Thanks
raph
/* read ports */
while (1) {
port = 2;
result = read(handle[port], &b[port], 1);
if (b[port] == 0x07) { /* button connected to 2 pressed */
if (red_button_state == 0) {
red_button_state = 1;
printf("DEBUG: red button switched on\n");
}
}
else {
if (red_button_state == 1) {
printf("DEBUG: red button switched off\n");
red_button_state = 0;
}
}
if (result != 1) {
perror("Can't read byte from port");
return;
}
usleep(READ_CONST * 1000);
}