]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/include/rpp/gio.h
Update rpp/gio.* to the new drv/gio interface and remove crap from it
[pes-rpp/rpp-lib.git] / rpp / include / rpp / gio.h
1 /*
2  * Copyright (C) 2015 Czech Technical University in Prague
3  *
4  * Authors:
5  *     - Michal Sojka <sojkam1@fel.cvut.cz>
6  *     - Michal Horn
7  *
8  * This document contains proprietary information belonging to Czech
9  * Technical University in Prague. Passing on and copying of this
10  * document, and communication of its contents is not permitted
11  * without prior written authorization.
12  *
13  */
14
15 #ifndef RPP_GIO_H
16 #define RPP_GIO_H
17
18 #include "types.h"
19 #include "drv/gio_names.h"
20
21 #define RPP_GIO_PORT_GIOA   0x2
22 #define RPP_GIO_PORT_GIOB   0x4
23 #define RPP_GIO_PORT_NHET1  0x8
24 #define RPP_GIO_PORT_ALL    (RPP_GIO_PORT_GIOA|RPP_GIO_PORT_GIOB|RPP_GIO_PORT_NHET1)
25
26 int8_t rpp_gio_init(uint32_t init_ports);
27
28 int8_t rpp_gio_set(enum pin_name pin, boolean_t value);
29 int8_t rpp_gio_get(enum pin_name pin);
30
31 /** GIO pin input mode */
32 enum rpp_gio_in_mode {
33         RPP_GIO_MODE_PULLDIS,           /**< Disable pull resistor */
34         RPP_GIO_MODE_PULLUP,
35         RPP_GIO_MODE_PULLDOWN,
36 };
37
38 /** GIO pin direction */
39 enum rpp_gio_io {
40         RPP_GIO_IN,
41         RPP_GIO_OUT,
42 };
43
44 /**
45  * Configure GIO pin
46  *
47  * @param pin Pin to configure
48  * @param io Configure the pin as input or output.
49  * @param in_mode Input settings. Ignored when pin is configured as
50  *                                output.
51  * @param open_drain Output is open drain when TRUE, pull/push when
52  *                                       FALSE. Ignored when pin is configured as input.
53  *
54  * @return SUCCESS or FAILURE.
55  */
56 int8_t rpp_gio_setup(enum pin_name pin,
57                                          enum rpp_gio_io io,
58                                          enum rpp_gio_in_mode in_mode,
59                                          boolean_t open_drain);
60
61 int8_t rpp_gio_port_set(int port, uint32_t bits);
62 int8_t rpp_gio_port_get(int port, uint32_t *bits);
63
64 #endif /* GIO_H_ */