From df91040196c536c1cf0a57379b946c89ea73ae6b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 4 Jul 2011 08:33:47 -0700 Subject: usrp: added clipping to link max rate when setting sample rate --- host/lib/usrp/usrp1/io_impl.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'host/lib/usrp/usrp1') diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp index bf34fde4f..b596bbd04 100644 --- a/host/lib/usrp/usrp1/io_impl.cpp +++ b/host/lib/usrp/usrp1/io_impl.cpp @@ -383,10 +383,9 @@ void usrp1_impl::update_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec){ double usrp1_impl::update_rx_samp_rate(const double samp_rate){ boost::mutex::scoped_lock lock = _io_impl->recv_handler.get_scoped_lock(); - size_t rate = boost::math::iround(_master_clock_rate / samp_rate); - - //clip the rate to something in range: - rate = std::min(std::max(rate, 4), 256); + const size_t rate = uhd::clip( + boost::math::iround(_master_clock_rate / samp_rate), size_t(std::ceil(_master_clock_rate / 8e6)), 256 + ); bool s = this->disable_rx(); _iface->poke32(FR_DECIM_RATE, rate/2 - 1); @@ -399,10 +398,9 @@ double usrp1_impl::update_rx_samp_rate(const double samp_rate){ double usrp1_impl::update_tx_samp_rate(const double samp_rate){ boost::mutex::scoped_lock lock = _io_impl->send_handler.get_scoped_lock(); - size_t rate = boost::math::iround(_master_clock_rate / samp_rate); - - //clip the rate to something in range: - rate = std::min(std::max(rate, 4), 256); + const size_t rate = uhd::clip( + boost::math::iround(_master_clock_rate / samp_rate), size_t(std::ceil(_master_clock_rate / 8e6)), 256 + ); bool s = this->disable_tx(); _iface->poke32(FR_INTERP_RATE, rate/2 - 1); -- cgit v1.2.3