Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Interrupts in uClinux

Altera_Forum
Honored Contributor II
1,297 Views

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.
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
279 Views

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
0 Kudos
Altera_Forum
Honored Contributor II
279 Views

Thanks wentao, I went for the poll & block route which went rather successfully.

0 Kudos
Reply