diff options
author | Mark Meserve <mark.meserve@ni.com> | 2018-12-21 15:54:17 -0600 |
---|---|---|
committer | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-10 09:50:16 -0800 |
commit | 9b9da62e800ed88123c3bae7abecd5603ead0f7e (patch) | |
tree | 1ac936dedc38f51c539c3e421136aee886b0a130 /host | |
parent | ec0b4dd1274c2d1d3fd392561f90e0186732cd52 (diff) | |
download | uhd-9b9da62e800ed88123c3bae7abecd5603ead0f7e.tar.gz uhd-9b9da62e800ed88123c3bae7abecd5603ead0f7e.tar.bz2 uhd-9b9da62e800ed88123c3bae7abecd5603ead0f7e.zip |
rh: implement set_rate
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/usrp/dboard/rhodium/rhodium_constants.hpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.cpp | 35 | ||||
-rw-r--r-- | host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_init.cpp | 8 |
3 files changed, 40 insertions, 9 deletions
diff --git a/host/lib/usrp/dboard/rhodium/rhodium_constants.hpp b/host/lib/usrp/dboard/rhodium/rhodium_constants.hpp index 2aafe4a63..c52a73bca 100644 --- a/host/lib/usrp/dboard/rhodium/rhodium_constants.hpp +++ b/host/lib/usrp/dboard/rhodium/rhodium_constants.hpp @@ -14,7 +14,11 @@ static constexpr double RHODIUM_FREQ_COMPARE_EPSILON = 1e-5; -static constexpr double RHODIUM_RADIO_RATE = 122.88e6; // Hz +static constexpr size_t NUM_RHODIUM_RADIO_RATES = 3; + +static constexpr std::array<double, NUM_RHODIUM_RADIO_RATES> RHODIUM_RADIO_RATES = { + 200e6, 245.76e6, 250e6}; + static constexpr double RHODIUM_MIN_FREQ = 1e6; // Hz static constexpr double RHODIUM_MAX_FREQ = 6e9; // Hz 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( diff --git a/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_init.cpp b/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_init.cpp index 9cf7c57e6..b626e5c15 100644 --- a/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_init.cpp +++ b/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_init.cpp @@ -794,11 +794,15 @@ void rhodium_radio_ctrl_impl::_init_prop_tree() _tree->create<std::string>("rx_codecs" / _radio_slot / "name").set("ad9695-625"); _tree->create<std::string>("tx_codecs" / _radio_slot / "name").set("dac37j82"); - // TODO remove this dirty hack - if (not _tree->exists("tick_rate")) + // The tick_rate is equivalent to the master clock rate of the DB in slot A + if (_radio_slot == "A") { + UHD_ASSERT_THROW(!_tree->exists("tick_rate")); + // set_rate sets the clock rate of the entire device, not just this DB, + // so only add DB A's set and get functions to the tree. _tree->create<double>("tick_rate") .set_publisher([this](){ return this->get_rate(); }) + .add_coerced_subscriber([this](double rate) { return this->set_rate(rate); }) ; } } |