blob: 6983e77906064b8fdf56524baded6986832cbffd [file] [log] [blame]
Norman Jamese7594922015-08-27 14:25:24 -05001#ifndef __OBJECTS_GPIO_UTILITIES_H__
2#define __OBJECTS_GPIO_UTILITIES_H__
3
4#include <stdint.h>
5#include <gio/gio.h>
Norman James02b77f32015-10-28 18:59:29 -05006#include <stdbool.h>
Norman Jamese7594922015-08-27 14:25:24 -05007
8typedef struct {
9 gchar* name;
10 gchar* dev;
11 uint16_t num;
12 gchar* direction;
13 int fd;
Norman James02b77f32015-10-28 18:59:29 -050014 bool irq_inited;
Norman Jamese7594922015-08-27 14:25:24 -050015} GPIO;
16
17
18//gpio functions
Norman James32e74e22015-09-15 21:28:06 -050019#define GPIO_OK 0
20#define GPIO_ERROR -1
21#define GPIO_OPEN_ERROR -2
22#define GPIO_INIT_ERROR -3
23#define GPIO_READ_ERROR -4
24#define GPIO_WRITE_ERROR -5
25#define GPIO_LOOKUP_ERROR -6
26
27int gpio_init(GDBusConnection*, GPIO*);
Norman Jamese7594922015-08-27 14:25:24 -050028void gpio_close(GPIO*);
29int gpio_open(GPIO*);
Norman James5a7cc8d2015-10-06 12:31:06 -050030int gpio_open_interrupt(GPIO*, GIOFunc, gpointer);
Norman James32e74e22015-09-15 21:28:06 -050031int gpio_write(GPIO*, uint8_t);
32int gpio_writec(GPIO*, char);
33int gpio_clock_cycle(GPIO*, int);
34int gpio_read(GPIO*,uint8_t*);
Norman Jamese7594922015-08-27 14:25:24 -050035
36#endif