diff options
author | Josh Blum <josh@joshknows.com> | 2011-06-29 10:54:28 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-06-29 10:54:28 -0700 |
commit | adbe1a0efe7598a9e0433675e2852aad2e280c62 (patch) | |
tree | 3ff0bec87ff979f091e3233bf06118670e2535fe /host/lib/usrp/cores | |
parent | d2f79c07281604c1b48ec81f1cdb2754e97bbe65 (diff) | |
download | uhd-adbe1a0efe7598a9e0433675e2852aad2e280c62.tar.gz uhd-adbe1a0efe7598a9e0433675e2852aad2e280c62.tar.bz2 uhd-adbe1a0efe7598a9e0433675e2852aad2e280c62.zip |
uhd: loopback working on usrp2
Diffstat (limited to 'host/lib/usrp/cores')
-rw-r--r-- | host/lib/usrp/cores/rx_dsp_core_200.cpp | 15 | ||||
-rw-r--r-- | host/lib/usrp/cores/rx_dsp_core_200.hpp | 3 | ||||
-rw-r--r-- | host/lib/usrp/cores/tx_dsp_core_200.cpp | 9 | ||||
-rw-r--r-- | host/lib/usrp/cores/tx_dsp_core_200.hpp | 3 |
4 files changed, 23 insertions, 7 deletions
diff --git a/host/lib/usrp/cores/rx_dsp_core_200.cpp b/host/lib/usrp/cores/rx_dsp_core_200.cpp index 3215bea15..8fcf4df96 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.cpp @@ -22,12 +22,12 @@ #include <boost/math/special_functions/round.hpp> #include <boost/math/special_functions/sign.hpp> #include <algorithm> -#include <algorithm> #include <cmath> #define REG_DSP_RX_FREQ _dsp_base + 0 -#define REG_DSP_RX_DECIM _dsp_base + 4 -#define REG_DSP_RX_MUX _dsp_base + 8 +//skip one right here +#define REG_DSP_RX_DECIM _dsp_base + 8 +#define REG_DSP_RX_MUX _dsp_base + 12 #define FLAG_DSP_RX_MUX_SWAP_IQ (1 << 0) #define FLAG_DSP_RX_MUX_REAL_MODE (1 << 1) @@ -123,7 +123,8 @@ public: } double set_host_rate(const double rate){ - int decim = boost::math::iround(_tick_rate/rate); + const size_t decim_rate = boost::math::iround(_tick_rate/rate); + size_t decim = decim_rate; //determine which half-band filters are activated int hb0 = 0, hb1 = 0; @@ -138,7 +139,7 @@ public: _iface->poke32(REG_DSP_RX_DECIM, (hb1 << 9) | (hb0 << 8) | (decim & 0xff)); - return _tick_rate/decim; + return _tick_rate/decim_rate; } double set_freq(const double freq_){ @@ -160,6 +161,10 @@ public: return actual_freq; } + uhd::meta_range_t get_freq_range(void){ + return uhd::meta_range_t(-_tick_rate/2, +_tick_rate/2, _tick_rate/std::pow(2.0, 32)); + } + void handle_overflow(void){ if (_continuous_streaming) issue_stream_command(stream_cmd_t::STREAM_MODE_START_CONTINUOUS); } diff --git a/host/lib/usrp/cores/rx_dsp_core_200.hpp b/host/lib/usrp/cores/rx_dsp_core_200.hpp index c496fca76..e0b6e18e4 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.hpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.hpp @@ -19,6 +19,7 @@ #define INCLUDED_LIBUHD_USRP_RX_DSP_CORE_200_HPP #include <uhd/config.hpp> +#include <uhd/types/ranges.hpp> #include <boost/utility.hpp> #include <boost/shared_ptr.hpp> #include <uhd/types/stream_cmd.hpp> @@ -45,6 +46,8 @@ public: virtual double set_host_rate(const double rate) = 0; + virtual uhd::meta_range_t get_freq_range(void) = 0; + virtual double set_freq(const double freq) = 0; virtual void handle_overflow(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 293b0b447..d2981bbdb 100644 --- a/host/lib/usrp/cores/tx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/tx_dsp_core_200.cpp @@ -69,7 +69,8 @@ public: } double set_host_rate(const double rate){ - int interp = boost::math::iround(_tick_rate/rate); + const size_t interp_rate = boost::math::iround(_tick_rate/rate); + size_t interp = interp_rate; //determine which half-band filters are activated int hb0 = 0, hb1 = 0; @@ -90,7 +91,7 @@ public: const boost::int16_t scale = boost::math::iround((4096*std::pow(2, ceil_log2(rate_cubed)))/(1.65*rate_cubed)); _iface->poke32(REG_DSP_TX_SCALE_IQ, (boost::uint32_t(scale) << 16) | (boost::uint32_t(scale) << 0)); - return _tick_rate/interp; + return _tick_rate/interp_rate; } double set_freq(const double freq_){ @@ -112,6 +113,10 @@ public: return actual_freq; } + uhd::meta_range_t get_freq_range(void){ + return uhd::meta_range_t(-_tick_rate/2, +_tick_rate/2, _tick_rate/std::pow(2.0, 32)); + } + void set_updates(const size_t cycles_per_up, const size_t packets_per_up){ _iface->poke32(REG_TX_CTRL_CYCLES_PER_UP, (cycles_per_up == 0)? 0 : (FLAG_TX_CTRL_UP_ENB | cycles_per_up)); _iface->poke32(REG_TX_CTRL_PACKETS_PER_UP, (packets_per_up == 0)? 0 : (FLAG_TX_CTRL_UP_ENB | packets_per_up)); diff --git a/host/lib/usrp/cores/tx_dsp_core_200.hpp b/host/lib/usrp/cores/tx_dsp_core_200.hpp index f218fe8c9..f74ec0bdb 100644 --- a/host/lib/usrp/cores/tx_dsp_core_200.hpp +++ b/host/lib/usrp/cores/tx_dsp_core_200.hpp @@ -19,6 +19,7 @@ #define INCLUDED_LIBUHD_USRP_TX_DSP_CORE_200_HPP #include <uhd/config.hpp> +#include <uhd/types/ranges.hpp> #include <boost/utility.hpp> #include <boost/shared_ptr.hpp> #include "wb_iface.hpp" @@ -37,6 +38,8 @@ public: virtual double set_host_rate(const double rate) = 0; + virtual uhd::meta_range_t get_freq_range(void) = 0; + virtual double set_freq(const double freq) = 0; virtual void set_updates(const size_t cycles_per_up, const size_t packets_per_up) = 0; |