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
51
52
53
54
55
56
57
58
59
60
61
| /*
| * eLesson Project
| * Copyright (c) 2023, EventOS Team, <event-os@outlook.com>
| */
|
| #ifndef EMS_PIN_H
| #define EMS_PIN_H
|
| /* includes ----------------------------------------------------------------- */
| #include "eio_object.h"
|
| #ifdef __cplusplus
| extern "C" {
| #endif
|
| enum pin_mode
| {
| PIN_MODE_INPUT = 0,
| PIN_MODE_INPUT_PULLUP,
| PIN_MODE_INPUT_PULLDOWN,
| PIN_MODE_OUTPUT_PP,
| PIN_MODE_OUTPUT_OD,
|
| PIN_MODE_MAX
| };
|
|
| typedef struct eio_pin
| {
| eio_object_t super;
|
| const struct ems_pin_ops *ops;
| uint8_t mode;
| bool status;
| } ems_pin_t;
|
| typedef struct ems_pin_ops
| {
| void (* init)(ems_pin_t * const me);
| void (* set_mode)(ems_pin_t * const me, uint8_t mode);
| bool (* get_status)(ems_pin_t * const me);
| void (* set_status)(ems_pin_t * const me, bool status);
| } ems_pin_ops_t;
|
|
| void ems_pin_register(ems_pin_t * const me,
| const char *name,
| const ems_pin_ops_t *ops,
| void *user_data);
|
| void ems_pin_set_mode(eio_object_t * const me, uint8_t mode);
| bool ems_pin_get_status(eio_object_t * const me);
| void ems_pin_set_status(eio_object_t * const me, bool status);
|
| #ifdef __cplusplus
| }
| #endif
|
| #endif
|
| /* ----------------------------- end of file -------------------------------- */
|
|