BeagleBone Black receives user space interrupts

I am using C ++ library (easyBlack) to handle GPIO through / dev / mem.

As I saw in chapter "25.3.3 Interrupt Functions" in "AM335x SitaraTM Processors - Technical Reference Manual"

To generate an interrupt request to the main processor for a specific event (level or logic transition) that occurs on the GPIO pin, the GPIO configuration registers must be programmed as follows:

โ€ข Interrupts for the GPIO channel must be included in the GPIO_IRQSTATUS_SET_0 and / or GPIO_IRQSTATUS_SET_1 registers.

โ€ข Pending events on the GPIO input to trigger an interrupt request must be selected in the GPIO_LEVELDETECT0, GPIO_LEVELDETECT1, GPIO_RISINGDETECT and GPIO_FALLINGDETECT registers.

So far so good, but all the documentation I can find is based on Linux kernel header files ("linux / gpio.h" and "linux / interrupt.h") and it seems that they cannot be used for a space program user. only in modules. Or examples that use kernel drivers and look at the state file in sysfs to implement an interrupt. This may work, but is slow and resource intensive.

Is there any other alternative other than working with multithreading to see if the values โ€‹โ€‹change the required pins? (Like this other library - github.com/jackmitch/libsoc)

Maybe compile easyBlack as a kernel module?

Thank!

+3


source to share


1 answer


Unfortunately, true interrupts cannot be obtained in user space. This is why all interrupt-dependent code is written either in the kernel module or in the kernel itself. This is usually fine. The ISR should be as fast as possible by design and leave the actual processing scheduled later. This is similar to what you mentioned above with the status file in sysfs. To you, however, it looks like the easyBlack library maintains memory mapping to GPIO memory space in user space and then allows you to poll the status of the pin. The examples shown will be extremely processing intensive, since there is no sleep in the main loop during sleep. This means that the process will take as much CPU time as the scheduler will allow.

Since Beaglebone runs an embedded Linux kernel, I assume the libGPIO driver was written to support GPIO. LibGPIO is a framework in the Linux kernel that abstracts some of the gora details of various GPIO devices and provides a standard interface. Try searching in the catalog /sys/class/gpio

. This should give you either a GPIO list or GPIO Chips.



Here is the GPIOsysfs documentation https://www.kernel.org/doc/Documentation/gpio/sysfs.txt

Your user's software can open the "value" file of the corresponding GPIO and can use the "poll" function on that filedescriptor. This will allow your software to block until the GPIO changes and then act accordingly, which will give you a pseudo interrupt in user space.

+1


source







All Articles