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/usrp2 | |
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/usrp2')
-rw-r--r-- | host/lib/usrp/usrp2/CMakeLists.txt | 42 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/codec_ctrl.cpp | 23 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/codec_ctrl.hpp | 9 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/dsp_impl.cpp | 19 |
4 files changed, 70 insertions, 23 deletions
diff --git a/host/lib/usrp/usrp2/CMakeLists.txt b/host/lib/usrp/usrp2/CMakeLists.txt index 81b73fcc2..d83c82063 100644 --- a/host/lib/usrp/usrp2/CMakeLists.txt +++ b/host/lib/usrp/usrp2/CMakeLists.txt @@ -15,32 +15,34 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -#This file will be included by cmake, use absolute paths! +######################################################################## +# This file included, use CMake directory variables +######################################################################## ######################################################################## # Conditionally configure the USRP2 support ######################################################################## -LIBUHD_REGISTER_COMPONENT("USRP2" ENABLE_USRP2 TRUE) +LIBUHD_REGISTER_COMPONENT("USRP2" ENABLE_USRP2 ON "ENABLE_LIBUHD" OFF) IF(ENABLE_USRP2) LIBUHD_APPEND_SOURCES( - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/clock_ctrl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/clock_ctrl.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/codec_ctrl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/codec_ctrl.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/codec_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/dboard_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/dboard_iface.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/dsp_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/gps_ctrl.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/gps_ctrl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/io_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/mboard_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/usrp2_iface.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/usrp2_iface.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/usrp2_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/usrp2_impl.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/usrp2_regs.hpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/usrp2_regs.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/clock_ctrl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/clock_ctrl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/codec_ctrl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/codec_ctrl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/codec_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dboard_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dboard_iface.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dsp_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/gps_ctrl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/gps_ctrl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/io_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mboard_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp2_iface.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp2_iface.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp2_impl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp2_impl.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp2_regs.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/usrp2_regs.cpp ) ENDIF(ENABLE_USRP2) diff --git a/host/lib/usrp/usrp2/codec_ctrl.cpp b/host/lib/usrp/usrp2/codec_ctrl.cpp index ad1ae1acb..4f2cd88bb 100644 --- a/host/lib/usrp/usrp2/codec_ctrl.cpp +++ b/host/lib/usrp/usrp2/codec_ctrl.cpp @@ -39,7 +39,7 @@ public: //setup the ad9777 dac _ad9777_regs.x_1r_2r_mode = ad9777_regs_t::X_1R_2R_MODE_1R; _ad9777_regs.filter_interp_rate = ad9777_regs_t::FILTER_INTERP_RATE_4X; - _ad9777_regs.mix_mode = ad9777_regs_t::MIX_MODE_REAL; + _ad9777_regs.mix_mode = ad9777_regs_t::MIX_MODE_COMPLEX; _ad9777_regs.pll_divide_ratio = ad9777_regs_t::PLL_DIVIDE_RATIO_DIV1; _ad9777_regs.pll_state = ad9777_regs_t::PLL_STATE_ON; _ad9777_regs.auto_cp_control = ad9777_regs_t::AUTO_CP_CONTROL_AUTO; @@ -57,6 +57,7 @@ public: for(boost::uint8_t addr = 0; addr <= 0xC; addr++){ this->send_ad9777_reg(addr); } + set_tx_mod_mode(0); //power-up adc switch(_iface->get_rev()){ @@ -102,6 +103,26 @@ public: } } + void set_tx_mod_mode(int mod_mode){ + //set the sign of the frequency shift + _ad9777_regs.modulation_form = (mod_mode > 0)? + ad9777_regs_t::MODULATION_FORM_E_PLUS_JWT: + ad9777_regs_t::MODULATION_FORM_E_MINUS_JWT + ; + + //set the frequency shift + switch(std::abs(mod_mode)){ + case 0: + case 1: _ad9777_regs.modulation_mode = ad9777_regs_t::MODULATION_MODE_NONE; break; + case 2: _ad9777_regs.modulation_mode = ad9777_regs_t::MODULATION_MODE_FS_2; break; + case 4: _ad9777_regs.modulation_mode = ad9777_regs_t::MODULATION_MODE_FS_4; break; + case 8: _ad9777_regs.modulation_mode = ad9777_regs_t::MODULATION_MODE_FS_8; break; + default: throw std::runtime_error("unknown modulation mode for ad9777"); + } + + this->send_ad9777_reg(0x01); //set the register + } + void set_rx_digital_gain(float gain) { //fine digital gain switch(_iface->get_rev()){ case usrp2_iface::USRP_N200: diff --git a/host/lib/usrp/usrp2/codec_ctrl.hpp b/host/lib/usrp/usrp2/codec_ctrl.hpp index 57a37b94b..c8d977a1f 100644 --- a/host/lib/usrp/usrp2/codec_ctrl.hpp +++ b/host/lib/usrp/usrp2/codec_ctrl.hpp @@ -34,6 +34,15 @@ public: static sptr make(usrp2_iface::sptr iface); /*! + * Set the modulation mode for the DAC. + * Possible modes are 0, +/-1, +/-2, +/-4, +/-8 + * which correspond to shifts of fs/mod_mode. + * A mode of 0 or +/-1 means no modulation. + * \param mod_mode the modulation mode + */ + virtual void set_tx_mod_mode(int mod_mode) = 0; + + /*! * Set the analog preamplifier on the USRP2+ ADC (ADS62P44). * \param gain enable or disable the 3.5dB preamp */ diff --git a/host/lib/usrp/usrp2/dsp_impl.cpp b/host/lib/usrp/usrp2/dsp_impl.cpp index 77ed594f5..8340f7cdd 100644 --- a/host/lib/usrp/usrp2/dsp_impl.cpp +++ b/host/lib/usrp/usrp2/dsp_impl.cpp @@ -20,6 +20,9 @@ #include <uhd/usrp/dsp_utils.hpp> #include <uhd/usrp/dsp_props.hpp> #include <boost/bind.hpp> +#include <boost/math/special_functions/round.hpp> +#include <boost/math/special_functions/sign.hpp> +#include <algorithm> #include <cmath> using namespace uhd; @@ -177,11 +180,23 @@ void usrp2_mboard_impl::duc_set(const wax::obj &key_, const wax::obj &val){ switch(key.as<dsp_prop_t>()){ case DSP_PROP_FREQ_SHIFT:{ + const double codec_rate = get_master_clock_freq(); double new_freq = val.as<double>(); + + //calculate the DAC shift (multiples of rate) + const int sign = boost::math::sign(new_freq); + const int zone = std::min(boost::math::iround(new_freq/codec_rate), 2); + const double dac_shift = sign*zone*codec_rate; + new_freq -= dac_shift; //update FPGA DSP target freq + + //set the DAC shift (modulation mode) + if (zone == 0) _codec_ctrl->set_tx_mod_mode(0); //no shift + else _codec_ctrl->set_tx_mod_mode(sign*4/zone); //DAC interp = 4 + _iface->poke32(_iface->regs.dsp_tx_freq, - dsp_type1::calc_cordic_word_and_update(new_freq, get_master_clock_freq()) + dsp_type1::calc_cordic_word_and_update(new_freq, codec_rate) ); - _duc_freq = new_freq; //shadow + _duc_freq = new_freq + dac_shift; //shadow } return; |