diff options
author | Josh Blum <josh@joshknows.com> | 2011-10-16 10:43:48 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-11-03 20:37:13 -0700 |
commit | ae9e89d76b2eb86a29995f04aaab1aa59ee93f04 (patch) | |
tree | 29b37a85c2779c9d3abca81028396f5e4cbdcebc /host/lib/usrp/usrp1 | |
parent | fe204a322ecbba4dd8b195987667651f0a1b7c80 (diff) | |
download | uhd-ae9e89d76b2eb86a29995f04aaab1aa59ee93f04.tar.gz uhd-ae9e89d76b2eb86a29995f04aaab1aa59ee93f04.tar.bz2 uhd-ae9e89d76b2eb86a29995f04aaab1aa59ee93f04.zip |
usrp: added get_tx/rx_rates
Diffstat (limited to 'host/lib/usrp/usrp1')
-rw-r--r-- | host/lib/usrp/usrp1/io_impl.cpp | 27 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/usrp1_impl.cpp | 8 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/usrp1_impl.hpp | 2 |
3 files changed, 30 insertions, 7 deletions
diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp index 12950d385..31c834109 100644 --- a/host/lib/usrp/usrp1/io_impl.cpp +++ b/host/lib/usrp/usrp1/io_impl.cpp @@ -442,7 +442,6 @@ void usrp1_impl::update_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec){ this->restore_tx(s); } - void usrp1_impl::update_tick_rate(const double rate){ //updating this variable should: //update dboard iface -> it has a reference @@ -450,11 +449,29 @@ void usrp1_impl::update_tick_rate(const double rate){ _master_clock_rate = rate; } +uhd::meta_range_t usrp1_impl::get_rx_dsp_host_rates(void){ + meta_range_t range; + const size_t div = this->has_rx_halfband()? 2 : 1; + for (int rate = 256; rate >= 4; rate -= div){ + range.push_back(range_t(_master_clock_rate/rate)); + } + return range; +} + +uhd::meta_range_t usrp1_impl::get_tx_dsp_host_rates(void){ + meta_range_t range; + const size_t div = this->has_tx_halfband()? 2 : 1; + for (int rate = 256; rate >= 8; rate -= div){ + range.push_back(range_t(_master_clock_rate/rate)); + } + return range; +} + double usrp1_impl::update_rx_samp_rate(size_t dspno, const double samp_rate){ const size_t div = this->has_rx_halfband()? 2 : 1; - const size_t rate = uhd::clip<size_t>( - boost::math::iround(_master_clock_rate / samp_rate), 4, 256) & ~(div-1); + const size_t rate = this->get_rx_dsp_host_rates().clip( + boost::math::iround(_master_clock_rate / samp_rate), true); if (rate < 8 and this->has_rx_halfband()) UHD_MSG(warning) << "USRP1 cannot achieve decimations below 8 when the half-band filter is present.\n" @@ -482,8 +499,8 @@ double usrp1_impl::update_rx_samp_rate(size_t dspno, const double samp_rate){ double usrp1_impl::update_tx_samp_rate(size_t dspno, const double samp_rate){ const size_t div = this->has_tx_halfband()? 2 : 1; - const size_t rate = uhd::clip<size_t>( - boost::math::iround(_master_clock_rate / samp_rate), 8, 256) & ~(div-1); + const size_t rate = this->get_tx_dsp_host_rates().clip( + boost::math::iround(_master_clock_rate / samp_rate), true); if (dspno == 0){ //only care if dsp0 is set since its homogeneous bool s = this->disable_tx(); diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp index 5788c536f..1a61f8136 100644 --- a/host/lib/usrp/usrp1/usrp1_impl.cpp +++ b/host/lib/usrp/usrp1/usrp1_impl.cpp @@ -283,8 +283,10 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){ _tree->create<int>(mb_path / "rx_dsps"); //dummy in case we have none for (size_t dspno = 0; dspno < get_num_ddcs(); dspno++){ fs_path rx_dsp_path = mb_path / str(boost::format("rx_dsps/%u") % dspno); + _tree->create<meta_range_t>(rx_dsp_path / "rate/range") + .publish(boost::bind(&usrp1_impl::get_rx_dsp_host_rates, this)); _tree->create<double>(rx_dsp_path / "rate/value") - .set(1e6) + .set(1e6) //some default rate .coerce(boost::bind(&usrp1_impl::update_rx_samp_rate, this, dspno, _1)); _tree->create<double>(rx_dsp_path / "freq/value") .coerce(boost::bind(&usrp1_impl::update_rx_dsp_freq, this, dspno, _1)); @@ -304,8 +306,10 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){ _tree->create<int>(mb_path / "tx_dsps"); //dummy in case we have none for (size_t dspno = 0; dspno < get_num_ducs(); dspno++){ fs_path tx_dsp_path = mb_path / str(boost::format("tx_dsps/%u") % dspno); + _tree->create<meta_range_t>(tx_dsp_path / "rate/range") + .publish(boost::bind(&usrp1_impl::get_tx_dsp_host_rates, this)); _tree->create<double>(tx_dsp_path / "rate/value") - .set(1e6) + .set(1e6) //some default rate .coerce(boost::bind(&usrp1_impl::update_tx_samp_rate, this, dspno, _1)); _tree->create<double>(tx_dsp_path / "freq/value") .coerce(boost::bind(&usrp1_impl::update_tx_dsp_freq, this, dspno, _1)); diff --git a/host/lib/usrp/usrp1/usrp1_impl.hpp b/host/lib/usrp/usrp1/usrp1_impl.hpp index 6f427c31e..ec313daf6 100644 --- a/host/lib/usrp/usrp1/usrp1_impl.hpp +++ b/host/lib/usrp/usrp1/usrp1_impl.hpp @@ -98,6 +98,8 @@ private: void update_tick_rate(const double rate); uhd::meta_range_t get_rx_dsp_freq_range(void); uhd::meta_range_t get_tx_dsp_freq_range(void); + uhd::meta_range_t get_rx_dsp_host_rates(void); + uhd::meta_range_t get_tx_dsp_host_rates(void); static uhd::usrp::dboard_iface::sptr make_dboard_iface( usrp1_iface::sptr, |