- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can someone please help me? I want to use the onboard buttons but I don't want to poll them continuously. With the altera_pio_button driver, 1, 2, 4 or 8 is written to /dev/buttons when a button is pressed, but it seems unnecessary to do the following to check each time whether a button was pressed:
FILE *btn = fopen( "/dev/buttons", "r" );
int Number=0;
fscanf(btn, "%d", &Number);
printf("%d\n", Number);
fclose(btn);
I also noted an interrupt.h header. Can this be used, or is it only for device drivers? I can also access the buttons the following way: np_pio *pio = na_button_pio;
int buttons;
pio->np_pioedgecapture = 0; // clear the irq condition
buttons = pio->np_piodata;
but again without interrupt, since the alt_irq_register() function won't work.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Pierre,
Interrupts are not available for applications under Linux. My advice is, a. let your application block on reading the button device. It will return whenever the button is pressed. If your application needs to check more than one devices/files, use select/poll function. b. or, enhance the basic button driver in kernel to implement the asynchronous part --- sending SIGIO to the process that has openned the device. Your application needs to implement a signal handler for SIGIO. There might be a noticeable delay between the action and the response. Hope this helps, wentao- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks wentao, I went for the poll & block route which went rather successfully.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page