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/cores/rx_dsp_core_200.cpp | 11 +++++++++-- host/lib/usrp/cores/rx_dsp_core_200.hpp | 2 ++ host/lib/usrp/cores/tx_dsp_core_200.cpp | 11 +++++++++-- host/lib/usrp/cores/tx_dsp_core_200.hpp | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-) (limited to 'host/lib/usrp/cores') 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 #include +#include #include #include #include @@ -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( + 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 #include +#include #include #include #include @@ -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( + 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; -- cgit v1.2.3