diff options
Diffstat (limited to 'host/lib/include/uhdlib')
-rw-r--r-- | host/lib/include/uhdlib/rfnoc/rf_control/antenna_iface.hpp | 102 | ||||
-rw-r--r-- | host/lib/include/uhdlib/usrp/dboard/zbx/zbx_dboard.hpp | 18 |
2 files changed, 106 insertions, 14 deletions
diff --git a/host/lib/include/uhdlib/rfnoc/rf_control/antenna_iface.hpp b/host/lib/include/uhdlib/rfnoc/rf_control/antenna_iface.hpp new file mode 100644 index 000000000..bd36fc869 --- /dev/null +++ b/host/lib/include/uhdlib/rfnoc/rf_control/antenna_iface.hpp @@ -0,0 +1,102 @@ +// +// Copyright 2021 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#pragma once + +#include <uhd/property_tree.hpp> +#include <uhd/rfnoc/rf_control/core_iface.hpp> +#include <unordered_map> +#include <functional> +#include <memory> +#include <string> +#include <vector> + +namespace uhd { namespace rfnoc { namespace rf_control { + +/*! Interface for setting and getting the current antenna. + */ +class antenna_iface +{ +public: + using sptr = std::shared_ptr<antenna_iface>; + + virtual ~antenna_iface() = default; + + /*! Return a list of valid antenna for channel \p chan. + * + * \return The selected antenna. + */ + virtual std::vector<std::string> get_antennas(const size_t chan) const = 0; + + /*! Select antenna \p for channel \p chan. + * + * \throws uhd::value_error if \p ant is not a valid value. + */ + virtual void set_antenna(const std::string& ant, const size_t chan) = 0; + + /*! Return the selected antenna for channel \p chan. + * + * \return The selected antenna. + */ + virtual std::string get_antenna(const size_t chan) const = 0; +}; + +/*! Class for getting and setting antennas out of an enumerated set, where + * the API calls for the antenna actually map to property nodes. + */ +class enumerated_antenna : public antenna_iface +{ +public: + using prop_path = std::function<fs_path(const size_t chan)>; + + /*! Constructs an enumerated_antenna class. + * + * \param tree The property tree the nodes are on + * \param prop_path_generator Closure to generate the property path given the channel. + * \param possible_antennas A vector of legal antennas. + * \param compat_map A map of alternative names for antennas. + */ + enumerated_antenna(uhd::property_tree::sptr tree, + prop_path prop_path_generator, + const std::vector<std::string>& possible_antennas, + const std::unordered_map<std::string, std::string>& compat_map); + + virtual ~enumerated_antenna() = default; + + std::vector<std::string> get_antennas(const size_t chan) const override; + void set_antenna(const std::string& ant, const size_t chan) override; + std::string get_antenna(const size_t chan) const override; + +private: + // The property tree & node used to implement the API + uhd::property_tree::sptr _tree; + prop_path _prop_path_generator; + + std::vector<std::string> _possible_antennas; + const std::unordered_map<std::string, std::string>& _compat_map; +}; + +/*! Partially implements core_iface for antenna, redirecting to one of two + * subobjects for RX or TX. + */ +class antenna_radio_control_mixin : virtual public core_iface +{ +public: + virtual ~antenna_radio_control_mixin() = default; + + std::string get_tx_antenna(const size_t chan) const override; + std::vector<std::string> get_tx_antennas(const size_t chan) const override; + void set_tx_antenna(const std::string& ant, const size_t chan) override; + std::string get_rx_antenna(const size_t chan) const override; + std::vector<std::string> get_rx_antennas(const size_t chan) const override; + void set_rx_antenna(const std::string& ant, const size_t chan) override; + +protected: + antenna_iface::sptr _rx_antenna; + antenna_iface::sptr _tx_antenna; +}; + +}}} // namespace uhd::rfnoc::rf_control diff --git a/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_dboard.hpp b/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_dboard.hpp index 0a52d7bdf..6e1d31381 100644 --- a/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_dboard.hpp +++ b/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_dboard.hpp @@ -21,6 +21,7 @@ #include <uhd/types/wb_iface.hpp> #include <uhdlib/experts/expert_factory.hpp> #include <uhdlib/rfnoc/rf_control/dboard_iface.hpp> +#include <uhdlib/rfnoc/rf_control/antenna_iface.hpp> #include <uhdlib/usrp/common/mpmd_mb_controller.hpp> #include <uhdlib/usrp/common/pwr_cal_mgr.hpp> #include <uhdlib/usrp/common/rpc.hpp> @@ -40,7 +41,9 @@ const static uint16_t ZBX_PID = 0x4002; /*! Provide access to a ZBX radio. */ -class zbx_dboard_impl : public uhd::usrp::x400::x400_dboard_iface +class zbx_dboard_impl : + public uhd::usrp::x400::x400_dboard_iface, + public uhd::rfnoc::rf_control::antenna_radio_control_mixin { public: using sptr = std::shared_ptr<zbx_dboard_impl>; @@ -109,17 +112,6 @@ public: return _rx_gain_profile_api; } - void set_tx_antenna(const std::string& ant, const size_t chan) override; - void set_rx_antenna(const std::string& ant, const size_t chan) override; - std::vector<std::string> get_tx_antennas(const size_t /*chan*/) const override - { - return TX_ANTENNAS; - } - std::vector<std::string> get_rx_antennas(const size_t /*chan*/) const override - { - return RX_ANTENNAS; - } - double set_tx_frequency(const double freq, const size_t chan) override; double set_rx_frequency(const double freq, const size_t chan) override; uhd::freq_range_t get_tx_frequency_range(const size_t /*chan*/) const override @@ -239,8 +231,6 @@ public: * Radio Identification API Calls *************************************************************************/ - std::string get_tx_antenna(size_t chan) const override; - std::string get_rx_antenna(size_t chan) const override; double get_tx_frequency(size_t chan) override; double get_rx_frequency(size_t chan) override; double get_rx_bandwidth(size_t chan) override; |