blob: dc439c8e60d8de5787f5c6d17608af65264293ec [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 Jamesc96f8372015-10-31 17:27:41 -050019#define GPIO_OK 0x00
20#define GPIO_ERROR 0x01
21#define GPIO_OPEN_ERROR 0x02
22#define GPIO_INIT_ERROR 0x04
23#define GPIO_READ_ERROR 0x08
24#define GPIO_WRITE_ERROR 0x10
25#define GPIO_LOOKUP_ERROR 0x20
Norman James32e74e22015-09-15 21:28:06 -050026
Matt Spinler0f3fd5a2018-08-08 11:15:26 -050027int gpio_init(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*);
Matt Spinler3a70e932018-08-07 14:16:47 -050035void gpio_inits_done();
Norman Jamese7594922015-08-27 14:25:24 -050036
37#endif