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; |
Anthony Wilson | c0c74e7 | 2019-03-06 10:54:58 -0600 | [diff] [blame] | 12 | uint16_t chip_id; |
Norman James | e759492 | 2015-08-27 14:25:24 -0500 | [diff] [blame] | 13 | gchar* direction; |
| 14 | int fd; |
Norman James | 02b77f3 | 2015-10-28 18:59:29 -0500 | [diff] [blame] | 15 | bool irq_inited; |
Norman James | e759492 | 2015-08-27 14:25:24 -0500 | [diff] [blame] | 16 | } GPIO; |
| 17 | |
| 18 | |
| 19 | //gpio functions |
Norman James | c96f837 | 2015-10-31 17:27:41 -0500 | [diff] [blame] | 20 | #define GPIO_OK 0x00 |
| 21 | #define GPIO_ERROR 0x01 |
| 22 | #define GPIO_OPEN_ERROR 0x02 |
| 23 | #define GPIO_INIT_ERROR 0x04 |
| 24 | #define GPIO_READ_ERROR 0x08 |
| 25 | #define GPIO_WRITE_ERROR 0x10 |
| 26 | #define GPIO_LOOKUP_ERROR 0x20 |
Norman James | 32e74e2 | 2015-09-15 21:28:06 -0500 | [diff] [blame] | 27 | |
Norman James | e759492 | 2015-08-27 14:25:24 -0500 | [diff] [blame] | 28 | void gpio_close(GPIO*); |
Anthony Wilson | c0c74e7 | 2019-03-06 10:54:58 -0600 | [diff] [blame] | 29 | int gpio_open(GPIO*, uint8_t); |
Norman James | 32e74e2 | 2015-09-15 21:28:06 -0500 | [diff] [blame] | 30 | int gpio_write(GPIO*, uint8_t); |
Anthony Wilson | c0c74e7 | 2019-03-06 10:54:58 -0600 | [diff] [blame] | 31 | int gpio_get_params(GPIO*); |
Norman James | 32e74e2 | 2015-09-15 21:28:06 -0500 | [diff] [blame] | 32 | int gpio_read(GPIO*,uint8_t*); |
Matt Spinler | 3a70e93 | 2018-08-07 14:16:47 -0500 | [diff] [blame] | 33 | void gpio_inits_done(); |
Norman James | e759492 | 2015-08-27 14:25:24 -0500 | [diff] [blame] | 34 | |
| 35 | #endif |