summaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib')
-rwxr-xr-xhost/lib/transport/gen_vrt_if_packet.py6
-rw-r--r--host/lib/transport/udp_zero_copy_asio.cpp3
-rw-r--r--host/lib/transport/vrt_packet_handler.hpp6
-rw-r--r--host/lib/types.cpp19
-rw-r--r--host/lib/usrp/dboard/db_basic_and_lf.cpp32
-rw-r--r--host/lib/usrp/dboard/db_rfx.cpp24
-rw-r--r--host/lib/usrp/dboard/db_unknown.cpp24
-rw-r--r--host/lib/usrp/dboard/db_wbx.cpp27
-rw-r--r--host/lib/usrp/dboard/db_xcvr2450.cpp24
-rw-r--r--host/lib/usrp/dsp_utils.hpp46
-rw-r--r--host/lib/usrp/mimo_usrp.cpp25
-rw-r--r--host/lib/usrp/simple_usrp.cpp25
-rw-r--r--host/lib/usrp/tune_helper.cpp81
-rw-r--r--host/lib/usrp/usrp2/dboard_impl.cpp5
14 files changed, 158 insertions, 189 deletions
diff --git a/host/lib/transport/gen_vrt_if_packet.py b/host/lib/transport/gen_vrt_if_packet.py
index 7438f5ff4..dbe026ba3 100755
--- a/host/lib/transport/gen_vrt_if_packet.py
+++ b/host/lib/transport/gen_vrt_if_packet.py
@@ -141,11 +141,17 @@ void vrt::if_hdr_unpack_$(suffix)(
){
//extract vrt header
boost::uint32_t vrt_hdr_word = $(XE_MACRO)(packet_buff[0]);
+ /*
size_t packet_words32 = vrt_hdr_word & 0xffff;
//failure case
if (if_packet_info.num_packet_words32 < packet_words32)
throw std::runtime_error("bad vrt header or packet fragment");
+ */
+ //Fix for short packets sent from the fpga:
+ // Use the num_packet_words32 passed in as input,
+ // and do not use the header bits which could be wrong.
+ size_t packet_words32 = if_packet_info.num_packet_words32;
//extract fields from the header
if_packet_info.packet_type = if_packet_info_t::packet_type_t(vrt_hdr_word >> 29);
diff --git a/host/lib/transport/udp_zero_copy_asio.cpp b/host/lib/transport/udp_zero_copy_asio.cpp
index 98451f188..bfbcf62d8 100644
--- a/host/lib/transport/udp_zero_copy_asio.cpp
+++ b/host/lib/transport/udp_zero_copy_asio.cpp
@@ -161,10 +161,13 @@ template<typename Opt> static void resize_buff_helper(
) % name % MIN_SOCK_BUFF_SIZE << std::endl;
}
+ //only enable on platforms that are happy with the large buffer resize
+ #if defined(UHD_PLATFORM_LINUX) || defined(UHD_PLATFORM_WIN32)
//otherwise, ensure that the buffer is at least the minimum size
else if (udp_trans->get_buff_size<Opt>() < MIN_SOCK_BUFF_SIZE){
resize_buff_helper<Opt>(udp_trans, MIN_SOCK_BUFF_SIZE, name);
}
+ #endif /*defined(UHD_PLATFORM_LINUX) || defined(UHD_PLATFORM_WIN32)*/
}
udp_zero_copy::sptr udp_zero_copy::make(
diff --git a/host/lib/transport/vrt_packet_handler.hpp b/host/lib/transport/vrt_packet_handler.hpp
index 6623957ac..bd76cbb8f 100644
--- a/host/lib/transport/vrt_packet_handler.hpp
+++ b/host/lib/transport/vrt_packet_handler.hpp
@@ -146,6 +146,8 @@ namespace vrt_packet_handler{
const handle_overrun_t &handle_overrun,
size_t vrt_header_offset_words32
){
+ metadata.error_code = uhd::rx_metadata_t::ERROR_CODE_NONE;
+
//perform a receive if no rx data is waiting to be copied
if (state.size_of_copy_buffs == 0){
state.fragment_offset_in_samps = 0;
@@ -171,7 +173,6 @@ namespace vrt_packet_handler{
metadata.has_time_spec = false;
metadata.start_of_burst = false;
metadata.end_of_burst = false;
- metadata.error_code = uhd::rx_metadata_t::ERROR_CODE_NONE;
}
//extract the number of samples available to copy
@@ -323,7 +324,8 @@ namespace vrt_packet_handler{
);
//commit the samples to the zero-copy interface
- if (send_buffs[i]->commit(if_packet_info.num_packet_words32*sizeof(boost::uint32_t)) < ssize_t(num_samps)){
+ size_t num_bytes_total = (vrt_header_offset_words32+if_packet_info.num_packet_words32)*sizeof(boost::uint32_t);
+ if (send_buffs[i]->commit(num_bytes_total) < ssize_t(num_bytes_total)){
std::cerr << "commit to send buffer returned less than commit size" << std::endl;
}
}
diff --git a/host/lib/types.cpp b/host/lib/types.cpp
index e0ce61058..fdc435fef 100644
--- a/host/lib/types.cpp
+++ b/host/lib/types.cpp
@@ -60,14 +60,17 @@ freq_range_t::freq_range_t(double min, double max):
/***********************************************************************
* tune result
**********************************************************************/
-tune_result_t::tune_result_t(void):
- target_inter_freq(0.0),
- actual_inter_freq(0.0),
- target_dsp_freq(0.0),
- actual_dsp_freq(0.0),
- spectrum_inverted(false)
-{
- /* NOP */
+std::string tune_result_t::to_pp_string(void) const{
+ return str(boost::format(
+ "Tune Result:\n"
+ " Target Intermediate Freq: %f (MHz)\n"
+ " Actual Intermediate Freq: %f (MHz)\n"
+ " Target DSP Freq Shift: %f (MHz)\n"
+ " Actual DSP Freq Shift: %f (MHz)\n"
+ )
+ % (target_inter_freq/1e6) % (actual_inter_freq/1e6)
+ % (target_dsp_freq/1e6) % (actual_dsp_freq/1e6)
+ );
}
/***********************************************************************
diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp
index 766deac78..9180828d8 100644
--- a/host/lib/usrp/dboard/db_basic_and_lf.cpp
+++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp
@@ -16,6 +16,7 @@
//
#include <uhd/usrp/subdev_props.hpp>
+#include <uhd/types/dict.hpp>
#include <uhd/types/ranges.hpp>
#include <uhd/utils/assert.hpp>
#include <uhd/utils/static.hpp>
@@ -138,17 +139,14 @@ void basic_rx::rx_get(const wax::obj &key_, wax::obj &val){
val = prop_names_t(1, ""); //vector of 1 empty string
return;
- case SUBDEV_PROP_QUADRATURE:
- val = (get_subdev_name() == "AB"); //only quadrature in ab mode
- return;
-
- case SUBDEV_PROP_IQ_SWAPPED:
- val = false;
- return;
-
- case SUBDEV_PROP_SPECTRUM_INVERTED:
- val = false;
- return;
+ case SUBDEV_PROP_CONNECTION:{
+ static const uhd::dict<std::string, subdev_conn_t> name_to_conn = map_list_of
+ ("A", SUBDEV_CONN_REAL_I)
+ ("B", SUBDEV_CONN_REAL_Q)
+ ("AB", SUBDEV_CONN_COMPLEX_IQ)
+ ;
+ val = name_to_conn[get_subdev_name()];
+ } return;
case SUBDEV_PROP_USE_LO_OFFSET:
val = false;
@@ -237,16 +235,8 @@ void basic_tx::tx_get(const wax::obj &key_, wax::obj &val){
val = prop_names_t(1, ""); //vector of 1 empty string
return;
- case SUBDEV_PROP_QUADRATURE:
- val = true;
- return;
-
- case SUBDEV_PROP_IQ_SWAPPED:
- val = false;
- return;
-
- case SUBDEV_PROP_SPECTRUM_INVERTED:
- val = false;
+ case SUBDEV_PROP_CONNECTION:
+ val = SUBDEV_CONN_COMPLEX_IQ;
return;
case SUBDEV_PROP_USE_LO_OFFSET:
diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp
index 2d6088983..914ca5e19 100644
--- a/host/lib/usrp/dboard/db_rfx.cpp
+++ b/host/lib/usrp/dboard/db_rfx.cpp
@@ -426,16 +426,8 @@ void rfx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){
val = rfx_rx_antennas;
return;
- case SUBDEV_PROP_QUADRATURE:
- val = true;
- return;
-
- case SUBDEV_PROP_IQ_SWAPPED:
- val = true;
- return;
-
- case SUBDEV_PROP_SPECTRUM_INVERTED:
- val = false;
+ case SUBDEV_PROP_CONNECTION:
+ val = SUBDEV_CONN_COMPLEX_QI;
return;
case SUBDEV_PROP_USE_LO_OFFSET:
@@ -516,16 +508,8 @@ void rfx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){
val = rfx_tx_antennas;
return;
- case SUBDEV_PROP_QUADRATURE:
- val = true;
- return;
-
- case SUBDEV_PROP_IQ_SWAPPED:
- val = false;
- return;
-
- case SUBDEV_PROP_SPECTRUM_INVERTED:
- val = false;
+ case SUBDEV_PROP_CONNECTION:
+ val = SUBDEV_CONN_COMPLEX_IQ;
return;
case SUBDEV_PROP_USE_LO_OFFSET:
diff --git a/host/lib/usrp/dboard/db_unknown.cpp b/host/lib/usrp/dboard/db_unknown.cpp
index ced27e34d..9dd9b550b 100644
--- a/host/lib/usrp/dboard/db_unknown.cpp
+++ b/host/lib/usrp/dboard/db_unknown.cpp
@@ -119,16 +119,8 @@ void unknown_rx::rx_get(const wax::obj &key_, wax::obj &val){
val = prop_names_t(1, ""); //vector of 1 empty string
return;
- case SUBDEV_PROP_QUADRATURE:
- val = false;
- return;
-
- case SUBDEV_PROP_IQ_SWAPPED:
- val = false;
- return;
-
- case SUBDEV_PROP_SPECTRUM_INVERTED:
- val = false;
+ case SUBDEV_PROP_CONNECTION:
+ val = SUBDEV_CONN_COMPLEX_IQ;
return;
case SUBDEV_PROP_USE_LO_OFFSET:
@@ -218,16 +210,8 @@ void unknown_tx::tx_get(const wax::obj &key_, wax::obj &val){
val = prop_names_t(1, ""); //vector of 1 empty string
return;
- case SUBDEV_PROP_QUADRATURE:
- val = true;
- return;
-
- case SUBDEV_PROP_IQ_SWAPPED:
- val = false;
- return;
-
- case SUBDEV_PROP_SPECTRUM_INVERTED:
- val = false;
+ case SUBDEV_PROP_CONNECTION:
+ val = SUBDEV_CONN_COMPLEX_IQ;
return;
case SUBDEV_PROP_USE_LO_OFFSET:
diff --git a/host/lib/usrp/dboard/db_wbx.cpp b/host/lib/usrp/dboard/db_wbx.cpp
index 2b2822b6b..3038ce30b 100644
--- a/host/lib/usrp/dboard/db_wbx.cpp
+++ b/host/lib/usrp/dboard/db_wbx.cpp
@@ -86,7 +86,7 @@ using namespace boost::assign;
**********************************************************************/
static const bool wbx_debug = false;
-static const freq_range_t wbx_freq_range(50e6, 2.22e9);
+static const freq_range_t wbx_freq_range(68.75e6, 2.2e9);
static const prop_names_t wbx_tx_antennas = list_of("TX/RX");
@@ -439,6 +439,7 @@ double wbx_xcvr::set_lo_freq(
regs.reference_divide_by_2 = T;
regs.reference_doubler = D;
regs.band_select_clock_div = BS;
+ UHD_ASSERT_THROW(rfdivsel_to_enum.has_key(RFdiv));
regs.rf_divider_select = rfdivsel_to_enum[RFdiv];
//write the registers
@@ -509,16 +510,8 @@ void wbx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){
val = wbx_rx_antennas;
return;
- case SUBDEV_PROP_QUADRATURE:
- val = true;
- return;
-
- case SUBDEV_PROP_IQ_SWAPPED:
- val = false;
- return;
-
- case SUBDEV_PROP_SPECTRUM_INVERTED:
- val = false;
+ case SUBDEV_PROP_CONNECTION:
+ val = SUBDEV_CONN_COMPLEX_IQ;
return;
case SUBDEV_PROP_USE_LO_OFFSET:
@@ -603,16 +596,8 @@ void wbx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){
val = wbx_tx_antennas;
return;
- case SUBDEV_PROP_QUADRATURE:
- val = true;
- return;
-
- case SUBDEV_PROP_IQ_SWAPPED:
- val = false;
- return;
-
- case SUBDEV_PROP_SPECTRUM_INVERTED:
- val = false;
+ case SUBDEV_PROP_CONNECTION:
+ val = SUBDEV_CONN_COMPLEX_IQ;
return;
case SUBDEV_PROP_USE_LO_OFFSET:
diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp
index 5032b6f31..2c94bcd2d 100644
--- a/host/lib/usrp/dboard/db_xcvr2450.cpp
+++ b/host/lib/usrp/dboard/db_xcvr2450.cpp
@@ -481,16 +481,8 @@ void xcvr2450::rx_get(const wax::obj &key_, wax::obj &val){
val = xcvr_antennas;
return;
- case SUBDEV_PROP_QUADRATURE:
- val = true;
- return;
-
- case SUBDEV_PROP_IQ_SWAPPED:
- val = false;
- return;
-
- case SUBDEV_PROP_SPECTRUM_INVERTED:
- val = false;
+ case SUBDEV_PROP_CONNECTION:
+ val = SUBDEV_CONN_COMPLEX_IQ;
return;
case SUBDEV_PROP_USE_LO_OFFSET:
@@ -579,16 +571,8 @@ void xcvr2450::tx_get(const wax::obj &key_, wax::obj &val){
val = xcvr_antennas;
return;
- case SUBDEV_PROP_QUADRATURE:
- val = true;
- return;
-
- case SUBDEV_PROP_IQ_SWAPPED:
- val = true;
- return;
-
- case SUBDEV_PROP_SPECTRUM_INVERTED:
- val = false;
+ case SUBDEV_PROP_CONNECTION:
+ val = SUBDEV_CONN_COMPLEX_QI;
return;
case SUBDEV_PROP_USE_LO_OFFSET:
diff --git a/host/lib/usrp/dsp_utils.hpp b/host/lib/usrp/dsp_utils.hpp
index 3fd5f1811..2f246c788 100644
--- a/host/lib/usrp/dsp_utils.hpp
+++ b/host/lib/usrp/dsp_utils.hpp
@@ -22,6 +22,7 @@
#include <uhd/types/dict.hpp>
#include <uhd/utils/assert.hpp>
#include <uhd/types/stream_cmd.hpp>
+#include <uhd/usrp/subdev_props.hpp>
#include <boost/cstdint.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/tuple/tuple.hpp>
@@ -37,37 +38,36 @@ namespace dsp_type1{
/*!
* Calculate the rx mux word from properties.
- * \param is_quadrature true if the subdev is complex
- * \param is_iq_swapped true if the i and q are reversed
+ * \param subdev_conn the subdev connection type
* \param the 32-bit rx mux control word
*/
static inline boost::uint32_t calc_rx_mux_word(
- bool is_quadrature,
- bool is_iq_swapped
+ subdev_conn_t subdev_conn
){
- boost::uint32_t rx_mux = 0;
- if (is_quadrature){
- rx_mux = (0x01 << 2) | (0x00 << 0); //Q=ADC1, I=ADC0
- }else{
- rx_mux = (0x11 << 2) | (0x00 << 0); //Q=ZERO, I=ADC0
+ switch(subdev_conn){
+ case SUBDEV_CONN_COMPLEX_IQ: return (0x1 << 2) | (0x0 << 0); //DDC0Q=ADC1, DDC0I=ADC0
+ case SUBDEV_CONN_COMPLEX_QI: return (0x0 << 2) | (0x1 << 0); //DDC0Q=ADC0, DDC0I=ADC1
+ case SUBDEV_CONN_REAL_I: return (0x3 << 2) | (0x0 << 0); //DDC0Q=ZERO, DDC0I=ADC0
+ case SUBDEV_CONN_REAL_Q: return (0x1 << 2) | (0x3 << 0); //DDC0Q=ADC1, DDC0I=ZERO
+ default: UHD_THROW_INVALID_CODE_PATH();
}
- if (is_iq_swapped){
- rx_mux = (rx_mux << 2) | (rx_mux >> 2);
- }
- return rx_mux;
}
/*!
* Calculate the tx mux word from properties.
- * \param is_iq_swapped true if the i and q are reversed
+ * \param subdev_conn the subdev connection type
* \param the 32-bit tx mux control word
*/
- static inline boost::uint32_t calc_tx_mux_word(bool is_iq_swapped){
- boost::uint32_t tx_mux = 0x10;
- if (is_iq_swapped){
- tx_mux = (tx_mux << 4) | (tx_mux >> 4);
+ static inline boost::uint32_t calc_tx_mux_word(
+ subdev_conn_t subdev_conn
+ ){
+ switch(subdev_conn){
+ case SUBDEV_CONN_COMPLEX_IQ: return (0x1 << 4) | (0x0 << 0); //DAC1=DUC0Q, DAC0=DUC0I
+ case SUBDEV_CONN_COMPLEX_QI: return (0x0 << 4) | (0x1 << 0); //DAC1=DUC0I, DAC0=DUC0Q
+ case SUBDEV_CONN_REAL_I: return (0xf << 4) | (0x0 << 0); //DAC1=ZERO, DAC0=DUC0I
+ case SUBDEV_CONN_REAL_Q: return (0x0 << 4) | (0xf << 0); //DAC1=DUC0I, DAC0=ZERO
+ default: UHD_THROW_INVALID_CODE_PATH();
}
- return tx_mux;
}
/*!
@@ -82,16 +82,16 @@ namespace dsp_type1{
double &freq,
double codec_rate
){
- UHD_ASSERT_THROW(std::abs(freq) < codec_rate/2.0);
+ UHD_ASSERT_THROW(freq >= -codec_rate/2.0 and freq < codec_rate/2.0);
static const double scale_factor = std::pow(2.0, 32);
- //calculate the freq register word
- boost::uint32_t freq_word = boost::math::iround((freq / codec_rate) * scale_factor);
+ //calculate the freq register word (signed)
+ boost::int32_t freq_word = boost::math::iround((freq / codec_rate) * scale_factor);
//update the actual frequency
freq = (double(freq_word) / scale_factor) * codec_rate;
- return freq_word;
+ return boost::uint32_t(freq_word);
}
/*!
diff --git a/host/lib/usrp/mimo_usrp.cpp b/host/lib/usrp/mimo_usrp.cpp
index b40f98226..ec0f1dcc8 100644
--- a/host/lib/usrp/mimo_usrp.cpp
+++ b/host/lib/usrp/mimo_usrp.cpp
@@ -33,6 +33,11 @@
using namespace uhd;
using namespace uhd::usrp;
+static inline freq_range_t add_dsp_shift(const freq_range_t &range, wax::obj dsp){
+ double codec_rate = dsp[DSP_PROP_CODEC_RATE].as<double>();
+ return freq_range_t(range.min - codec_rate/2.0, range.max + codec_rate/2.0);
+}
+
/***********************************************************************
* MIMO USRP Implementation
**********************************************************************/
@@ -180,15 +185,19 @@ public:
}
tune_result_t set_rx_freq(size_t chan, double target_freq){
- return tune_rx_subdev_and_ddc(_rx_subdevs.at(chan), _rx_dsps.at(chan), target_freq);
+ return tune_rx_subdev_and_dsp(_rx_subdevs.at(chan), _rx_dsps.at(chan), target_freq);
}
tune_result_t set_rx_freq(size_t chan, double target_freq, double lo_off){
- return tune_rx_subdev_and_ddc(_rx_subdevs.at(chan), _rx_dsps.at(chan), target_freq, lo_off);
+ return tune_rx_subdev_and_dsp(_rx_subdevs.at(chan), _rx_dsps.at(chan), target_freq, lo_off);
+ }
+
+ double get_rx_freq(size_t chan){
+ return derive_freq_from_rx_subdev_and_dsp(_rx_subdevs.at(chan), _rx_dsps.at(chan));
}
freq_range_t get_rx_freq_range(size_t chan){
- return _rx_subdevs.at(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>();
+ return add_dsp_shift(_rx_subdevs.at(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _rx_dsps.at(chan));
}
void set_rx_gain(size_t chan, float gain){
@@ -243,15 +252,19 @@ public:
}
tune_result_t set_tx_freq(size_t chan, double target_freq){
- return tune_tx_subdev_and_duc(_tx_subdevs.at(chan), _tx_dsps.at(chan), target_freq);
+ return tune_tx_subdev_and_dsp(_tx_subdevs.at(chan), _tx_dsps.at(chan), target_freq);
}
tune_result_t set_tx_freq(size_t chan, double target_freq, double lo_off){
- return tune_tx_subdev_and_duc(_tx_subdevs.at(chan), _tx_dsps.at(chan), target_freq, lo_off);
+ return tune_tx_subdev_and_dsp(_tx_subdevs.at(chan), _tx_dsps.at(chan), target_freq, lo_off);
+ }
+
+ double get_tx_freq(size_t chan){
+ return derive_freq_from_tx_subdev_and_dsp(_tx_subdevs.at(chan), _tx_dsps.at(chan));
}
freq_range_t get_tx_freq_range(size_t chan){
- return _tx_subdevs.at(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>();
+ return add_dsp_shift(_tx_subdevs.at(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _tx_dsps.at(chan));
}
void set_tx_gain(size_t chan, float gain){
diff --git a/host/lib/usrp/simple_usrp.cpp b/host/lib/usrp/simple_usrp.cpp
index 56e82d7ee..5cb9511f4 100644
--- a/host/lib/usrp/simple_usrp.cpp
+++ b/host/lib/usrp/simple_usrp.cpp
@@ -30,6 +30,11 @@
using namespace uhd;
using namespace uhd::usrp;
+static inline freq_range_t add_dsp_shift(const freq_range_t &range, wax::obj dsp){
+ double codec_rate = dsp[DSP_PROP_CODEC_RATE].as<double>();
+ return freq_range_t(range.min - codec_rate/2.0, range.max + codec_rate/2.0);
+}
+
/***********************************************************************
* Simple USRP Implementation
**********************************************************************/
@@ -118,15 +123,19 @@ public:
}
tune_result_t set_rx_freq(double target_freq){
- return tune_rx_subdev_and_ddc(_rx_subdev, _rx_dsp, target_freq);
+ return tune_rx_subdev_and_dsp(_rx_subdev, _rx_dsp, target_freq);
}
tune_result_t set_rx_freq(double target_freq, double lo_off){
- return tune_rx_subdev_and_ddc(_rx_subdev, _rx_dsp, target_freq, lo_off);
+ return tune_rx_subdev_and_dsp(_rx_subdev, _rx_dsp, target_freq, lo_off);
+ }
+
+ double get_rx_freq(void){
+ return derive_freq_from_rx_subdev_and_dsp(_rx_subdev, _rx_dsp);
}
freq_range_t get_rx_freq_range(void){
- return _rx_subdev[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>();
+ return add_dsp_shift(_rx_subdev[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _rx_dsp);
}
void set_rx_gain(float gain){
@@ -173,15 +182,19 @@ public:
}
tune_result_t set_tx_freq(double target_freq){
- return tune_tx_subdev_and_duc(_tx_subdev, _tx_dsp, target_freq);
+ return tune_tx_subdev_and_dsp(_tx_subdev, _tx_dsp, target_freq);
}
tune_result_t set_tx_freq(double target_freq, double lo_off){
- return tune_tx_subdev_and_duc(_tx_subdev, _tx_dsp, target_freq, lo_off);
+ return tune_tx_subdev_and_dsp(_tx_subdev, _tx_dsp, target_freq, lo_off);
+ }
+
+ double get_tx_freq(void){
+ return derive_freq_from_tx_subdev_and_dsp(_tx_subdev, _tx_dsp);
}
freq_range_t get_tx_freq_range(void){
- return _tx_subdev[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>();
+ return add_dsp_shift(_tx_subdev[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _tx_dsp);
}
void set_tx_gain(float gain){
diff --git a/host/lib/usrp/tune_helper.cpp b/host/lib/usrp/tune_helper.cpp
index 082c39f6d..c5cce3ecf 100644
--- a/host/lib/usrp/tune_helper.cpp
+++ b/host/lib/usrp/tune_helper.cpp
@@ -19,22 +19,21 @@
#include <uhd/utils/algorithm.hpp>
#include <uhd/usrp/subdev_props.hpp>
#include <uhd/usrp/dsp_props.hpp>
+#include <uhd/usrp/dboard_iface.hpp> //unit_t
#include <cmath>
using namespace uhd;
using namespace uhd::usrp;
/***********************************************************************
- * Tune Helper Function
+ * Tune Helper Functions
**********************************************************************/
static tune_result_t tune_xx_subdev_and_dxc(
- bool is_tx,
+ dboard_iface::unit_t unit,
wax::obj subdev, wax::obj dxc,
double target_freq, double lo_offset
){
wax::obj subdev_freq_proxy = subdev[SUBDEV_PROP_FREQ];
- bool subdev_quadrature = subdev[SUBDEV_PROP_QUADRATURE].as<bool>();
- bool subdev_spectrum_inverted = subdev[SUBDEV_PROP_SPECTRUM_INVERTED].as<bool>();
wax::obj dxc_freq_proxy = dxc[DSP_PROP_FREQ_SHIFT];
double dxc_sample_rate = dxc[DSP_PROP_CODEC_RATE].as<double>();
@@ -43,55 +42,52 @@ static tune_result_t tune_xx_subdev_and_dxc(
subdev_freq_proxy = target_inter_freq;
double actual_inter_freq = subdev_freq_proxy.as<double>();
- // Calculate the DDC setting that will downconvert the baseband from the
- // daughterboard to our target frequency.
- double delta_freq = target_freq - actual_inter_freq;
- int delta_sign = std::signum(delta_freq);
- delta_freq *= delta_sign;
- delta_freq = std::fmod(delta_freq, dxc_sample_rate);
- bool inverted = delta_freq > dxc_sample_rate/2.0;
- double target_dxc_freq = inverted? (delta_freq - dxc_sample_rate) : (-delta_freq);
- target_dxc_freq *= delta_sign;
-
- // If the spectrum is inverted, and the daughterboard doesn't do
- // quadrature downconversion, we can fix the inversion by flipping the
- // sign of the dxc_freq... (This only happens using the basic_rx board)
- if (subdev_spectrum_inverted){
- inverted = not inverted;
- }
- if (inverted and not subdev_quadrature){
- target_dxc_freq *= -1.0;
- inverted = not inverted;
- }
- // down conversion versus up conversion, fight!
- // your mother is ugly and your going down...
- target_dxc_freq *= (is_tx)? -1.0 : +1.0;
+ //perform the correction correction for dxc rates outside of nyquist
+ double delta_freq = std::fmod(target_freq - actual_inter_freq, dxc_sample_rate);
+ bool outside_of_nyquist = std::abs(delta_freq) > dxc_sample_rate/2.0;
+ double target_dxc_freq = (outside_of_nyquist)?
+ std::signum(delta_freq)*dxc_sample_rate - delta_freq : -delta_freq;
+
+ //invert the sign on the dxc freq given the following conditions
+ if (unit == dboard_iface::UNIT_TX) target_dxc_freq *= -1.0;
dxc_freq_proxy = target_dxc_freq;
double actual_dxc_freq = dxc_freq_proxy.as<double>();
- //return some kind of tune result tuple/struct
+ //load and return the tune result
tune_result_t tune_result;
tune_result.target_inter_freq = target_inter_freq;
tune_result.actual_inter_freq = actual_inter_freq;
tune_result.target_dsp_freq = target_dxc_freq;
tune_result.actual_dsp_freq = actual_dxc_freq;
- tune_result.spectrum_inverted = inverted;
return tune_result;
}
+static double derive_freq_from_xx_subdev_and_dxc(
+ dboard_iface::unit_t unit,
+ wax::obj subdev, wax::obj dxc
+){
+ //extract actual dsp and IF frequencies
+ double actual_inter_freq = subdev[SUBDEV_PROP_FREQ].as<double>();
+ double actual_dxc_freq = dxc[DSP_PROP_FREQ_SHIFT].as<double>();
+
+ //invert the sign on the dxc freq given the following conditions
+ if (unit == dboard_iface::UNIT_TX) actual_dxc_freq *= -1.0;
+
+ return actual_inter_freq - actual_dxc_freq;
+}
+
/***********************************************************************
* RX Tune
**********************************************************************/
-tune_result_t uhd::usrp::tune_rx_subdev_and_ddc(
+tune_result_t usrp::tune_rx_subdev_and_dsp(
wax::obj subdev, wax::obj ddc,
double target_freq, double lo_offset
){
- bool is_tx = false;
- return tune_xx_subdev_and_dxc(is_tx, subdev, ddc, target_freq, lo_offset);
+ return tune_xx_subdev_and_dxc(dboard_iface::UNIT_RX, subdev, ddc, target_freq, lo_offset);
}
-tune_result_t uhd::usrp::tune_rx_subdev_and_ddc(
+tune_result_t usrp::tune_rx_subdev_and_dsp(
wax::obj subdev, wax::obj ddc,
double target_freq
){
@@ -100,21 +96,24 @@ tune_result_t uhd::usrp::tune_rx_subdev_and_ddc(
if (subdev[SUBDEV_PROP_USE_LO_OFFSET].as<bool>()){
lo_offset = 2.0*ddc[DSP_PROP_HOST_RATE].as<double>();
}
- return tune_rx_subdev_and_ddc(subdev, ddc, target_freq, lo_offset);
+ return tune_rx_subdev_and_dsp(subdev, ddc, target_freq, lo_offset);
+}
+
+double usrp::derive_freq_from_rx_subdev_and_dsp(wax::obj subdev, wax::obj ddc){
+ return derive_freq_from_xx_subdev_and_dxc(dboard_iface::UNIT_RX, subdev, ddc);
}
/***********************************************************************
* TX Tune
**********************************************************************/
-tune_result_t uhd::usrp::tune_tx_subdev_and_duc(
+tune_result_t usrp::tune_tx_subdev_and_dsp(
wax::obj subdev, wax::obj duc,
double target_freq, double lo_offset
){
- bool is_tx = true;
- return tune_xx_subdev_and_dxc(is_tx, subdev, duc, target_freq, lo_offset);
+ return tune_xx_subdev_and_dxc(dboard_iface::UNIT_TX, subdev, duc, target_freq, lo_offset);
}
-tune_result_t uhd::usrp::tune_tx_subdev_and_duc(
+tune_result_t usrp::tune_tx_subdev_and_dsp(
wax::obj subdev, wax::obj duc,
double target_freq
){
@@ -123,5 +122,9 @@ tune_result_t uhd::usrp::tune_tx_subdev_and_duc(
if (subdev[SUBDEV_PROP_USE_LO_OFFSET].as<bool>()){
lo_offset = 2.0*duc[DSP_PROP_HOST_RATE].as<double>();
}
- return tune_tx_subdev_and_duc(subdev, duc, target_freq, lo_offset);
+ return tune_tx_subdev_and_dsp(subdev, duc, target_freq, lo_offset);
+}
+
+double usrp::derive_freq_from_tx_subdev_and_dsp(wax::obj subdev, wax::obj duc){
+ return derive_freq_from_xx_subdev_and_dxc(dboard_iface::UNIT_TX, subdev, duc);
}
diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp
index fa8d1a674..8942f9d31 100644
--- a/host/lib/usrp/usrp2/dboard_impl.cpp
+++ b/host/lib/usrp/usrp2/dboard_impl.cpp
@@ -104,8 +104,7 @@ void usrp2_mboard_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val){
wax::obj rx_subdev = _dboard_manager->get_rx_subdev(_rx_subdevs_in_use.at(0));
std::cout << "Using: " << rx_subdev[SUBDEV_PROP_NAME].as<std::string>() << std::endl;
_iface->poke32(U2_REG_DSP_RX_MUX, dsp_type1::calc_rx_mux_word(
- rx_subdev[SUBDEV_PROP_QUADRATURE].as<bool>(),
- rx_subdev[SUBDEV_PROP_IQ_SWAPPED].as<bool>()
+ rx_subdev[SUBDEV_PROP_CONNECTION].as<subdev_conn_t>()
));
}
return;
@@ -164,7 +163,7 @@ void usrp2_mboard_impl::tx_dboard_set(const wax::obj &key, const wax::obj &val){
wax::obj tx_subdev = _dboard_manager->get_tx_subdev(_tx_subdevs_in_use.at(0));
std::cout << "Using: " << tx_subdev[SUBDEV_PROP_NAME].as<std::string>() << std::endl;
_iface->poke32(U2_REG_DSP_TX_MUX, dsp_type1::calc_tx_mux_word(
- tx_subdev[SUBDEV_PROP_IQ_SWAPPED].as<bool>()
+ tx_subdev[SUBDEV_PROP_CONNECTION].as<subdev_conn_t>()
));
}
return;