aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.cpp
diff options
context:
space:
mode:
authorMark Meserve <mark.meserve@ni.com>2018-12-21 15:54:17 -0600
committerBrent Stapleton <brent.stapleton@ettus.com>2019-01-10 09:50:16 -0800
commit9b9da62e800ed88123c3bae7abecd5603ead0f7e (patch)
tree1ac936dedc38f51c539c3e421136aee886b0a130 /host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.cpp
parentec0b4dd1274c2d1d3fd392561f90e0186732cd52 (diff)
downloaduhd-9b9da62e800ed88123c3bae7abecd5603ead0f7e.tar.gz
uhd-9b9da62e800ed88123c3bae7abecd5603ead0f7e.tar.bz2
uhd-9b9da62e800ed88123c3bae7abecd5603ead0f7e.zip
rh: implement set_rate
Diffstat (limited to 'host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.cpp')
-rw-r--r--host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.cpp35
1 files changed, 29 insertions, 6 deletions
diff --git a/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.cpp b/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.cpp
index 6599e3d82..61e2d2550 100644
--- a/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.cpp
+++ b/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.cpp
@@ -70,13 +70,36 @@ rhodium_radio_ctrl_impl::~rhodium_radio_ctrl_impl()
/******************************************************************************
* API Calls
*****************************************************************************/
-double rhodium_radio_ctrl_impl::set_rate(double /* rate */)
+double rhodium_radio_ctrl_impl::set_rate(double requested_rate)
{
- // TODO: implement
- // TODO: set_rate may also need to update the LO since master clock rate
- // changes also change the lowband LO frequency. (run set_frequency)
- UHD_LOG_WARNING(unique_id(), "set_rate() called but not implemented");
- return 0.0;
+ meta_range_t rates;
+ for (const double rate : RHODIUM_RADIO_RATES) {
+ rates.push_back(range_t(rate));
+ }
+
+ const double rate = rates.clip(requested_rate);
+ if (!math::frequencies_are_equal(requested_rate, rate)) {
+ UHD_LOG_WARNING(unique_id(),
+ "Coercing requested sample rate from " << (requested_rate / 1e6) << " MHz to " <<
+ (rate / 1e6) << " MHz, the closest possible rate.");
+ }
+
+ const double current_rate = get_rate();
+ if (math::frequencies_are_equal(current_rate, rate)) {
+ UHD_LOG_DEBUG(
+ unique_id(), "Rate is already at " << (rate / 1e6) << " MHz. Skipping set_rate()");
+ return current_rate;
+ }
+
+ UHD_LOG_TRACE(unique_id(), "Updating master clock rate to " << rate);
+ auto new_rate = _rpcc->request_with_token<double>(_rpc_prefix + "set_master_clock_rate", rate);
+ // The lowband LO frequency will change with the master clock rate, so
+ // update the tuning of the device.
+ set_tx_frequency(get_tx_frequency(0), 0);
+ set_rx_frequency(get_rx_frequency(0), 0);
+
+ radio_ctrl_impl::set_rate(new_rate);
+ return new_rate;
}
void rhodium_radio_ctrl_impl::set_tx_antenna(