diff options
author | Trung N Tran <trung.tran@ettus.com> | 2018-01-09 17:52:48 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-01-12 16:26:03 -0800 |
commit | 5e265ad175658ab6ac784aa298d0e760d8380b68 (patch) | |
tree | 7033c64057a1055102862aa6eca1aa1a2264fc1c /host | |
parent | 00402669d08b206f3b0367f5f4e3383d25e7944b (diff) | |
download | uhd-5e265ad175658ab6ac784aa298d0e760d8380b68.tar.gz uhd-5e265ad175658ab6ac784aa298d0e760d8380b68.tar.bz2 uhd-5e265ad175658ab6ac784aa298d0e760d8380b68.zip |
usrp: add multiusrp api for gain profile.
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/usrp/multi_usrp.hpp | 56 | ||||
-rw-r--r-- | host/lib/usrp/multi_usrp.cpp | 72 |
2 files changed, 128 insertions, 0 deletions
diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index c1fa26cbc..5d47bee84 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -791,6 +791,34 @@ public: */ virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0; + /*! Get a list of possible RX gain profile options + * + * Example: On the TwinRX, this will return "low-noise", "low-distortion" or "default". + * These names can be used in gain-profile related API called. + * An empty return value doesn't mean there are no profile options, it means that + * this radio does not have any gain profiles implemented, and typically means + * there is only one default profile of set gain + * + * \param chan the channel index 0 to N-1 + * \return a vector of strings for possible gain profile options, or an empty list of + * this doesn't apply. + */ + virtual std::vector<std::string> get_rx_gain_profile_names(const size_t chan = 0) = 0; + + /*! + * Set the RX gain profile. + * \param profile the profile string option + * \param chan the channel index 0 to N-1 + */ + virtual void set_rx_gain_profile(const std::string& profile, const size_t chan = 0) = 0; + + /*! + * Get the RX gain profile. + * \param chan the channel index 0 to N-1 + * \return a string of current RX gain profile of corresponding channel. + */ + virtual std::string get_rx_gain_profile(const size_t chan = 0) = 0; + //! A convenience wrapper for setting overall RX gain void set_rx_gain(double gain, size_t chan = 0){ return this->set_rx_gain(gain, ALL_GAINS, chan); @@ -1077,6 +1105,34 @@ public: */ virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0; + /*! Get a list of possible TX gain profile options + * + * Example: On the N310, this will return "manual" or "default". + * These names can be used in gain related API called. + * An empty return value doesn't mean there are no profile options, it means that + * this radio does not have any gain profiles implemented, and typically means + * there is only one default profile of set gain + * + * \param chan the channel index 0 to N-1 + * \return a vector of strings for possible gain profile options, or an empty list of + * this doesn't apply. + */ + virtual std::vector<std::string> get_tx_gain_profile_names(const size_t chan = 0) = 0; + + /*! + * Set the TX gain profile. + * \param profile the profile string option + * \param chan the channel index 0 to N-1 + */ + virtual void set_tx_gain_profile(const std::string& profile, const size_t chan = 0) = 0; + + /*! + * Get the TX gain profile. + * \param chan the channel index 0 to N-1 + * \return a string of current TX gain profile of corresponding channel. + */ + virtual std::string get_tx_gain_profile(const size_t chan = 0) = 0; + //! A convenience wrapper for setting overall TX gain void set_tx_gain(double gain, size_t chan = 0){ return this->set_tx_gain(gain, ALL_GAINS, chan); diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 57f7cc8f6..636940f53 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -1272,6 +1272,42 @@ public: } } + void set_rx_gain_profile(const std::string& profile, const size_t chan){ + if (chan != ALL_CHANS) { + if (_tree->exists(rx_rf_fe_root(chan) / "gains/all/profile/value")) { + _tree->access<std::string>(rx_rf_fe_root(chan) / "gains/all/profile/value").set(profile); + } + } else { + for (size_t c = 0; c < get_rx_num_channels(); c++){ + if (_tree->exists(rx_rf_fe_root(c) / "gains/all/profile/value")) { + _tree->access<std::string>(rx_rf_fe_root(chan) / "gains/all/profile/value").set(profile); + } + } + } + } + + std::string get_rx_gain_profile(const size_t chan){ + if (chan != ALL_CHANS) { + if (_tree->exists(rx_rf_fe_root(chan) / "gains/all/profile/value")) { + return _tree->access<std::string>(rx_rf_fe_root(chan) / "gains/all/profile/value").get(); + } + } else { + UHD_LOG_ERROR("MULTI_USRP", "Can't get rx gain profile from all channels at once. Ignoring this operation") + return ""; + } + } + + std::vector<std::string> get_rx_gain_profile_names(const size_t chan){ + if (chan != ALL_CHANS) { + if (_tree->exists(rx_rf_fe_root(chan) / "gains/all/profile/options")) { + return _tree->access<std::vector<std::string>>(rx_rf_fe_root(chan) / "gains/all/profile/options").get(); + } + } else { + UHD_LOG_ERROR("MULTI_USRP", "Can't get rx gain profile from all channels at once. Ignoring this operation") + return std::vector<std::string>(); + } + } + void set_normalized_rx_gain(double gain, size_t chan = 0) { if (gain > 1.0 || gain < 0.0) { @@ -1631,6 +1667,42 @@ public: } } + void set_tx_gain_profile(const std::string& profile, const size_t chan){ + if (chan != ALL_CHANS) { + if (_tree->exists(tx_rf_fe_root(chan) / "gains/all/profile/value")) { + _tree->access<std::string>(tx_rf_fe_root(chan) / "gains/all/profile/value").set(profile); + } + } else { + for (size_t c = 0; c < get_tx_num_channels(); c++){ + if (_tree->exists(tx_rf_fe_root(c) / "gains/all/profile/value")) { + _tree->access<std::string>(tx_rf_fe_root(chan) / "gains/all/profile/value").set(profile); + } + } + } + } + + std::string get_tx_gain_profile(const size_t chan){ + if (chan != ALL_CHANS) { + if (_tree->exists(tx_rf_fe_root(chan) / "gains/all/profile/value")) { + return _tree->access<std::string>(tx_rf_fe_root(chan) / "gains/all/profile/value").get(); + } + } else { + UHD_LOG_ERROR("MULTI_USRP", "Can't get tx gain profile from all channels at once. Ignoring this operation") + return ""; + } + } + + std::vector<std::string> get_tx_gain_profile_names(const size_t chan){ + if (chan != ALL_CHANS) { + if (_tree->exists(tx_rf_fe_root(chan) / "gains/all/profile/options")) { + return _tree->access<std::vector<std::string>>(tx_rf_fe_root(chan) / "gains/all/profile/options").get(); + } + } else { + UHD_LOG_ERROR("MULTI_USRP", "Can't get tx gain profile from all channels at once. Ignoring this operation") + return std::vector<std::string>(); + } + } + void set_normalized_tx_gain(double gain, size_t chan = 0) { if (gain > 1.0 || gain < 0.0) { |