]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/include/rpp/gio.h
Document rpp/gio.h
[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 /**
27  * Intialize GIO ports.
28  *
29  * The ports are initialized according to the definition in gio_def.h.
30  *
31  * @param[in] init_ports Specifies which ports to initialize.
32  * RPP_GIO_PORT_ALL causes all ports to be initialized.
33  *
34  * @return SUCCESS if successful, FAILURE otherwise.
35  */
36 int8_t rpp_gio_init(uint32_t init_ports);
37
38 /**
39  * Sets GIO output pin to a value.
40  *
41  * @param pin Pin to set
42  * @param value Value to the pin to.
43  *
44  * @return SUCCESS if successful, FAILURE otherwise.
45  */
46 int8_t rpp_gio_set(enum pin_name pin, boolean_t value);
47
48 /**
49  * Reads the value of a GIO pin.
50  *
51  * @param pin Pin to read.
52  *
53  * @return Pin value (0 or 1) in case of success, FAILURE otherwise.
54  */
55 int8_t rpp_gio_get(enum pin_name pin);
56
57 /** GIO pin input mode */
58 enum rpp_gio_in_mode {
59         RPP_GIO_MODE_PULLDIS,       /**< Disable pull resistor */
60         RPP_GIO_MODE_PULLUP,
61         RPP_GIO_MODE_PULLDOWN,
62 };
63
64 /** GIO pin direction */
65 enum rpp_gio_io {
66         RPP_GIO_IN,
67         RPP_GIO_OUT,
68 };
69
70 /**
71  * Configure GIO pin.
72  *
73  * @param pin Pin to configure
74  * @param io Configure the pin as input or output.
75  * @param in_mode Input settings. Ignored when pin is configured as
76  *                output.
77  * @param open_drain Output is open drain when TRUE, pull/push when
78  *                   FALSE. Ignored when pin is configured as input.
79  *
80  * @return SUCCESS or FAILURE.
81  */
82 int8_t rpp_gio_setup(enum pin_name pin,
83                                          enum rpp_gio_io io,
84                                          enum rpp_gio_in_mode in_mode,
85                                          boolean_t open_drain);
86
87 int8_t rpp_gio_port_set(int port, uint32_t bits);
88 int8_t rpp_gio_port_get(int port, uint32_t *bits);
89
90 #endif /* GIO_H_ */