2 * Copyright (C) 2015 Czech Technical University in Prague
5 * - Michal Sojka <sojkam1@fel.cvut.cz>
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.
19 #include "drv/gio_names.h"
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)
27 * Intialize GIO ports.
29 * The ports are initialized according to the definition in gio_def.h.
31 * @param[in] init_ports Specifies which ports to initialize.
32 * RPP_GIO_PORT_ALL causes all ports to be initialized.
34 * This function is not thread safe. Do not call it from multiple
37 * @return SUCCESS if successful, FAILURE otherwise.
39 int8_t rpp_gio_init(uint32_t init_ports);
42 * Sets GIO output pin to a value.
44 * The function is thread safe.
46 * @param pin Pin to set
47 * @param value Value to the pin to.
49 * @return SUCCESS if successful, FAILURE otherwise.
51 int8_t rpp_gio_set(enum pin_name pin, boolean_t value);
54 * Reads the value of a GIO pin.
56 * The function is thread safe.
58 * @param pin Pin to read.
60 * @return Pin value (0 or 1) in case of success, FAILURE otherwise.
62 int8_t rpp_gio_get(enum pin_name pin);
64 /** GIO pin input mode */
65 enum rpp_gio_in_mode {
66 RPP_GIO_MODE_PULLDIS, /**< Disable pull resistor */
68 RPP_GIO_MODE_PULLDOWN,
71 /** GIO pin direction */
80 * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
82 * @param pin Pin to configure
83 * @param io Configure the pin as input or output.
84 * @param in_mode Input settings. Ignored when pin is configured as
86 * @param open_drain Output is open drain when TRUE, pull/push when
87 * FALSE. Ignored when pin is configured as input.
89 * @return SUCCESS or FAILURE.
91 int8_t rpp_gio_setup(enum pin_name pin,
93 enum rpp_gio_in_mode in_mode,
94 boolean_t open_drain);
96 int8_t rpp_gio_port_set(int port, uint32_t bits);
97 int8_t rpp_gio_port_get(int port, uint32_t *bits);