aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp')
-rw-r--r--host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp47
1 files changed, 36 insertions, 11 deletions
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp b/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp
index 3683fae47..3bb0aeea6 100644
--- a/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp
+++ b/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp
@@ -17,9 +17,23 @@ namespace {
*/
std::string _get_which(const direction_t dir, const size_t chan)
{
- UHD_ASSERT_THROW(dir == RX_DIRECTION or dir == TX_DIRECTION);
- UHD_ASSERT_THROW(chan == 0 or chan == 1);
- return str(boost::format("%s%d") % (dir == RX_DIRECTION ? "RX" : "TX") % (chan + 1));
+ UHD_ASSERT_THROW(dir == RX_DIRECTION || dir == TX_DIRECTION);
+ UHD_ASSERT_THROW(chan == 0 || chan == 1);
+ return (dir == RX_DIRECTION ? "RX" : "TX") + std::to_string(chan + 1);
+}
+
+/*! Return a valid 'which' string for use with AD9371 API duplex calls
+ *
+ * Extends _get_which by additionally allowing duplex values
+ */
+std::string _get_which_duplex(const direction_t dir, const size_t chan)
+{
+ if (dir == RX_DIRECTION || dir == TX_DIRECTION) {
+ return _get_which(dir, chan);
+ }
+ UHD_ASSERT_THROW(dir == DX_DIRECTION);
+ UHD_ASSERT_THROW(chan == 0 || chan == 1);
+ return "DX" + std::to_string(chan + 1);
}
} // namespace
@@ -59,12 +73,23 @@ double magnesium_ad9371_iface::set_gain(
// return 0.0;
}
+/*! brief Sets the frontend bandwidth settings for the dboard. Requires
+ * re-initializing the dboard, so it may take a significant amount of time.
+ *
+ * \param bandwidth target rf bandwidth value
+ * \param chan -not important- the bandwidth settings affect both channels on
+ * the dboard
+ * \param dir specifies which path to set the bandwidth filters for. Supports
+ * rx, tx, or dx for both
+ * \return actual rf bandwidth value
+ */
double magnesium_ad9371_iface::set_bandwidth(
const double bandwidth, const size_t chan, const direction_t dir)
{
- auto const which = _get_which(dir, chan);
- auto retval = request<double>("set_bw_filter", which, bandwidth);
- UHD_LOG_TRACE(_log_prefix, _rpc_prefix << "set_bw_filter returned " << retval);
+ const auto which = _get_which_duplex(dir, chan);
+ const auto retval =
+ request<double>(MAGNESIUM_TUNE_TIMEOUT, "set_bandwidth", which, bandwidth);
+ UHD_LOG_TRACE(_log_prefix, _rpc_prefix << "set_bandwidth returned " << retval);
return retval;
}
@@ -84,12 +109,12 @@ double magnesium_ad9371_iface::get_gain(const size_t chan, const direction_t dir
return retval;
}
-double magnesium_ad9371_iface::get_bandwidth(
- const size_t /*chan*/, const direction_t /*dir*/)
+double magnesium_ad9371_iface::get_bandwidth(const size_t chan, const direction_t dir)
{
- // TODO: implement
- UHD_LOG_WARNING(_log_prefix, "Ignoring attempt to get bandwidth");
- return 0.0;
+ const auto which = _get_which(dir, chan);
+ const auto retval = request<double>("get_bandwidth", which);
+ UHD_LOG_TRACE(_log_prefix, _rpc_prefix << "get_bandwidth returned " << retval);
+ return retval;
}
std::string magnesium_ad9371_iface::set_lo_source(