diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-02-23 14:30:40 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-02-27 09:52:19 -0800 |
commit | 594030c1af4af36f5590df58f71606c62d74f033 (patch) | |
tree | b18ccea5e2c211c3c48f4f32d15459b413721f24 /host | |
parent | d52905703af61cfd9854249af7d24cfcd4505c68 (diff) | |
download | uhd-594030c1af4af36f5590df58f71606c62d74f033.tar.gz uhd-594030c1af4af36f5590df58f71606c62d74f033.tar.bz2 uhd-594030c1af4af36f5590df58f71606c62d74f033.zip |
uhd: Move some gpio_defs constants definitions out of headers
Reviewed-by: Trung Tran <trung.tran@ettus.com>
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/usrp/gpio_defs.hpp | 109 | ||||
-rw-r--r-- | host/lib/include/uhdlib/usrp/gpio_defs.hpp | 127 | ||||
-rw-r--r-- | host/lib/usrp/cores/gpio_atr_3000.hpp | 3 | ||||
-rw-r--r-- | host/lib/usrp/multi_usrp.cpp | 1 |
4 files changed, 130 insertions, 110 deletions
diff --git a/host/include/uhd/usrp/gpio_defs.hpp b/host/include/uhd/usrp/gpio_defs.hpp index 18ccc0834..65d6a761e 100644 --- a/host/include/uhd/usrp/gpio_defs.hpp +++ b/host/include/uhd/usrp/gpio_defs.hpp @@ -8,29 +8,7 @@ #ifndef INCLUDED_LIBUHD_USRP_GPIO_DEFS_HPP #define INCLUDED_LIBUHD_USRP_GPIO_DEFS_HPP -#include <uhd/config.hpp> -#include <boost/assign.hpp> -#include <boost/utility.hpp> -#include <map> - namespace uhd { namespace usrp { namespace gpio_atr { - static const std::string GPIO_ATTR_SRC = "SRC"; - //! Attribute name for GPIO control. - static const std::string GPIO_ATTR_CTRL = "CTRL"; - //! Attribute name for GPIO data direction register. - static const std::string GPIO_ATTR_DDR = "DDR"; - //! Attribute name for GPIO ouput value. - static const std::string GPIO_ATTR_OUT = "OUT"; - //! Attribute name for GPIO ATR idle state register. - static const std::string GPIO_ATTR_ATR0X = "ATR_0X"; - //! Attribute name for GPIO ATR receive only register. - static const std::string GPIO_ATTR_ATRRX = "ATR_RX"; - //! Attribute name for GPIO ATR transmit only register. - static const std::string GPIO_ATTR_ATRTX = "ATR_TX"; - //! Attribute name for GPIO ATR full duplex state register. - static const std::string GPIO_ATTR_ATRXX = "ATR_XX"; - //! Attribute name for GPIO READBACK register. - static const std::string GPIO_ATTR_READBACK = "READBACK"; enum gpio_atr_reg_t { ATR_REG_IDLE = int('i'), @@ -39,93 +17,6 @@ namespace uhd { namespace usrp { namespace gpio_atr { ATR_REG_FULL_DUPLEX = int('f') }; - enum gpio_atr_mode_t { - MODE_ATR = 0, //Output driven by the auto-transmit-receive engine - MODE_GPIO = 1 //Output value is static - }; - - enum gpio_ddr_t { - DDR_INPUT = 0, - DDR_OUTPUT = 1 - }; - - enum gpio_attr_t { - GPIO_SRC, - GPIO_CTRL, - GPIO_DDR, - GPIO_OUT, - GPIO_ATR_0X, - GPIO_ATR_RX, - GPIO_ATR_TX, - GPIO_ATR_XX, - GPIO_READBACK - }; - - - typedef std::map<gpio_attr_t, std::string> gpio_attr_map_t; - - static const gpio_attr_map_t gpio_attr_map = { - {GPIO_SRC, GPIO_ATTR_SRC}, - {GPIO_CTRL, GPIO_ATTR_CTRL}, - {GPIO_DDR, GPIO_ATTR_DDR}, - {GPIO_OUT, GPIO_ATTR_OUT}, - {GPIO_ATR_0X, GPIO_ATTR_ATR0X}, - {GPIO_ATR_RX, GPIO_ATTR_ATRRX}, - {GPIO_ATR_TX, GPIO_ATTR_ATRTX}, - {GPIO_ATR_XX, GPIO_ATTR_ATRXX}, - {GPIO_READBACK, GPIO_ATTR_READBACK} - }; - - static const std::map<gpio_attr_t, std::map<uint32_t, std::string>> attr_value_map = { - {GPIO_CTRL, {{0, "ATR"}, {1, "GPIO"}}}, - {GPIO_DDR, {{0, "INPUT"}, {1, "OUTPUT"}}} - }; - static const std::map<std::string, gpio_attr_t> gpio_attr_rev_map ={ - {GPIO_ATTR_SRC, GPIO_SRC}, - {GPIO_ATTR_CTRL, GPIO_CTRL}, - {GPIO_ATTR_DDR, GPIO_DDR}, - {GPIO_ATTR_OUT, GPIO_OUT}, - {GPIO_ATTR_ATR0X, GPIO_ATR_0X}, - {GPIO_ATTR_ATRRX, GPIO_ATR_RX}, - {GPIO_ATTR_ATRTX, GPIO_ATR_TX}, - {GPIO_ATTR_ATRXX, GPIO_ATR_XX}, - { GPIO_ATTR_READBACK, GPIO_READBACK} - }; - - static const gpio_attr_map_t default_attr_value_map ={ - {GPIO_SRC, "RADIO_0/0"}, - {GPIO_CTRL, "GPIO"}, - {GPIO_DDR, "INPUT"} - }; - static const std::map<std::string, uint32_t> gpio_level_map = { - {"HIGH", 1}, - {"LOW", 0}, - {"ON", 1}, - {"OFF", 0}, - {"TRUE", 1}, - {"FALSE", 0} - }; - static const std::map<std::string, uint32_t> gpio_direction = { - {"OUT", 1}, - {"IN", 0}, - {"OUTPUT", 1}, - {"INPUT", 0} - }; - static const std::map<std::string, uint32_t> gpio_ctrl_mode = { - {"ATR", 0}, - {"GPIO", 1} - }; - static const std::map<std::string,std::map<std::string, uint32_t>> gpio_attr_value_pair = { - {GPIO_ATTR_CTRL, gpio_ctrl_mode}, - {GPIO_ATTR_DDR, gpio_direction}, - {GPIO_ATTR_OUT, gpio_level_map}, - {GPIO_ATTR_ATR0X, gpio_level_map}, - {GPIO_ATTR_ATRRX, gpio_level_map}, - {GPIO_ATTR_ATRTX, gpio_level_map}, - {GPIO_ATTR_ATRXX, gpio_level_map}, - {GPIO_ATTR_READBACK, gpio_level_map} - }; - }}} //namespaces #endif /* INCLUDED_LIBUHD_USRP_GPIO_DEFS_HPP */ diff --git a/host/lib/include/uhdlib/usrp/gpio_defs.hpp b/host/lib/include/uhdlib/usrp/gpio_defs.hpp new file mode 100644 index 000000000..b16ea7311 --- /dev/null +++ b/host/lib/include/uhdlib/usrp/gpio_defs.hpp @@ -0,0 +1,127 @@ +// +// Copyright 2018 Ettus Research, a National Instruments Company +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_LIBUHD_USRP_GPIO_DEFS_LIB_HPP +#define INCLUDED_LIBUHD_USRP_GPIO_DEFS_LIB_HPP + +#include <uhd/usrp/gpio_defs.hpp> +#include <map> +#include <string> + +namespace uhd { namespace usrp { namespace gpio_atr { + + enum gpio_atr_mode_t { + MODE_ATR = 0, //Output driven by the auto-transmit-receive engine + MODE_GPIO = 1 //Output value is static + }; + + enum gpio_ddr_t { + DDR_INPUT = 0, + DDR_OUTPUT = 1 + }; + + enum gpio_attr_t { + GPIO_SRC, + GPIO_CTRL, + GPIO_DDR, + GPIO_OUT, + GPIO_ATR_0X, + GPIO_ATR_RX, + GPIO_ATR_TX, + GPIO_ATR_XX, + GPIO_READBACK + }; + + static const std::string GPIO_ATTR_SRC = "SRC"; + //! Attribute name for GPIO control. + static const std::string GPIO_ATTR_CTRL = "CTRL"; + //! Attribute name for GPIO data direction register. + static const std::string GPIO_ATTR_DDR = "DDR"; + //! Attribute name for GPIO ouput value. + static const std::string GPIO_ATTR_OUT = "OUT"; + //! Attribute name for GPIO ATR idle state register. + static const std::string GPIO_ATTR_ATR0X = "ATR_0X"; + //! Attribute name for GPIO ATR receive only register. + static const std::string GPIO_ATTR_ATRRX = "ATR_RX"; + //! Attribute name for GPIO ATR transmit only register. + static const std::string GPIO_ATTR_ATRTX = "ATR_TX"; + //! Attribute name for GPIO ATR full duplex state register. + static const std::string GPIO_ATTR_ATRXX = "ATR_XX"; + //! Attribute name for GPIO READBACK register. + static const std::string GPIO_ATTR_READBACK = "READBACK"; + + typedef std::map<gpio_attr_t, std::string> gpio_attr_map_t; + + static const gpio_attr_map_t gpio_attr_map{ + {GPIO_SRC, GPIO_ATTR_SRC}, + {GPIO_CTRL, GPIO_ATTR_CTRL}, + {GPIO_DDR, GPIO_ATTR_DDR}, + {GPIO_OUT, GPIO_ATTR_OUT}, + {GPIO_ATR_0X, GPIO_ATTR_ATR0X}, + {GPIO_ATR_RX, GPIO_ATTR_ATRRX}, + {GPIO_ATR_TX, GPIO_ATTR_ATRTX}, + {GPIO_ATR_XX, GPIO_ATTR_ATRXX}, + {GPIO_READBACK, GPIO_ATTR_READBACK} + }; + + static const std::map<gpio_attr_t, std::map<uint32_t, std::string>> attr_value_map{ + {GPIO_CTRL, {{0, "ATR"}, {1, "GPIO"}}}, + {GPIO_DDR, {{0, "INPUT"}, {1, "OUTPUT"}}} + }; + + static const std::map<std::string, gpio_attr_t> gpio_attr_rev_map{ + {GPIO_ATTR_SRC, GPIO_SRC}, + {GPIO_ATTR_CTRL, GPIO_CTRL}, + {GPIO_ATTR_DDR, GPIO_DDR}, + {GPIO_ATTR_OUT, GPIO_OUT}, + {GPIO_ATTR_ATR0X, GPIO_ATR_0X}, + {GPIO_ATTR_ATRRX, GPIO_ATR_RX}, + {GPIO_ATTR_ATRTX, GPIO_ATR_TX}, + {GPIO_ATTR_ATRXX, GPIO_ATR_XX}, + {GPIO_ATTR_READBACK, GPIO_READBACK} + }; + + static const gpio_attr_map_t default_attr_value_map{ + {GPIO_SRC, "RADIO_0/0"}, + {GPIO_CTRL, "GPIO"}, + {GPIO_DDR, "INPUT"} + }; + + static const std::map<std::string, uint32_t> gpio_level_map{ + {"HIGH", 1}, + {"LOW", 0}, + {"ON", 1}, + {"OFF", 0}, + {"TRUE", 1}, + {"FALSE", 0} + }; + + static const std::map<std::string, uint32_t> gpio_direction{ + {"OUT", 1}, + {"IN", 0}, + {"OUTPUT", 1}, + {"INPUT", 0} + }; + + static const std::map<std::string, uint32_t> gpio_ctrl_mode{ + {"ATR", 0}, + {"GPIO", 1} + }; + + static const std::map<std::string, std::map<std::string, uint32_t>> gpio_attr_value_pair{ + {GPIO_ATTR_CTRL, uhd::usrp::gpio_atr::gpio_ctrl_mode}, + {GPIO_ATTR_DDR, uhd::usrp::gpio_atr::gpio_direction}, + {GPIO_ATTR_OUT, uhd::usrp::gpio_atr::gpio_level_map}, + {GPIO_ATTR_ATR0X, uhd::usrp::gpio_atr::gpio_level_map}, + {GPIO_ATTR_ATRRX, uhd::usrp::gpio_atr::gpio_level_map}, + {GPIO_ATTR_ATRTX, uhd::usrp::gpio_atr::gpio_level_map}, + {GPIO_ATTR_ATRXX, uhd::usrp::gpio_atr::gpio_level_map}, + {GPIO_ATTR_READBACK, uhd::usrp::gpio_atr::gpio_level_map} + }; + +}}} //namespaces + +#endif /* INCLUDED_LIBUHD_USRP_GPIO_DEFS_LIB_HPP */ diff --git a/host/lib/usrp/cores/gpio_atr_3000.hpp b/host/lib/usrp/cores/gpio_atr_3000.hpp index d9ca24b19..30c7d6fb7 100644 --- a/host/lib/usrp/cores/gpio_atr_3000.hpp +++ b/host/lib/usrp/cores/gpio_atr_3000.hpp @@ -11,8 +11,9 @@ #include <uhd/config.hpp> #include <uhd/usrp/dboard_iface.hpp> #include <uhd/usrp/gpio_defs.hpp> -#include <boost/shared_ptr.hpp> +#include <uhdlib/usrp/gpio_defs.hpp> #include <uhd/types/wb_iface.hpp> +#include <boost/shared_ptr.hpp> namespace uhd { namespace usrp { namespace gpio_atr { diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 593cff4dc..6ff619b55 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -17,6 +17,7 @@ #include <uhd/usrp/dboard_eeprom.hpp> #include <uhd/convert.hpp> #include <uhd/utils/soft_register.hpp> +#include <uhdlib/usrp/gpio_defs.hpp> #include "legacy_compat.hpp" #include <boost/assign/list_of.hpp> #include <boost/thread.hpp> |