Norman James | e759492 | 2015-08-27 14:25:24 -0500 | [diff] [blame] | 1 | #ifndef __OBJECTS_GPIO_UTILITIES_H__ |
| 2 | #define __OBJECTS_GPIO_UTILITIES_H__ |
| 3 | |
| 4 | #include <stdint.h> |
| 5 | #include <gio/gio.h> |
Norman James | 02b77f3 | 2015-10-28 18:59:29 -0500 | [diff] [blame] | 6 | #include <stdbool.h> |
Norman James | e759492 | 2015-08-27 14:25:24 -0500 | [diff] [blame] | 7 | |
| 8 | typedef struct { |
| 9 | gchar* name; |
| 10 | gchar* dev; |
| 11 | uint16_t num; |
| 12 | gchar* direction; |
| 13 | int fd; |
Norman James | 02b77f3 | 2015-10-28 18:59:29 -0500 | [diff] [blame] | 14 | bool irq_inited; |
Norman James | e759492 | 2015-08-27 14:25:24 -0500 | [diff] [blame] | 15 | } GPIO; |
| 16 | |
| 17 | |
| 18 | //gpio functions |
Norman James | c96f837 | 2015-10-31 17:27:41 -0500 | [diff] [blame] | 19 | #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 James | 32e74e2 | 2015-09-15 21:28:06 -0500 | [diff] [blame] | 26 | |
| 27 | int gpio_init(GDBusConnection*, GPIO*); |
Norman James | e759492 | 2015-08-27 14:25:24 -0500 | [diff] [blame] | 28 | void gpio_close(GPIO*); |
| 29 | int gpio_open(GPIO*); |
Norman James | 5a7cc8d | 2015-10-06 12:31:06 -0500 | [diff] [blame] | 30 | int gpio_open_interrupt(GPIO*, GIOFunc, gpointer); |
Norman James | 32e74e2 | 2015-09-15 21:28:06 -0500 | [diff] [blame] | 31 | int gpio_write(GPIO*, uint8_t); |
| 32 | int gpio_writec(GPIO*, char); |
| 33 | int gpio_clock_cycle(GPIO*, int); |
| 34 | int gpio_read(GPIO*,uint8_t*); |
Norman James | e759492 | 2015-08-27 14:25:24 -0500 | [diff] [blame] | 35 | |
| 36 | #endif |