-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathi_tiny_gpio_group.h
50 lines (38 loc) · 1.21 KB
/
i_tiny_gpio_group.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*!
* @file
* @brief Abstract group of GPIOs.
*/
#ifndef i_tiny_gpio_group_h
#define i_tiny_gpio_group_h
#include <stdint.h>
#include <stdbool.h>
#include "i_tiny_gpio.h"
typedef uint8_t tiny_gpio_channel_t;
struct i_tiny_gpio_group_api_t;
typedef struct {
const struct i_tiny_gpio_group_api_t* api;
} i_tiny_gpio_group_t;
typedef struct i_tiny_gpio_group_api_t {
/*!
* Set the direction of the GPIO channel.
*/
void (*set_direction)(
i_tiny_gpio_group_t* self,
tiny_gpio_channel_t channel,
tiny_gpio_direction_t direction);
/*!
* Read the state of the GPIO channel (must be configured as an input).
*/
bool (*read)(i_tiny_gpio_group_t* self, tiny_gpio_channel_t channel);
/*!
* Write the state of the GPIO channel (must be configured as an input).
*/
void (*write)(i_tiny_gpio_group_t* self, tiny_gpio_channel_t channel, bool state);
} i_tiny_gpio_group_api_t;
#define tiny_gpio_group_set_direction(self, channel, direction) \
(self)->api->set_direction((self), (channel), (direction))
#define tiny_gpio_group_read(self, channel) \
(self)->api->read((self), (channel))
#define tiny_gpio_group_write(self, channel, state) \
(self)->api->write((self), (channel), (state))
#endif