]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/blob - mt_gpio.h
mt_server: Use "%s" format string in syslog()
[coffee/mt-apps.git] / mt_gpio.h
1 #ifndef MT_GPIO_H
2 #define MT_GPIO_H
3
4 #include <ev.h>
5 #include <gpiod.h>
6
7 typedef struct mt_gpio_dev_t {
8     unsigned int chip;
9     unsigned int offset;
10     char key;
11 } mt_gpio_dev_t;
12
13 #define GPIO_COUNT 20
14 #ifndef GPIO_CONSUMER
15 #define GPIO_CONSUMER "mtgpio"
16 #endif
17 #define GPIO_ACTIVE_LOW 1
18
19 #define ADV_GPIO_PINS \
20 { \
21     {0, 27, 'A'}, \
22     {0, 29, 'B'}, \
23     {0, 25, 'C'}, \
24     {0, 30, 'D'}, \
25     {5, 31, 'E'}, \
26     {2, 30, 'F'}, \
27     {2, 31, 'G'}, \
28     {2, 21, 'H'}, \
29     {4,  2, 'I'}, \
30     {2, 20, 'J'}, \
31     {2, 23, 'K'}, \
32     {5, 11, 'L'}, \
33     {1,  2, 'M'}, \
34     {5,  9, 'N'}, \
35     {1,  3, 'O'}, \
36     {5, 16, 'P'}, \
37     {5,  7, 'Q'}, \
38     {1,  4, 'R'}, \
39     {1,  0, 'S'}, \
40     {5,  8, 'T'}  \
41 }
42
43 const mt_gpio_dev_t pins[GPIO_COUNT] = ADV_GPIO_PINS;
44
45 typedef struct ev_io_gpio {
46     ev_io w;
47     int fd;
48     char key;
49 } ev_io_gpio;
50
51 typedef struct mt_gpio_t {
52     ev_io_gpio w[GPIO_COUNT];
53     struct gpiod_chip *chip[GPIO_COUNT];
54 } mt_gpio_t;
55
56 int mt_gpio_init(mt_gpio_t *self, struct ev_loop *loop, int fd);
57
58 void mt_gpio_deinit(mt_gpio_t *self);
59
60 #endif