aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/UHDDevice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Transceiver52M/UHDDevice.cpp')
-rw-r--r--Transceiver52M/UHDDevice.cpp78
1 files changed, 46 insertions, 32 deletions
diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp
index 70ad66e..5874edc 100644
--- a/Transceiver52M/UHDDevice.cpp
+++ b/Transceiver52M/UHDDevice.cpp
@@ -32,10 +32,16 @@
#include "config.h"
#endif
-#define U1_DEFAULT_CLK_RT 64e6
-#define U2_DEFAULT_CLK_RT 100e6
#define NUM_TX_CHANS 2
#define TX_CHAN_OFFSET 2e6
+#define B100_CLK_RT 52e6
+
+enum uhd_dev_type {
+ USRP1,
+ USRP2,
+ B100,
+ NUM_USRP_TYPES,
+};
/*
master_clk_rt - Master clock frequency - ignored if host resampling is
@@ -160,7 +166,7 @@ public:
bool stop();
void restart(uhd::time_spec_t ts);
void setPriority();
- enum busType getBus() { return bus; }
+ enum TxWindowType getWindowType() { return tx_window; }
int readSamples(short *buf, int len, bool *overrun,
TIMESTAMP timestamp, bool *underrun, unsigned *RSSI);
@@ -214,7 +220,8 @@ private:
uhd::usrp::multi_usrp::sptr usrp_dev;
uhd::tx_streamer::sptr tx_stream;
uhd::rx_streamer::sptr rx_stream;
- enum busType bus;
+ enum TxWindowType tx_window;
+ enum uhd_dev_type dev_type;
double desired_smpl_rt, actual_smpl_rt;
@@ -237,7 +244,8 @@ private:
void init_gains();
void set_ref_clk(bool ext_clk);
- double set_rates(double rate);
+ int set_master_clk(double rate);
+ int set_rates(double rate);
bool parse_dev_type();
bool flush_recv(size_t num_pkts);
int check_rx_md_err(uhd::rx_metadata_t &md, ssize_t num_smpls);
@@ -326,45 +334,46 @@ void uhd_device::set_ref_clk(bool ext_clk)
return;
}
-double uhd_device::set_rates(double rate)
+int uhd_device::set_master_clk(double clk_rate)
{
- double actual_rt, actual_clk_rt;
-
-#ifndef RESAMPLE
- // Make sure we can set the master clock rate on this device
- actual_clk_rt = usrp_dev->get_master_clock_rate();
- if (actual_clk_rt > U1_DEFAULT_CLK_RT) {
- LOG(ALERT) << "Cannot set clock rate on this device";
- LOG(ALERT) << "Please compile with host resampling support";
- return -1.0;
- }
+ double actual_clk_rt;
// Set master clock rate
- usrp_dev->set_master_clock_rate(master_clk_rt);
+ usrp_dev->set_master_clock_rate(clk_rate);
actual_clk_rt = usrp_dev->get_master_clock_rate();
- if (actual_clk_rt != master_clk_rt) {
+ if (actual_clk_rt != clk_rate) {
LOG(ALERT) << "Failed to set master clock rate";
LOG(ALERT) << "Actual clock rate " << actual_clk_rt;
- return -1.0;
+ return -1;
+ }
+
+ return 0;
+}
+
+int uhd_device::set_rates(double rate)
+{
+ // B100 is the only device where we set FPGA clocking
+ if (dev_type == B100) {
+ if (set_master_clk(B100_CLK_RT) < 0)
+ return -1;
}
-#endif
// Set sample rates
usrp_dev->set_tx_rate(rate);
usrp_dev->set_rx_rate(rate);
- actual_rt = usrp_dev->get_tx_rate();
+ actual_smpl_rt = usrp_dev->get_tx_rate();
- if (actual_rt != rate) {
+ if (actual_smpl_rt != rate) {
LOG(ALERT) << "Actual sample rate differs from desired rate";
- return -1.0;
+ return -1;
}
- if (usrp_dev->get_rx_rate() != actual_rt) {
+ if (usrp_dev->get_rx_rate() != actual_smpl_rt) {
LOG(ALERT) << "Transmit and receive sample rates do not match";
return -1.0;
}
- return actual_rt;
+ return 0;
}
double uhd_device::setTxGain(double db)
@@ -410,7 +419,7 @@ std::string uhd_device::getRxAntenna()
/*
Parse the UHD device tree and mboard name to find out what device we're
- dealing with. We need the bus type so that the transceiver knows how to
+ dealing with. We need the window type so that the transceiver knows how to
deal with the transport latency. Reject the USRP1 because UHD doesn't
support timestamped samples with it.
*/
@@ -431,17 +440,23 @@ bool uhd_device::parse_dev_type()
if (usrp1_str != std::string::npos) {
LOG(ALERT) << "USRP1 is not supported using the UHD driver";
LOG(ALERT) << "Please compile with GNU Radio libusrp support";
+ dev_type = USRP1;
return false;
}
if ((b100_str1 != std::string::npos) || (b100_str2 != std::string::npos)) {
- bus = USB;
- LOG(INFO) << "Using USB bus for " << dev_str;
+ tx_window = TX_WINDOW_USRP1;
+ LOG(INFO) << "Using USRP1 type transmit window for "
+ << dev_str << " " << mboard_str;
+ dev_type = B100;
+ return true;
} else {
- bus = NET;
- LOG(INFO) << "Using network bus for " << dev_str;
+ dev_type = USRP2;
}
+ tx_window = TX_WINDOW_FIXED;
+ LOG(INFO) << "Using fixed transmit window for "
+ << dev_str << " " << mboard_str;
return true;
}
@@ -492,8 +507,7 @@ bool uhd_device::open(const std::string &args)
rx_spp = rx_stream->get_max_num_samps();
// Set rates
- actual_smpl_rt = set_rates(desired_smpl_rt);
- if (actual_smpl_rt < 0)
+ if (set_rates(desired_smpl_rt) < 0)
return false;
// Create receive buffer