/*
- * 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 "hal/hal.h"
+#include "types.h"
+#include "drv/gio_names.h"
#define RPP_GIO_PORT_GIOA 0x2
#define RPP_GIO_PORT_GIOB 0x4
int8_t rpp_gio_init(uint32_t init_ports);
+int8_t rpp_gio_set(enum pin_name pin, boolean_t value);
+int8_t rpp_gio_get(enum pin_name pin);
+
+/** 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_port_set(int port, uint32_t bits);
+int8_t rpp_gio_port_get(int port, uint32_t *bits);
+
#endif /* GIO_H_ */