aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/b200
diff options
context:
space:
mode:
authorAshish Chaudhari <ashish@ettus.com>2015-07-07 17:01:10 -0700
committerAshish Chaudhari <ashish@ettus.com>2015-07-07 17:01:10 -0700
commit273fb752fb14e0ebf3b04e0729f6545a54baf2c6 (patch)
tree55a5bbb92a6be36d27cf6e9d5755dbacd2b5e114 /host/lib/usrp/b200
parenta44f791a44fc248f82da070cd6ea2405cf4532f6 (diff)
parent984575c9f1ca18c3d97ba730e20bdbe7b7614c1e (diff)
downloaduhd-273fb752fb14e0ebf3b04e0729f6545a54baf2c6.tar.gz
uhd-273fb752fb14e0ebf3b04e0729f6545a54baf2c6.tar.bz2
uhd-273fb752fb14e0ebf3b04e0729f6545a54baf2c6.zip
Merge branch 'master' into x300/rev7_support
Diffstat (limited to 'host/lib/usrp/b200')
-rw-r--r--host/lib/usrp/b200/b200_impl.cpp33
-rw-r--r--host/lib/usrp/b200/b200_impl.hpp3
-rw-r--r--host/lib/usrp/b200/b200_io_impl.cpp22
3 files changed, 28 insertions, 30 deletions
diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp
index 768fde313..abddd1747 100644
--- a/host/lib/usrp/b200/b200_impl.cpp
+++ b/host/lib/usrp/b200/b200_impl.cpp
@@ -578,8 +578,8 @@ b200_impl::b200_impl(const device_addr_t &device_addr) :
////////////////////////////////////////////////////////////////////
//init the clock rate to something reasonable
- _tree->access<double>(mb_path / "tick_rate").set(
- device_addr.cast<double>("master_clock_rate", B200_DEFAULT_TICK_RATE));
+ double default_tick_rate = device_addr.cast<double>("master_clock_rate", B200_DEFAULT_TICK_RATE);
+ _tree->access<double>(mb_path / "tick_rate").set(default_tick_rate);
//subdev spec contains full width of selections
subdev_spec_t rx_spec, tx_spec;
@@ -598,10 +598,10 @@ b200_impl::b200_impl(const device_addr_t &device_addr) :
_tree->access<std::string>(mb_path / "clock_source/value").set("internal");
_tree->access<std::string>(mb_path / "time_source/value").set("none");
- // Set default rates (can't be done in setup_radio() because tick rate is not yet set)
+ // Set the DSP chains to some safe value
for (size_t i = 0; i < _radio_perifs.size(); i++) {
- _tree->access<double>(mb_path / "rx_dsps" / str(boost::format("%u") % i)/ "rate/value").set(B200_DEFAULT_RATE);
- _tree->access<double>(mb_path / "tx_dsps" / str(boost::format("%u") % i) / "rate/value").set(B200_DEFAULT_RATE);
+ _radio_perifs[i].ddc->set_host_rate(default_tick_rate / B200_DEFAULT_DECIM);
+ _radio_perifs[i].duc->set_host_rate(default_tick_rate / B200_DEFAULT_INTERP);
}
// We can automatically choose a master clock rate, but not if the user specifies one
_tree->access<bool>(mb_path / "auto_tick_rate").set(not device_addr.has_key("master_clock_rate"));
@@ -630,7 +630,7 @@ b200_impl::~b200_impl(void)
{
UHD_SAFE_CALL
(
- _async_task.reset();
+ _async_task.reset();
)
}
@@ -667,13 +667,14 @@ void b200_impl::setup_radio(const size_t dspno)
_tree->access<double>(mb_path / "tick_rate")
.subscribe(boost::bind(&rx_vita_core_3000::set_tick_rate, perif.framer, _1))
.subscribe(boost::bind(&rx_dsp_core_3000::set_tick_rate, perif.ddc, _1));
- const fs_path rx_dsp_path = mb_path / "rx_dsps" / str(boost::format("%u") % dspno);
+ const fs_path rx_dsp_path = mb_path / "rx_dsps" / dspno;
_tree->create<meta_range_t>(rx_dsp_path / "rate" / "range")
.publish(boost::bind(&rx_dsp_core_3000::get_host_rates, perif.ddc));
_tree->create<double>(rx_dsp_path / "rate" / "value")
+ .set(0.0) // We can only load a sensible value after the tick rate was set
.coerce(boost::bind(&b200_impl::coerce_rx_samp_rate, this, perif.ddc, dspno, _1))
.subscribe(boost::bind(&b200_impl::update_rx_samp_rate, this, dspno, _1))
- .set(0.0); // Can only set this after tick rate is initialized.
+ ;
_tree->create<double>(rx_dsp_path / "freq" / "value")
.coerce(boost::bind(&rx_dsp_core_3000::set_freq, perif.ddc, _1))
.set(0.0);
@@ -691,13 +692,14 @@ void b200_impl::setup_radio(const size_t dspno)
_tree->access<double>(mb_path / "tick_rate")
.subscribe(boost::bind(&tx_vita_core_3000::set_tick_rate, perif.deframer, _1))
.subscribe(boost::bind(&tx_dsp_core_3000::set_tick_rate, perif.duc, _1));
- const fs_path tx_dsp_path = mb_path / "tx_dsps" / str(boost::format("%u") % dspno);
+ const fs_path tx_dsp_path = mb_path / "tx_dsps" / dspno;
_tree->create<meta_range_t>(tx_dsp_path / "rate" / "range")
.publish(boost::bind(&tx_dsp_core_3000::get_host_rates, perif.duc));
_tree->create<double>(tx_dsp_path / "rate" / "value")
+ .set(0.0) // We can only load a sensible value after the tick rate was set
.coerce(boost::bind(&b200_impl::coerce_tx_samp_rate, this, perif.duc, dspno, _1))
.subscribe(boost::bind(&b200_impl::update_tx_samp_rate, this, dspno, _1))
- .set(0.0); // Can only set this after tick rate is initialized.
+ ;
_tree->create<double>(tx_dsp_path / "freq" / "value")
.coerce(boost::bind(&tx_dsp_core_3000::set_freq, perif.duc, _1))
.set(0.0);
@@ -823,7 +825,6 @@ void b200_impl::register_loopback_self_test(wb_iface::sptr iface)
void b200_impl::codec_loopback_self_test(wb_iface::sptr iface)
{
- bool test_fail = false;
UHD_MSG(status) << "Performing CODEC loopback test... " << std::flush;
size_t hash = size_t(time(NULL));
for (size_t i = 0; i < 100; i++)
@@ -835,11 +836,13 @@ void b200_impl::codec_loopback_self_test(wb_iface::sptr iface)
const boost::uint64_t rb_word64 = iface->peek64(RB64_CODEC_READBACK);
const boost::uint32_t rb_tx = boost::uint32_t(rb_word64 >> 32);
const boost::uint32_t rb_rx = boost::uint32_t(rb_word64 & 0xffffffff);
- test_fail = word32 != rb_tx or word32 != rb_rx;
- if (test_fail) break; //exit loop on any failure
+ bool test_fail = word32 != rb_tx or word32 != rb_rx;
+ if (test_fail) {
+ UHD_MSG(status) << "fail" << std::endl;
+ throw uhd::runtime_error("CODEC loopback test failed.");
+ }
}
- UHD_MSG(status) << ((test_fail)? "fail" : "pass") << std::endl;
-
+ UHD_MSG(status) << "pass" << std::endl;
/* Zero out the idle data. */
iface->poke32(TOREG(SR_CODEC_IDLE), 0);
}
diff --git a/host/lib/usrp/b200/b200_impl.hpp b/host/lib/usrp/b200/b200_impl.hpp
index 2491b36ad..57c68be71 100644
--- a/host/lib/usrp/b200/b200_impl.hpp
+++ b/host/lib/usrp/b200/b200_impl.hpp
@@ -51,7 +51,8 @@ static const boost::uint16_t B200_FPGA_COMPAT_NUM = 7;
static const double B200_BUS_CLOCK_RATE = 100e6;
static const double B200_DEFAULT_TICK_RATE = 32e6;
static const double B200_DEFAULT_FREQ = 100e6; // Hz
-static const double B200_DEFAULT_RATE = 250e3; // Sps
+static const double B200_DEFAULT_DECIM = 128;
+static const double B200_DEFAULT_INTERP = 128;
static const double B200_DEFAULT_RX_GAIN = 0; // dB
static const double B200_DEFAULT_TX_GAIN = 0; // dB
static const boost::uint32_t B200_GPSDO_ST_NONE = 0x83;
diff --git a/host/lib/usrp/b200/b200_io_impl.cpp b/host/lib/usrp/b200/b200_io_impl.cpp
index 3171e25c3..c4e04f70a 100644
--- a/host/lib/usrp/b200/b200_io_impl.cpp
+++ b/host/lib/usrp/b200/b200_io_impl.cpp
@@ -111,16 +111,9 @@ void b200_impl::set_auto_tick_rate(
% (this_dsp_rate / 1e6) % (max_tick_rate / 1e6)
));
}
- // If this_dsp_rate == B200_DEFAULT_RATE, we assume the user did not actually set
- // the sampling rate. If the user *did* set the rate to
- // B200_DEFAULT_RATE on all DSPs, then this will still work (see below).
- // If the user set one DSP to B200_DEFAULT_RATE and the other to
- // a different rate, this also works if the rates are integer multiples
- // of one another. Only for certain configurations of B200_DEFAULT_RATE
- // and another rate that is not an integer multiple, this will be problematic.
- // Since this case is less common than the case where a rate is left unset,
- // we don't handle that but rather explain that corner case in the documentation.
- if (this_dsp_rate == B200_DEFAULT_RATE) {
+ // If this_dsp_rate == 0.0, the sampling rate for this DSP hasn't been set, so
+ // we don't take that into consideration.
+ if (this_dsp_rate == 0.0) {
continue;
}
lcm_rate = boost::math::lcm<boost::uint32_t>(
@@ -130,11 +123,11 @@ void b200_impl::set_auto_tick_rate(
}
}
if (lcm_rate == 1) {
- lcm_rate = static_cast<boost::uint32_t>(B200_DEFAULT_RATE);
+ // In this case, no one has ever set a sampling rate.
+ return;
}
- // Step 2: Determine whether if we can use lcm_rate (preferred),
- // or have to give up because too large:
+ // Step 2: Check if the lcm_rate is within available limits:
double base_rate = static_cast<double>(lcm_rate);
if (uhd::math::fp_compare::fp_compare_delta<double>(base_rate, uhd::math::FREQ_COMPARISON_DELTA_HZ) >
uhd::math::fp_compare::fp_compare_delta<double>(max_tick_rate, uhd::math::FREQ_COMPARISON_DELTA_HZ)) {
@@ -152,6 +145,7 @@ void b200_impl::set_auto_tick_rate(
// An equation that does all that is:
//
// f_auto = r * 2^floor(log2(f_max/r))
+ // = base_rate * multiplier
//
// where r is the base rate and f_max is the maximum tick rate. The case
// where floor() yields 1 must be caught.
@@ -173,7 +167,7 @@ void b200_impl::set_auto_tick_rate(
uhd::math::fp_compare::fp_compare_delta<double>(max_tick_rate, uhd::math::FREQ_COMPARISON_DELTA_HZ)
);
- if (_tree->access<double>("/mboards/0/tick_rate").get() != new_rate) {
+ if (!uhd::math::frequencies_are_equal(_tree->access<double>("/mboards/0/tick_rate").get(), new_rate)) {
_tree->access<double>("/mboards/0/tick_rate").set(new_rate);
}
}