aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/dboard
diff options
context:
space:
mode:
authorLane Kolbly <lane.kolbly@ni.com>2020-06-18 17:46:06 -0500
committerAaron Rossetto <aaron.rossetto@ni.com>2021-01-11 12:26:00 -0600
commit12673d9290319d2453fedd806ddf248d3d5586e3 (patch)
tree811016297552c5358129aecb5953a0c143229e86 /host/lib/usrp/dboard
parentc9b35e3b7107ab82c0e3978b7cbfd76ba98e2407 (diff)
downloaduhd-12673d9290319d2453fedd806ddf248d3d5586e3.tar.gz
uhd-12673d9290319d2453fedd806ddf248d3d5586e3.tar.bz2
uhd-12673d9290319d2453fedd806ddf248d3d5586e3.zip
uhd: Split radio_control into rf_control interfaces
These rf_control interfaces allow easier implementation of radio controls as well as allowing easier sharing of code for implementing e.g. gain_profile.
Diffstat (limited to 'host/lib/usrp/dboard')
-rw-r--r--host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp48
-rw-r--r--host/lib/usrp/dboard/magnesium/magnesium_radio_control.hpp9
-rw-r--r--host/lib/usrp/dboard/magnesium/magnesium_radio_control_gain.cpp2
-rw-r--r--host/lib/usrp/dboard/magnesium/magnesium_radio_control_init.cpp4
4 files changed, 7 insertions, 56 deletions
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp
index 5eb0f63a5..879885640 100644
--- a/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp
+++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp
@@ -103,6 +103,10 @@ magnesium_radio_control_impl::magnesium_radio_control_impl(make_args_ptr make_ar
{
RFNOC_LOG_TRACE("Entering magnesium_radio_control_impl ctor...");
UHD_ASSERT_THROW(get_block_id().get_block_count() < 2);
+
+ _tx_gain_profile_api = std::make_shared<rf_control::enumerated_gain_profile>(MAGNESIUM_GP_OPTIONS, "default", MAGNESIUM_NUM_CHANS);
+ _rx_gain_profile_api = std::make_shared<rf_control::enumerated_gain_profile>(MAGNESIUM_GP_OPTIONS, "default", MAGNESIUM_NUM_CHANS);
+
const char radio_slot_name[2] = {'A', 'B'};
_radio_slot = radio_slot_name[get_block_id().get_block_count()];
RFNOC_LOG_TRACE("Radio slot: " << _radio_slot);
@@ -363,28 +367,6 @@ double magnesium_radio_control_impl::set_tx_bandwidth(
return AD9371_TX_MAX_BANDWIDTH;
}
-void magnesium_radio_control_impl::set_tx_gain_profile(
- const std::string& profile, const size_t)
-{
- if (std::find(MAGNESIUM_GP_OPTIONS.begin(), MAGNESIUM_GP_OPTIONS.end(), profile)
- == MAGNESIUM_GP_OPTIONS.end()) {
- RFNOC_LOG_ERROR("Invalid TX gain profile: " << profile);
- throw uhd::key_error("Invalid TX gain profile!");
- }
- _gain_profile[TX_DIRECTION] = profile;
-}
-
-void magnesium_radio_control_impl::set_rx_gain_profile(
- const std::string& profile, const size_t)
-{
- if (std::find(MAGNESIUM_GP_OPTIONS.begin(), MAGNESIUM_GP_OPTIONS.end(), profile)
- == MAGNESIUM_GP_OPTIONS.end()) {
- RFNOC_LOG_ERROR("Invalid RX gain profile: " << profile);
- throw uhd::key_error("Invalid RX gain profile!");
- }
- _gain_profile[RX_DIRECTION] = profile;
-}
-
double magnesium_radio_control_impl::set_tx_gain(const double gain, const size_t chan)
{
std::lock_guard<std::recursive_mutex> l(_set_lock);
@@ -716,28 +698,6 @@ uhd::gain_range_t magnesium_radio_control_impl::get_rx_gain_range(
throw uhd::key_error("Invalid RX gain name!");
}
-std::vector<std::string> magnesium_radio_control_impl::get_tx_gain_profile_names(
- const size_t) const
-{
- return MAGNESIUM_GP_OPTIONS;
-}
-
-std::vector<std::string> magnesium_radio_control_impl::get_rx_gain_profile_names(
- const size_t) const
-{
- return MAGNESIUM_GP_OPTIONS;
-}
-
-std::string magnesium_radio_control_impl::get_tx_gain_profile(const size_t) const
-{
- return _gain_profile.at(TX_DIRECTION);
-}
-
-std::string magnesium_radio_control_impl::get_rx_gain_profile(const size_t) const
-{
- return _gain_profile.at(RX_DIRECTION);
-}
-
meta_range_t magnesium_radio_control_impl::get_tx_bandwidth_range(size_t) const
{
return meta_range_t(AD9371_TX_MIN_BANDWIDTH, AD9371_TX_MAX_BANDWIDTH);
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_control.hpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_control.hpp
index fc8c79b5a..e8c252605 100644
--- a/host/lib/usrp/dboard/magnesium/magnesium_radio_control.hpp
+++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_control.hpp
@@ -87,8 +87,6 @@ public:
double set_rx_gain(const double gain, const std::string& name, const size_t chan);
double set_tx_bandwidth(const double bandwidth, const size_t chan);
double set_rx_bandwidth(const double bandwidth, const size_t chan);
- void set_tx_gain_profile(const std::string& profile, const size_t chan);
- void set_rx_gain_profile(const std::string& profile, const size_t chan);
// Getters
std::vector<std::string> get_tx_antennas(const size_t chan) const;
@@ -103,10 +101,6 @@ public:
uhd::gain_range_t get_tx_gain_range(const std::string&, const size_t) const;
uhd::gain_range_t get_rx_gain_range(const size_t) const;
uhd::gain_range_t get_rx_gain_range(const std::string&, const size_t) const;
- std::vector<std::string> get_tx_gain_profile_names(const size_t chan) const;
- std::vector<std::string> get_rx_gain_profile_names(const size_t chan) const;
- std::string get_tx_gain_profile(const size_t chan) const;
- std::string get_rx_gain_profile(const size_t chan) const;
uhd::meta_range_t get_tx_bandwidth_range(size_t chan) const;
uhd::meta_range_t get_rx_bandwidth_range(size_t chan) const;
@@ -351,9 +345,6 @@ private:
//! All gain
double _all_rx_gain = 0.0;
double _all_tx_gain = 0.0;
- //! Gain profile
- std::map<direction_t, std::string> _gain_profile = {
- {RX_DIRECTION, "default"}, {TX_DIRECTION, "default"}};
bool _rx_bypass_lnas = true;
bool _tx_bypass_amp = true;
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_control_gain.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_control_gain.cpp
index b06222205..72d8d564c 100644
--- a/host/lib/usrp/dboard/magnesium/magnesium_radio_control_gain.cpp
+++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_control_gain.cpp
@@ -31,7 +31,7 @@ double magnesium_radio_control_impl::_set_all_gain(
const size_t ad9371_chan = chan;
auto chan_sel = static_cast<magnesium_cpld_ctrl::chan_sel_t>(chan);
gain_tuple_t gain_tuple;
- std::string gp = _gain_profile[dir];
+ std::string gp = dir == RX_DIRECTION ? get_rx_gain_profile(0) : get_tx_gain_profile(0);
RFNOC_LOG_TRACE("Gain profile: " << gp);
if (gp == "manual") {
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_control_init.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_control_init.cpp
index d9bf5c3d2..82da7ec75 100644
--- a/host/lib/usrp/dboard/magnesium/magnesium_radio_control_init.cpp
+++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_control_init.cpp
@@ -51,13 +51,13 @@ void magnesium_radio_control_impl::_init_defaults()
if (block_args.has_key("tx_gain_profile")) {
RFNOC_LOG_INFO("Using user specified TX gain profile: " << block_args.get(
"tx_gain_profile"));
- _gain_profile[TX_DIRECTION] = block_args.get("tx_gain_profile");
+ set_tx_gain_profile(block_args.get("tx_gain_profile"), 0);
}
if (block_args.has_key("rx_gain_profile")) {
RFNOC_LOG_INFO("Using user specified RX gain profile: " << block_args.get(
"rx_gain_profile"));
- _gain_profile[RX_DIRECTION] = block_args.get("rx_gain_profile");
+ set_rx_gain_profile(block_args.get("rx_gain_profile"), 0);
}
if (block_args.has_key("rx_band_map")) {