diff options
author | Josh Blum <josh@joshknows.com> | 2010-12-22 17:33:43 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-12-22 17:33:43 -0800 |
commit | 67e89717659605e4d8e0ddd26e4ccef4dec24eb2 (patch) | |
tree | a011be8ad75e13fd98d61c8b31ed218e0bce687c /host/lib/usrp/dsp_utils.cpp | |
parent | 94682e4b04d9304a2f39c192bf423c4ee9f38e69 (diff) | |
parent | 8f93121987af42d8b049d29cd8ea101a6306fa87 (diff) | |
download | uhd-67e89717659605e4d8e0ddd26e4ccef4dec24eb2.tar.gz uhd-67e89717659605e4d8e0ddd26e4ccef4dec24eb2.tar.bz2 uhd-67e89717659605e4d8e0ddd26e4ccef4dec24eb2.zip |
Merge branch 'master' into next
Conflicts:
host/lib/usrp/usrp2/CMakeLists.txt
Diffstat (limited to 'host/lib/usrp/dsp_utils.cpp')
-rw-r--r-- | host/lib/usrp/dsp_utils.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/host/lib/usrp/dsp_utils.cpp b/host/lib/usrp/dsp_utils.cpp index 2553e4a25..576c4639f 100644 --- a/host/lib/usrp/dsp_utils.cpp +++ b/host/lib/usrp/dsp_utils.cpp @@ -21,6 +21,8 @@ #include <boost/assign/list_of.hpp> #include <boost/tuple/tuple.hpp> #include <boost/math/special_functions/round.hpp> +#include <boost/math/special_functions/sign.hpp> +#include <algorithm> #include <cmath> using namespace uhd; @@ -65,13 +67,16 @@ boost::uint32_t dsp_type1::calc_tx_mux_word(subdev_conn_t subdev_conn){ } boost::uint32_t dsp_type1::calc_cordic_word_and_update( - double &freq, - double codec_rate + double &freq, double codec_rate ){ - UHD_ASSERT_THROW(std::abs(freq) <= codec_rate/2.0); - static const double scale_factor = std::pow(2.0, 32); + //correct for outside of rate (wrap around) + freq = std::fmod(freq, codec_rate); + if (std::abs(freq) > codec_rate/2.0) + freq -= boost::math::sign(freq)*codec_rate; //calculate the freq register word (signed) + UHD_ASSERT_THROW(std::abs(freq) <= codec_rate/2.0); + static const double scale_factor = std::pow(2.0, 32); boost::int32_t freq_word = boost::int32_t(boost::math::round((freq / codec_rate) * scale_factor)); //update the actual frequency |