]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/commitdiff
Add RPP interface for Digital IO
authorMichal Horn <hornmich@fel.cvut.cz>
Tue, 21 Jul 2015 13:08:45 +0000 (15:08 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 2 Aug 2015 18:26:36 +0000 (20:26 +0200)
18 files changed:
rpp/include/drv/.gitattributes
rpp/include/drv/_rm48_hdk/.gitattributes
rpp/include/drv/_rm48_hdk/digital_io_def.h
rpp/include/drv/_tms570_hdk/.gitattributes
rpp/include/drv/_tms570_hdk/digital_io_def.h
rpp/include/drv/_tms570_hydctr/.gitattributes
rpp/include/drv/_tms570_hydctr/digital_io_def.h
rpp/include/drv/_tms570_rpp/digital_io_def.h
rpp/include/drv/digital_io.h
rpp/include/drv/digital_io_def.h [new file with mode: 0644]
rpp/include/hal/.gitattributes [deleted file]
rpp/include/rpp/gio.h
rpp/src/drv/.gitattributes
rpp/src/drv/_rm48_hdk/.gitattributes
rpp/src/drv/_tms570_hdk/.gitattributes
rpp/src/drv/_tms570_hydctr/.gitattributes
rpp/src/hal/.gitattributes
rpp/src/rpp/gio.c

index fa29f1518dedcf48d8c9a0c29ca1c0277a6e9ec9..3ee21ef18d9caa6a901a5edd8ce65b4eddc7c5bc 100644 (file)
@@ -2,3 +2,5 @@
 /Std_Types.h   eaton
 /drv.h eaton
 /sci.h eaton
+/digital_io_def.h      eaton
+/digital_io.h  eaton
\ No newline at end of file
index 7ba1a6c388453bca9e88f4fa6e3fc7e67b4d0b49..7f75ca036f16ae8ede06470a084e1a22d39f1970 100644 (file)
@@ -1 +1,2 @@
 /adc.h eaton
+/digital_io_def.h      eaton
\ No newline at end of file
index 15ed8934e8362bd6f33d0df397741e11136c625e..5409fbcc21c41f77415997075842e25870b71d16 100644 (file)
@@ -7,8 +7,8 @@
  * @author Michal Horn <hornmich@fel.cvut.cz>
  */
 
-#ifndef DIGITAL_IO_DEF_H_
-#define DIGITAL_IO_DEF_H_
+#ifndef TG_DIGITAL_IO_DEF_H_
+#define TG_DIGITAL_IO_DEF_H_
 
 #define DIO_MAX_PIN_CNT     46
 #define DIO_MAX_PORT_CNT    5
@@ -73,4 +73,4 @@
 #define DIO_PORT_NAME_GIOB          "GIOB"
 #define DIO_PORT_NAME_NHET1         "NHET1"
 #define DIO_PORT_NAME_ADC           "ADC"
-#endif /* DIGITAL_IO_DEF_H_ */
+#endif /* TG_DIGITAL_IO_DEF_H_ */
index 7ba1a6c388453bca9e88f4fa6e3fc7e67b4d0b49..7f75ca036f16ae8ede06470a084e1a22d39f1970 100644 (file)
@@ -1 +1,2 @@
 /adc.h eaton
+/digital_io_def.h      eaton
\ No newline at end of file
index c24bf793a4a81362a1dda057121bcff8840da472..5b1a3e394ffef192e43d09c7c51431ed1583d440 100644 (file)
@@ -7,8 +7,8 @@
  * @author Michal Horn <hornmich@fel.cvut.cz>
  */
 
-#ifndef DIGITAL_IO_DEF_H_
-#define DIGITAL_IO_DEF_H_
+#ifndef TG_DIGITAL_IO_DEF_H_
+#define TG_DIGITAL_IO_DEF_H_
 
 #define DIO_MAX_PIN_CNT     46
 #define DIO_MAX_PORT_CNT    5
@@ -74,4 +74,4 @@
 #define DIO_PORT_NAME_NHET1         "NHET1"
 #define DIO_PORT_NAME_ADC           "ADC"
 
-#endif /* DIGITAL_IO_DEF_H_ */
+#endif /* TG_DIGITAL_IO_DEF_H_ */
index 7ba1a6c388453bca9e88f4fa6e3fc7e67b4d0b49..7f75ca036f16ae8ede06470a084e1a22d39f1970 100644 (file)
@@ -1 +1,2 @@
 /adc.h eaton
+/digital_io_def.h      eaton
\ No newline at end of file
index c24bf793a4a81362a1dda057121bcff8840da472..5b1a3e394ffef192e43d09c7c51431ed1583d440 100644 (file)
@@ -7,8 +7,8 @@
  * @author Michal Horn <hornmich@fel.cvut.cz>
  */
 
-#ifndef DIGITAL_IO_DEF_H_
-#define DIGITAL_IO_DEF_H_
+#ifndef TG_DIGITAL_IO_DEF_H_
+#define TG_DIGITAL_IO_DEF_H_
 
 #define DIO_MAX_PIN_CNT     46
 #define DIO_MAX_PORT_CNT    5
@@ -74,4 +74,4 @@
 #define DIO_PORT_NAME_NHET1         "NHET1"
 #define DIO_PORT_NAME_ADC           "ADC"
 
-#endif /* DIGITAL_IO_DEF_H_ */
+#endif /* TG_DIGITAL_IO_DEF_H_ */
index f009d774a89fa6e0f6bcec00dea76d2b1ac06e71..32e6dbd92f9e4cf25764e3ba6888fcbd4f9f1551 100644 (file)
@@ -7,8 +7,8 @@
  * @author Michal Horn <hornmich@fel.cvut.cz>
  */
 
-#ifndef DIGITAL_IO_DEF_H_
-#define DIGITAL_IO_DEF_H_
+#ifndef TG_DIGITAL_IO_DEF_H_
+#define TG_DIGITAL_IO_DEF_H_
 
 #define DIO_MAX_PIN_CNT     103
 #define DIO_MAX_PORT_CNT       5
@@ -82,4 +82,4 @@
 #define DIO_PORT_NAME_MOUTEN        "MOUTEN"
 #define DIO_PORT_NAME_MOUTIN        "MOUTIN"
 
-#endif /* DIGITAL_IO_DEF_H_ */
+#endif /* TG_DIGITAL_IO_DEF_H_ */
index f3758b2e9da84ac8938c517432d51fd6b256c185..7a03bef1a455fafe954943ca81c3c5f8b62be177 100644 (file)
 #define __HAL_H
 
 #include "sys/sys.h"
-
-#if defined(TARGET_POSIX)
-#include "drv/_rm48_hdk/digital_io_def.h"
-#elif defined(TARGET_RM48_HDK)
-#include "drv/_rm48_hdk/digital_io_def.h"
-#elif defined(TARGET_TMS570_HDK)
-#include "drv/_tms570_hdk/digital_io_def.h"
-#elif defined(TARGET_TMS570_HYDCTR)
-#include "drv/_tms570_hydctr/digital_io_def.h"
-#elif defined(TARGET_TMS570_RPP)
-#include "drv/_tms570_rpp/digital_io_def.h"
-#else
-#error No supported target specified!
-#endif
+#include "drv/digital_io_def.h"
 
 typedef struct dio_pin_map_element {
        const char *pin_name;          // Pin name
diff --git a/rpp/include/drv/digital_io_def.h b/rpp/include/drv/digital_io_def.h
new file mode 100644 (file)
index 0000000..77aa469
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * digital_io_def.h
+ *
+ *  Created on: 20.7.2015
+ *      Author: michal
+ */
+
+#ifndef DIGITAL_IO_DEF_H_
+#define DIGITAL_IO_DEF_H_
+
+#if defined(TARGET_POSIX)
+#include "drv/_rm48_hdk/digital_io_def.h"
+#elif defined(TARGET_RM48_HDK)
+#include "drv/_rm48_hdk/digital_io_def.h"
+#elif defined(TARGET_TMS570_HDK)
+#include "drv/_tms570_hdk/digital_io_def.h"
+#elif defined(TARGET_TMS570_HYDCTR)
+#include "drv/_tms570_hydctr/digital_io_def.h"
+#elif defined(TARGET_TMS570_RPP)
+#include "drv/_tms570_rpp/digital_io_def.h"
+#else
+#error No supported target specified!
+#endif
+
+#endif /* DIGITAL_IO_DEF_H_ */
diff --git a/rpp/include/hal/.gitattributes b/rpp/include/hal/.gitattributes
deleted file mode 100644 (file)
index 7407c7d..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/gpio.h        eaton
-/hal.h eaton
-/port_gpio.h   eaton
index b2fc6a77013701d5a39cb95e80fbde4d0c4960bf..83a89ba20c9f1fd359712d8ce857c783b1dc5567 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef GIO_H_
 #define GIO_H_
 
-#include "drv/digital_io.h"
+#include "types.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_val(const char* pin_name, uint8_t value);
+
+int8_t rpp_gio_get_val(const char* pin_name);
+
+int8_t rpp_gio_set_output(const char* pin_name, uint8_t value);
+
+int8_t rpp_gio_set_input(const char* pin_name);
+
+int8_t rpp_gio_set_push_pull(const char* pin_name, boolean_t pull_up);
+
+int8_t rpp_gio_set_open_drain(const char* pin_name);
+
+int8_t rpp_gio_set_pull_up(const char* pin_name);
+
+int8_t rpp_gio_set_pull_down(const char* pin_name);
+
+boolean_t rpp_gio_is_dir_output(const char* pin_name);
+
+boolean_t rpp_gio_is_push_pull(const char* pin_name);
+
+boolean_t rpp_gio_is_pull_up(const char* pin_name);
+
+uint32_t rpp_gio_get_pin_cnt();
+
+int8_t rpp_gio_get_pin_names(const char** pin_names, uint8_t max_names_cnt);
+
+int8_t rpp_port_set_val(const char* port_name, uint8_t port_num_vals, const uint32_t* values);
+
+int8_t rpp_port_get_val(const char* port_name, uint8_t port_num_vals, uint32_t* values);
+
+int32_t rpp_port_get_pin_cnt(const char* port_name);
+
+int32_t rpp_port_get_port_cnt();
+
+int8_t rpp_port_get_port_names(const char** port_names, uint8_t max_names_cnt);
+
+int8_t rpp_port_get_interface_type(const char* port_name);
+
+
 #endif /* GIO_H_ */
index 4e0b56a87c7711732649ea4fcdc65ac426c48d1d..63afd403bb5e68759a866af1e51d6573bb34772e 100644 (file)
@@ -1 +1,2 @@
 /sci.c eaton
+/digital_io.c  eaton
\ No newline at end of file
index 744c6a512aef56daf028d9e7b68f74be0cf846bf..b745d88ea31ec6e75e812c201b2ac855fdff8752 100644 (file)
@@ -1 +1,2 @@
 /adc.c eaton
+/digital_io_def.c      eaton
index 744c6a512aef56daf028d9e7b68f74be0cf846bf..16709abd1dbd84d2b01dab24fa87f564c8df939f 100644 (file)
@@ -1 +1,2 @@
 /adc.c eaton
+/digital_io_def.c      eaton
\ No newline at end of file
index 744c6a512aef56daf028d9e7b68f74be0cf846bf..16709abd1dbd84d2b01dab24fa87f564c8df939f 100644 (file)
@@ -1 +1,2 @@
 /adc.c eaton
+/digital_io_def.c      eaton
\ No newline at end of file
index 00388113b111e5f21632b1f1605a51d4b58b0515..0e89bec0ed2258f5dcbbc0479df6cd7aa7fa43f1 100644 (file)
@@ -1,3 +1 @@
-/gpio.c        eaton
 /pom_vect_remap.c      eaton
-/port_gpio.c   eaton
index 37d8cdbf8ac5b3710f45c9bc8f610664a11c48be..2d2b47323d81565eb50d3a6b2e78521db60c976b 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include "rpp/gio.h"
+#include "drv/digital_io.h"
 
 static uint32_t ports_initialized = 0;
 
@@ -39,3 +40,273 @@ int8_t rpp_gio_init(uint32_t init_ports)
 
        return SUCCESS;
 }
+
+int8_t rpp_gio_set_val(const char* pin_name, uint8_t value) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+       uint32_t* pin_dsc = dio_gpio_pin_get_dsc(pin_name, -1);
+       if (pin_dsc == NULL) {
+               return FAILURE;
+       }
+
+       dio_gpio_pin_set_value(*pin_dsc, value);
+       return SUCCESS;
+}
+
+int8_t rpp_gio_get_val(const char* pin_name) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+
+       uint32_t* pin_dsc = dio_gpio_pin_get_dsc(pin_name, -1);
+       if (pin_dsc == NULL) {
+               return FAILURE;
+       }
+
+       return dio_gpio_pin_get_value(*pin_dsc);
+}
+
+int8_t rpp_gio_set_output(const char* pin_name, uint8_t value) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+
+       uint32_t* pin_dsc = dio_gpio_pin_get_dsc(pin_name, -1);
+       if (pin_dsc == NULL) {
+               return FAILURE;
+       }
+
+       dio_gpio_pin_set_dir_out(*pin_dsc, value);
+
+       return SUCCESS;
+}
+
+int8_t rpp_gio_set_input(const char* pin_name) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+
+       uint32_t* pin_dsc = dio_gpio_pin_get_dsc(pin_name, -1);
+       if (pin_dsc == NULL) {
+               return FAILURE;
+       }
+
+       dio_gpio_pin_set_dir_in(*pin_dsc);
+
+       return SUCCESS;
+}
+
+int8_t rpp_gio_set_push_pull(const char* pin_name, boolean_t pull_up) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+
+       uint32_t* pin_dsc = dio_gpio_pin_get_dsc(pin_name, -1);
+       if (pin_dsc == NULL) {
+               return FAILURE;
+       }
+
+       dio_gpio_pin_set_od(*pin_dsc, DIO_PORT_CONF_OD_OFF);
+       if (pull_up) {
+               dio_gpio_pin_set_mode(*pin_dsc, DIO_PORT_CONF_MODE_PU|DIO_PORT_CONF_MODE_PEN);
+       }
+       else {
+               dio_gpio_pin_set_mode(*pin_dsc, DIO_PORT_CONF_MODE_PD|DIO_PORT_CONF_MODE_PEN);
+       }
+
+       dio_gpio_pin_set_dir_in(*pin_dsc);
+
+       return SUCCESS;
+}
+
+int8_t rpp_gio_set_open_drain(const char* pin_name) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+
+       uint32_t* pin_dsc = dio_gpio_pin_get_dsc(pin_name, -1);
+       if (pin_dsc == NULL) {
+               return FAILURE;
+       }
+
+       dio_gpio_pin_set_od(*pin_dsc, DIO_PORT_CONF_OD_ON);
+       dio_gpio_pin_set_mode(*pin_dsc, DIO_PORT_CONF_MODE_PU|DIO_PORT_CONF_MODE_PDIS);
+
+       dio_gpio_pin_set_dir_in(*pin_dsc);
+
+       return SUCCESS;
+}
+
+int8_t rpp_gio_set_pull_up(const char* pin_name) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+
+       uint32_t* pin_dsc = dio_gpio_pin_get_dsc(pin_name, -1);
+       if (pin_dsc == NULL) {
+               return FAILURE;
+       }
+
+       dio_gpio_pin_set_mode(*pin_dsc, DIO_PORT_CONF_MODE_PU|DIO_PORT_CONF_MODE_PEN);
+
+       return SUCCESS;
+}
+
+int8_t rpp_gio_set_pull_down(const char* pin_name) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+
+       uint32_t* pin_dsc = dio_gpio_pin_get_dsc(pin_name, -1);
+       if (pin_dsc == NULL) {
+               return FAILURE;
+       }
+
+       dio_gpio_pin_set_mode(*pin_dsc, DIO_PORT_CONF_MODE_PD|DIO_PORT_CONF_MODE_PEN);
+
+       return SUCCESS;
+}
+
+boolean_t rpp_gio_is_dir_output(const char* pin_name) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+
+       uint32_t* pin_dsc = dio_gpio_pin_get_dsc(pin_name, -1);
+       if (pin_dsc == NULL) {
+               return FAILURE;
+       }
+
+       int dir = dio_gpio_pin_get_dir(*pin_dsc);
+       return (dir == 1) ? TRUE : FALSE;
+}
+
+boolean_t rpp_gio_is_push_pull(const char* pin_name) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+
+       uint32_t* pin_dsc = dio_gpio_pin_get_dsc(pin_name, -1);
+       if (pin_dsc == NULL) {
+               return FAILURE;
+       }
+       return !(dio_gpio_pin_get_port_base(*pin_dsc)->PULDIS >> ((*pin_dsc & 0x1f) & 1));
+}
+
+boolean_t rpp_gio_is_pull_up(const char* pin_name) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+
+       uint32_t* pin_dsc = dio_gpio_pin_get_dsc(pin_name, -1);
+       if (pin_dsc == NULL) {
+               return FAILURE;
+       }
+       return dio_gpio_pin_get_port_base(*pin_dsc)->PSL >> ((*pin_dsc & 0x1f) & 1);
+}
+
+uint32_t rpp_gio_get_pin_cnt() {
+       return dio_gpio_get_pin_cnt();
+}
+
+int8_t rpp_gio_get_pin_names(const char** pin_names, uint8_t max_names_cnt) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+       if (pin_names == NULL) {
+               return FAILURE;
+       }
+
+       dio_pin_map_element_t* pin_map = dio_gpio_get_pin_map();
+       uint32_t pin_cnt = dio_gpio_get_pin_cnt();
+
+       uint32_t i;
+       for (i = 0; i < pin_cnt && i < max_names_cnt; i++) {
+               pin_names[i] = pin_map[i].pin_name;
+       }
+
+       return i;
+}
+
+int8_t rpp_port_set_val(const char* port_name, uint8_t port_num_vals, const uint32_t* values) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+       if (port_name == NULL || values == NULL) {
+               return FAILURE;
+       }
+       const dio_port_desc_t* port = dio_port_get_dsc(port_name, -1);
+       if (port != NULL && dio_port_get_val_cnt(port) != port_num_vals) {
+               return FAILURE;
+       }
+
+       dio_gpio_port_set_val(port->config, port_num_vals, values);
+       return SUCCESS;
+}
+
+int8_t rpp_port_get_val(const char* port_name, uint8_t port_num_vals, uint32_t* values) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+       if (port_name == NULL || values == NULL) {
+               return FAILURE;
+       }
+       dio_port_desc_t* port = dio_port_get_dsc(port_name, -1);
+       if (port != NULL && dio_port_get_val_cnt(port) != port_num_vals) {
+               return FAILURE;
+       }
+
+       dio_gpio_port_get_val(port->config, port_num_vals, values);
+       return SUCCESS;
+}
+
+int32_t rpp_port_get_pin_cnt(const char* port_name) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+       if (port_name == NULL) {
+               return FAILURE;
+       }
+       return dio_port_get_val_cnt(dio_port_get_dsc(port_name, -1));
+}
+
+int32_t rpp_port_get_port_cnt() {
+       return DIO_PORT_CNT;
+}
+
+int8_t rpp_port_get_port_names(const char** port_names, uint8_t max_names_cnt) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+       if (port_names == NULL) {
+               return FAILURE;
+       }
+
+       const dio_port_def_t* port_map = dio_port_get_map();
+
+       uint32_t port_cnt = DIO_PORT_CNT;
+       uint32_t i;
+       for (i = 0; i < port_cnt && i < max_names_cnt; i++) {
+               port_names[i] = port_map[i].name;
+       }
+
+       return i;
+}
+
+int8_t rpp_port_get_interface_type(const char* port_name) {
+       if (ports_initialized == 0) {
+               return FAILURE;
+       }
+       if (port_name == NULL) {
+               return FAILURE;
+       }
+
+       dio_port_desc_t* port = dio_port_get_dsc(port_name, -1);
+       if (port == NULL) {
+               return FAILURE;
+       }
+
+       return port->interfaceType;
+}
+