]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blobdiff - rpp/include/rpp/gio.h
Uncrustify
[pes-rpp/rpp-lib.git] / rpp / include / rpp / gio.h
index e29ab65382eb9de8fde252dea320202dea4de491..a5edd60acc0232a9f1088d9b4fe4751bd34dfd64 100644 (file)
@@ -1,20 +1,64 @@
 /*
- * gio.h
+ * Copyright (C) 2015 Czech Technical University in Prague
+ *
+ * Authors:
+ *     - Michal Sojka <sojkam1@fel.cvut.cz>
+ *     - Michal Horn
+ *
+ * This document contains proprietary information belonging to Czech
+ * Technical University in Prague. Passing on and copying of this
+ * document, and communication of its contents is not permitted
+ * without prior written authorization.
  *
- *  Created on: 29.10.2014
- *      Author: Michal Horn
  */
 
-#ifndef GIO_H_
-#define GIO_H_
+#ifndef RPP_GIO_H
+#define RPP_GIO_H
+
+#include "types.h"
+#include "drv/gio_names.h"
+
+#define RPP_GIO_PORT_GIOA   0x2
+#define RPP_GIO_PORT_GIOB   0x4
+#define RPP_GIO_PORT_NHET1  0x8
+#define RPP_GIO_PORT_ALL    (RPP_GIO_PORT_GIOA|RPP_GIO_PORT_GIOB|RPP_GIO_PORT_NHET1)
+
+int8_t rpp_gio_init(uint32_t init_ports);
 
-#include "hal/hal.h"
+int8_t rpp_gio_set(enum pin_name pin, boolean_t value);
+int8_t rpp_gio_get(enum pin_name pin);
 
-#define RPP_GIO_PORT_GIOA   0x1
-#define RPP_GIO_PORT_GIOB   0x2
-#define RPP_GIO_PORT_NHET1  0x4
-#define RPP_GIO_PORT_ALL    0xFFFFFFFF
+/** GIO pin input mode */
+enum rpp_gio_in_mode {
+       RPP_GIO_MODE_PULLDIS,       /**< Disable pull resistor */
+       RPP_GIO_MODE_PULLUP,
+       RPP_GIO_MODE_PULLDOWN,
+};
+
+/** GIO pin direction */
+enum rpp_gio_io {
+       RPP_GIO_IN,
+       RPP_GIO_OUT,
+};
+
+/**
+ * Configure GIO pin
+ *
+ * @param pin Pin to configure
+ * @param io Configure the pin as input or output.
+ * @param in_mode Input settings. Ignored when pin is configured as
+ *                output.
+ * @param open_drain Output is open drain when TRUE, pull/push when
+ *                   FALSE. Ignored when pin is configured as input.
+ *
+ * @return SUCCESS or FAILURE.
+ */
+int8_t rpp_gio_setup(enum pin_name pin,
+                                        enum rpp_gio_io io,
+                                        enum rpp_gio_in_mode in_mode,
+                                        boolean_t open_drain);
 
-int8_t rpp_gio_init(uint32_t ports);
+int8_t rpp_gio_port_set(int port, uint32_t bits);
+int8_t rpp_gio_port_get(int port, uint32_t *bits);
 
 #endif /* GIO_H_ */