Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => A13 => Topic started by: krbonne on April 03, 2014, 12:52:48 AM

Title: userland application reacting to hardware interrupt
Post by: krbonne on April 03, 2014, 12:52:48 AM
Hi,

Not specifically a question for the A13, but as there is no forum dedicated to generic linux coding, I'll ask it here.

How do I write a userland application that reacts to a hardware interrupt on one of the IO pins. I want to interface with a chip (NRF24L01) that uses SPI to control it, but returns a hardward interrupt on an events (like "packet received").

Any info on how to code this? (in preference in C).


Cheerio! Kr. Bonne.
Title: Re: userland application reacting to hardware interrupt
Post by: vinifr on April 03, 2014, 08:07:23 PM
This could be help: https://developer.ridgerun.com/wiki/index.php/How_to_use_GPIO_signals (https://developer.ridgerun.com/wiki/index.php/How_to_use_GPIO_signals)

I'm writing an article about GPIO usage, will soon be ready.  ;)
Title: Re: userland application reacting to hardware interrupt
Post by: MBR on April 03, 2014, 09:41:10 PM
If a GPIO has the edge file in its directory, it can generate hardware interrupt. The C code example is at https://developer.ridgerun.com/wiki/index.php/Gpio-int-test.c (https://developer.ridgerun.com/wiki/index.php/Gpio-int-test.c), the main key is to use poll() to wait on value file.
Title: Re: userland application reacting to hardware interrupt
Post by: krbonne on April 07, 2014, 06:05:29 PM
Hi MBR, vinifr,

I'm sorry for the late reply. (been busy couple of days).

OK, this is funny.
It looks like I had already tried out the application you mention. But, when doing copy-and-paste, I had put the "fopen" insite the while loop, so the application didn't work. I made the wrong conclussions because of that. How stupid! :-(

OK. It now works. Thanks!

Now I only need to find out how to access the spi bus on the A13 and I can get started.


Cheerio! Kr. Bonne?