summaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/CMakeLists.txt39
-rw-r--r--host/lib/usrp/dboard/CMakeLists.txt20
-rw-r--r--host/lib/usrp/dboard/db_dbsrx.cpp2
-rw-r--r--host/lib/usrp/dsp_utils.cpp13
-rw-r--r--host/lib/usrp/tune_helper.cpp7
-rw-r--r--host/lib/usrp/usrp1/CMakeLists.txt43
-rw-r--r--host/lib/usrp/usrp1/dsp_impl.cpp2
-rw-r--r--host/lib/usrp/usrp2/CMakeLists.txt42
-rw-r--r--host/lib/usrp/usrp2/codec_ctrl.cpp23
-rw-r--r--host/lib/usrp/usrp2/codec_ctrl.hpp9
-rw-r--r--host/lib/usrp/usrp2/dsp_impl.cpp19
-rw-r--r--host/lib/usrp/usrp_e100/CMakeLists.txt42
12 files changed, 155 insertions, 106 deletions
diff --git a/host/lib/usrp/CMakeLists.txt b/host/lib/usrp/CMakeLists.txt
index bd26d29a1..9dc74a5fe 100644
--- a/host/lib/usrp/CMakeLists.txt
+++ b/host/lib/usrp/CMakeLists.txt
@@ -15,25 +15,26 @@
# 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
+########################################################################
LIBUHD_APPEND_SOURCES(
- ${CMAKE_SOURCE_DIR}/lib/usrp/dboard_base.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/dboard_eeprom.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/dboard_id.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/dboard_iface.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/dboard_manager.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/dsp_utils.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/mboard_eeprom.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/misc_utils.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/multi_usrp.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/single_usrp.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/subdev_spec.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/tune_helper.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/wrapper_utils.hpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/dboard_base.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/dboard_eeprom.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/dboard_id.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/dboard_iface.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/dboard_manager.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/dsp_utils.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/mboard_eeprom.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/misc_utils.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/multi_usrp.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/single_usrp.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/subdev_spec.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/tune_helper.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_utils.hpp
)
-INCLUDE(${CMAKE_SOURCE_DIR}/lib/usrp/dboard/CMakeLists.txt)
-INCLUDE(${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/CMakeLists.txt)
-INCLUDE(${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/CMakeLists.txt)
-INCLUDE(${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/CMakeLists.txt)
+INCLUDE_SUBDIRECTORY(dboard)
+INCLUDE_SUBDIRECTORY(usrp1)
+INCLUDE_SUBDIRECTORY(usrp2)
+INCLUDE_SUBDIRECTORY(usrp_e100)
diff --git a/host/lib/usrp/dboard/CMakeLists.txt b/host/lib/usrp/dboard/CMakeLists.txt
index 79cd42d18..7bd201294 100644
--- a/host/lib/usrp/dboard/CMakeLists.txt
+++ b/host/lib/usrp/dboard/CMakeLists.txt
@@ -15,16 +15,18 @@
# 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
+########################################################################
LIBUHD_APPEND_SOURCES(
- ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_basic_and_lf.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_rfx.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_xcvr2450.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_wbx.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_dbsrx.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_unknown.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_tvrx.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/dboard/db_dbsrx2.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/db_basic_and_lf.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/db_rfx.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/db_xcvr2450.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/db_wbx.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/db_dbsrx.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/db_unknown.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/db_tvrx.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/db_dbsrx2.cpp
)
diff --git a/host/lib/usrp/dboard/db_dbsrx.cpp b/host/lib/usrp/dboard/db_dbsrx.cpp
index 7edc1822c..7250136f5 100644
--- a/host/lib/usrp/dboard/db_dbsrx.cpp
+++ b/host/lib/usrp/dboard/db_dbsrx.cpp
@@ -376,7 +376,7 @@ void dbsrx::set_lo_freq(double target_freq){
read_reg(0x0, 0x0);
//allow for setup time before checking condition again
- boost::this_thread::sleep(boost::posix_time::milliseconds(1));
+ boost::this_thread::sleep(boost::posix_time::milliseconds(10));
}
if(dbsrx_debug) std::cerr << boost::format(
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
diff --git a/host/lib/usrp/tune_helper.cpp b/host/lib/usrp/tune_helper.cpp
index fa40a8a26..eccee7f4b 100644
--- a/host/lib/usrp/tune_helper.cpp
+++ b/host/lib/usrp/tune_helper.cpp
@@ -20,7 +20,6 @@
#include <uhd/usrp/dsp_props.hpp>
#include <uhd/usrp/dboard_iface.hpp> //unit_t
#include <uhd/utils/algorithm.hpp>
-#include <boost/math/special_functions/sign.hpp>
#include <cmath>
using namespace uhd;
@@ -37,7 +36,6 @@ static tune_result_t tune_xx_subdev_and_dsp(
wax::obj subdev_freq_proxy = subdev[SUBDEV_PROP_FREQ];
std::string freq_name = dsp[DSP_PROP_FREQ_SHIFT_NAMES].as<prop_names_t>().at(chan);
wax::obj dsp_freq_proxy = dsp[named_prop_t(DSP_PROP_FREQ_SHIFT, freq_name)];
- double dsp_sample_rate = dsp[DSP_PROP_CODEC_RATE].as<double>();
//------------------------------------------------------------------
//-- calculate the LO offset, only used with automatic policy
@@ -73,10 +71,7 @@ static tune_result_t tune_xx_subdev_and_dsp(
//------------------------------------------------------------------
//-- calculate the dsp freq, only used with automatic policy
//------------------------------------------------------------------
- double delta_freq = std::fmod(tune_request.target_freq - actual_inter_freq, dsp_sample_rate);
- bool outside_of_nyquist = std::abs(delta_freq) > dsp_sample_rate/2.0;
- double target_dsp_freq = (outside_of_nyquist)?
- boost::math::sign(delta_freq)*dsp_sample_rate - delta_freq : -delta_freq;
+ double target_dsp_freq = actual_inter_freq - tune_request.target_freq;
//invert the sign on the dsp freq given the following conditions
if (unit == dboard_iface::UNIT_TX) target_dsp_freq *= -1.0;
diff --git a/host/lib/usrp/usrp1/CMakeLists.txt b/host/lib/usrp/usrp1/CMakeLists.txt
index 8b6ba78d2..519e17bfa 100644
--- a/host/lib/usrp/usrp1/CMakeLists.txt
+++ b/host/lib/usrp/usrp1/CMakeLists.txt
@@ -15,37 +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 USRP1 support
########################################################################
-LIBUHD_REGISTER_COMPONENT("USRP1" ENABLE_USRP1 ${HAVE_USB_SUPPORT})
-
-#sanity check when USRP1 support enabled
-IF(ENABLE_USRP1 AND NOT HAVE_USB_SUPPORT)
- MESSAGE(FATAL_ERROR "USRP1 support enabled without USB support")
-ENDIF(ENABLE_USRP1 AND NOT HAVE_USB_SUPPORT)
+LIBUHD_REGISTER_COMPONENT("USRP1" ENABLE_USRP1 ON "ENABLE_LIBUHD;ENABLE_USB" OFF)
IF(ENABLE_USRP1)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/../firmware/fx2/common)
LIBUHD_APPEND_SOURCES(
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/clock_ctrl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/clock_ctrl.hpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/codec_ctrl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/codec_ctrl.hpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/codec_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/dboard_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/dboard_iface.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/dsp_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/io_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/mboard_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_iface.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_iface.hpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_impl.hpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_ctrl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp1/usrp1_ctrl.hpp
+ ${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}/io_impl.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/mboard_impl.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/usrp1_iface.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/usrp1_iface.hpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/usrp1_impl.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/usrp1_impl.hpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/usrp1_ctrl.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/usrp1_ctrl.hpp
)
ENDIF(ENABLE_USRP1)
diff --git a/host/lib/usrp/usrp1/dsp_impl.cpp b/host/lib/usrp/usrp1/dsp_impl.cpp
index e9a5e60a6..370f4831f 100644
--- a/host/lib/usrp/usrp1/dsp_impl.cpp
+++ b/host/lib/usrp/usrp1/dsp_impl.cpp
@@ -102,7 +102,7 @@ void usrp1_impl::rx_dsp_set(const wax::obj &key_, const wax::obj &val){
("0", FR_RX_FREQ_0) ("1", FR_RX_FREQ_1)
("2", FR_RX_FREQ_2) ("3", FR_RX_FREQ_3)
;
- _iface->poke32(freq_name_to_reg_val[key.name], reg_word);
+ _iface->poke32(freq_name_to_reg_val[key.name], ~reg_word + 1);
_rx_dsp_freqs[key.name] = new_freq;
return;
}
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;
diff --git a/host/lib/usrp/usrp_e100/CMakeLists.txt b/host/lib/usrp/usrp_e100/CMakeLists.txt
index 3c5c58ee0..5d8a9791d 100644
--- a/host/lib/usrp/usrp_e100/CMakeLists.txt
+++ b/host/lib/usrp/usrp_e100/CMakeLists.txt
@@ -15,33 +15,35 @@
# 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 USRP-E100 support
########################################################################
-LIBUHD_REGISTER_COMPONENT("USRP-E100" ENABLE_USRP_E100 FALSE)
+LIBUHD_REGISTER_COMPONENT("USRP-E100" ENABLE_USRP_E100 OFF "ENABLE_LIBUHD" ON)
IF(ENABLE_USRP_E100)
- INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/include)
+ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
LIBUHD_APPEND_SOURCES(
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/clock_ctrl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/clock_ctrl.hpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/codec_ctrl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/codec_ctrl.hpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/codec_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/dboard_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/dboard_iface.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/dsp_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/fpga-downloader.cc
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/io_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/mboard_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/usrp_e100_impl.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/usrp_e100_impl.hpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/usrp_e100_iface.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/usrp_e100_iface.hpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/usrp_e100_mmap_zero_copy.cpp
- ${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/usrp_e100_regs.hpp
+ ${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}/fpga-downloader.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/io_impl.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/mboard_impl.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/usrp_e100_impl.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/usrp_e100_impl.hpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/usrp_e100_iface.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/usrp_e100_iface.hpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/usrp_e100_mmap_zero_copy.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/usrp_e100_regs.hpp
)
ENDIF(ENABLE_USRP_E100)