declare create interrupts gpio tren beaglebone black

Hello all,
I am trying to generate interrupts on the board Beaglebone black, but not yet know how to declare
I using library BlackLib c++.
Please give me answers

BlackLib is for user space programming. To process interrupts, you have to be in kernel space so you have to use a Kernel Module or Device Driver to process interrupts. To pass the event onto user space, there are several options, such as blocking on a read, or sigaction, etc. Best to read Linux Device Driver 3rd edition on how to do this. Search Google as this book is online.


I found this info in the book "Mastering Embedded Linux Programming” by Chris SimmondsHANDLING INTERRUPTS FROM GPIO

In many cases, a GPIO input can be configured to generate an interrupt when it changes state, which allows you to wait for the interrupt rather than polling in an inefficient software loop. If the GPIO bit can generate interrupts, the file edge exists. Initially, it has the value none, meaning that it does not generate interrupts. To enable interrupts, you can set it to one of these values:

• rising: Interrupt on rising edge

• falling: Interrupt on falling edge

• both: Interrupt on both rising and falling edges

• none: No interrupts (default)

You can wait for an interrupt using the poll() function with POLLPRI as the event. If you want to wait for a rising edge on GPIO 48, you first enable interrupts:

echo 48 > /sys/class/gpio/export

echo rising > /sys/class/gpio/gpio48/edge

Then, you use poll() to wait for the change, as shown in this code example:

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <poll.h>

int main (int argc, char *argv[])
int f;
struct pollfd poll_fds [1];
int ret;
char value[4];
int n;
f = open("/sys/class/gpio/gpio48", O_RDONLY);
if (f == -1) {
perror(“Can’t open gpio48”);
return 1;
poll_fds[0].fd = f;
poll_fds[0].events = POLLPRI | POLLERR;
while (1) {
ret = poll(poll_fds, 1, -1);
if (ret > 0) {
n = read(f, &value, sizeof(value));
printf(“Button pressed: read %d bytes, value=%c\n”,
n, value[0]);
return 0;