fixed interrupt handling
diff --git a/includes/gpio.c b/includes/gpio.c
index 51c2b82..6fed039 100644
--- a/includes/gpio.c
+++ b/includes/gpio.c
@@ -183,16 +183,17 @@
int gpio_open_interrupt(GPIO* gpio, GIOFunc func, gpointer user_data)
{
int rc = GPIO_OK;
- char* buf;
+ char buf[255];
sprintf(buf, "%s/gpio%d/value", gpio->dev, gpio->num);
gpio->fd = open(buf, O_RDONLY | O_NONBLOCK );
+ gpio->irq_inited = false;
if (gpio->fd == -1)
{
rc = GPIO_OPEN_ERROR;
}
else
{
- GIOChannel* channel = g_io_channel_unix_new( gpio->fd );
+ GIOChannel* channel = g_io_channel_unix_new( gpio->fd);
guint id = g_io_add_watch( channel, G_IO_PRI, func, user_data );
}
return rc;
diff --git a/includes/gpio.h b/includes/gpio.h
index d9279e4..6983e77 100644
--- a/includes/gpio.h
+++ b/includes/gpio.h
@@ -3,6 +3,7 @@
#include <stdint.h>
#include <gio/gio.h>
+#include <stdbool.h>
typedef struct {
gchar* name;
@@ -10,6 +11,7 @@
uint16_t num;
gchar* direction;
int fd;
+ bool irq_inited;
} GPIO;