summaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp1
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-07-04 08:33:47 -0700
committerJosh Blum <josh@joshknows.com>2011-07-04 08:33:47 -0700
commitdf91040196c536c1cf0a57379b946c89ea73ae6b (patch)
tree54fb6d34704c10bf6b00852094a3b437c08fbb53 /host/lib/usrp/usrp1
parent729b284f628f3326d774262570b68540d7de9baa (diff)
downloaduhd-df91040196c536c1cf0a57379b946c89ea73ae6b.tar.gz
uhd-df91040196c536c1cf0a57379b946c89ea73ae6b.tar.bz2
uhd-df91040196c536c1cf0a57379b946c89ea73ae6b.zip
usrp: added clipping to link max rate when setting sample rate
Diffstat (limited to 'host/lib/usrp/usrp1')
-rw-r--r--host/lib/usrp/usrp1/io_impl.cpp14
1 files changed, 6 insertions, 8 deletions
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<size_t>(std::max<size_t>(rate, 4), 256);
+ const size_t rate = uhd::clip<size_t>(
+ 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<size_t>(std::max<size_t>(rate, 4), 256);
+ const size_t rate = uhd::clip<size_t>(
+ 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);