diff options
author | Josh Blum <josh@joshknows.com> | 2011-07-04 08:33:47 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-07-04 08:33:47 -0700 |
commit | df91040196c536c1cf0a57379b946c89ea73ae6b (patch) | |
tree | 54fb6d34704c10bf6b00852094a3b437c08fbb53 /host/lib/usrp/cores | |
parent | 729b284f628f3326d774262570b68540d7de9baa (diff) | |
download | uhd-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/cores')
-rw-r--r-- | host/lib/usrp/cores/rx_dsp_core_200.cpp | 11 | ||||
-rw-r--r-- | host/lib/usrp/cores/rx_dsp_core_200.hpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/cores/tx_dsp_core_200.cpp | 11 | ||||
-rw-r--r-- | host/lib/usrp/cores/tx_dsp_core_200.hpp | 2 |
4 files changed, 22 insertions, 4 deletions
diff --git a/host/lib/usrp/cores/rx_dsp_core_200.cpp b/host/lib/usrp/cores/rx_dsp_core_200.cpp index 0c065e228..e059ddfca 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.cpp @@ -18,6 +18,7 @@ #include "rx_dsp_core_200.hpp" #include <uhd/types/dict.hpp> #include <uhd/exception.hpp> +#include <uhd/utils/algorithm.hpp> #include <boost/assign/list_of.hpp> #include <boost/math/special_functions/round.hpp> #include <boost/math/special_functions/sign.hpp> @@ -122,8 +123,14 @@ public: _tick_rate = rate; } + void set_link_rate(const double rate){ + _link_rate = rate/sizeof(boost::uint32_t); //in samps/s + } + double set_host_rate(const double rate){ - const size_t decim_rate = boost::math::iround(_tick_rate/rate); + const size_t decim_rate = uhd::clip<size_t>( + boost::math::iround(_tick_rate/rate), size_t(std::ceil(_tick_rate/_link_rate)), 512 + ); size_t decim = decim_rate; //determine which half-band filters are activated @@ -172,7 +179,7 @@ public: private: wb_iface::sptr _iface; const size_t _dsp_base, _ctrl_base; - double _tick_rate; + double _tick_rate, _link_rate; bool _continuous_streaming; }; diff --git a/host/lib/usrp/cores/rx_dsp_core_200.hpp b/host/lib/usrp/cores/rx_dsp_core_200.hpp index 72ed07230..abe7bf817 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.hpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.hpp @@ -44,6 +44,8 @@ public: virtual void set_tick_rate(const double rate) = 0; + virtual void set_link_rate(const double rate) = 0; + virtual double set_host_rate(const double rate) = 0; virtual uhd::meta_range_t get_freq_range(void) = 0; diff --git a/host/lib/usrp/cores/tx_dsp_core_200.cpp b/host/lib/usrp/cores/tx_dsp_core_200.cpp index d2981bbdb..222ba589a 100644 --- a/host/lib/usrp/cores/tx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/tx_dsp_core_200.cpp @@ -18,6 +18,7 @@ #include "tx_dsp_core_200.hpp" #include <uhd/types/dict.hpp> #include <uhd/exception.hpp> +#include <uhd/utils/algorithm.hpp> #include <boost/assign/list_of.hpp> #include <boost/math/special_functions/round.hpp> #include <boost/math/special_functions/sign.hpp> @@ -68,8 +69,14 @@ public: _tick_rate = rate; } + void set_link_rate(const double rate){ + _link_rate = rate/sizeof(boost::uint32_t); //in samps/s + } + double set_host_rate(const double rate){ - const size_t interp_rate = boost::math::iround(_tick_rate/rate); + const size_t interp_rate = uhd::clip<size_t>( + boost::math::iround(_tick_rate/rate), size_t(std::ceil(_tick_rate/_link_rate)), 512 + ); size_t interp = interp_rate; //determine which half-band filters are activated @@ -125,7 +132,7 @@ public: private: wb_iface::sptr _iface; const size_t _dsp_base, _ctrl_base; - double _tick_rate; + double _tick_rate, _link_rate; }; tx_dsp_core_200::sptr tx_dsp_core_200::make(wb_iface::sptr iface, const size_t dsp_base, const size_t ctrl_base, const boost::uint32_t sid){ diff --git a/host/lib/usrp/cores/tx_dsp_core_200.hpp b/host/lib/usrp/cores/tx_dsp_core_200.hpp index f74ec0bdb..65f822558 100644 --- a/host/lib/usrp/cores/tx_dsp_core_200.hpp +++ b/host/lib/usrp/cores/tx_dsp_core_200.hpp @@ -36,6 +36,8 @@ public: virtual void set_tick_rate(const double rate) = 0; + virtual void set_link_rate(const double rate) = 0; + virtual double set_host_rate(const double rate) = 0; virtual uhd::meta_range_t get_freq_range(void) = 0; |