aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tsou <tom@tsou.cc>2013-04-05 15:36:30 -0400
committerAlexander Chemeris <Alexander.Chemeris@gmail.com>2013-06-24 01:46:33 +0400
commit00493f1a413a743c27ff2bb11c041e63a0f0d4ce (patch)
treef4f32fd7b76c42cf234757e3dad853a57778d679
parentd565556b4b39eed6e6a01ed4c6bf85ee6ce5929c (diff)
Transceiver52M: Add UHD device type checking
UHD device type was previously detected, but only categorized in terms of bus type, USB or Ethernet, and sample rate capability. With the number of supported device increasing, we can no longer easily group devices since we need to handle more and more device-specific peculiarities. Some of these factors are managed internally by the UHD driver, but other factors (e.g. timing offsets) are specific to a single device. Start by maintaining an enumerated list of relevant device types that we can use for applying device specific operations. Also rename the USB/Ethernet grouping to transmit window type because that's what it is. enum uhd_dev_type { USRP1, USRP2, B100, NUM_USRP_TYPES, }; Signed-off-by: Thomas Tsou <tom@tsou.cc>
-rw-r--r--Transceiver52M/Transceiver.cpp2
-rw-r--r--Transceiver52M/UHDDevice.cpp78
-rw-r--r--Transceiver52M/USRPDevice.h3
-rw-r--r--Transceiver52M/radioDevice.h6
-rw-r--r--Transceiver52M/radioInterface.h4
5 files changed, 53 insertions, 40 deletions
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index 423821d..017b641 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -758,7 +758,7 @@ void Transceiver::driveTransmitFIFO()
while (radioClock->get() + mTransmitLatency > mTransmitDeadlineClock) {
// if underrun, then we're not providing bursts to radio/USRP fast
// enough. Need to increase latency by one GSM frame.
- if (mRadioInterface->getBus() == RadioDevice::USB) {
+ if (mRadioInterface->getWindowType() == RadioDevice::TX_WINDOW_USRP1) {
if (mRadioInterface->isUnderrun()) {
// only update latency at the defined frame interval
if (radioClock->get() > mLatencyUpdateTime + GSM::Time(USB_LATENCY_INTRVL)) {
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
diff --git a/Transceiver52M/USRPDevice.h b/Transceiver52M/USRPDevice.h
index b88afcb..f2a9a6d 100644
--- a/Transceiver52M/USRPDevice.h
+++ b/Transceiver52M/USRPDevice.h
@@ -126,8 +126,7 @@ private:
/** Set priority not supported */
void setPriority() { return; }
- /** Only USB bus supported */
- busType getBus() { return USB; }
+ enum TxWindowType getWindowType() { return TX_WINDOW_USRP1; }
/**
Read samples from the USRP.
diff --git a/Transceiver52M/radioDevice.h b/Transceiver52M/radioDevice.h
index 006e663..754bdbe 100644
--- a/Transceiver52M/radioDevice.h
+++ b/Transceiver52M/radioDevice.h
@@ -29,7 +29,7 @@ class RadioDevice {
public:
/* Available transport bus types */
- enum busType { USB, NET };
+ enum TxWindowType { TX_WINDOW_USRP1, TX_WINDOW_FIXED };
static RadioDevice *make(double desiredSampleRate, bool skipRx = false);
@@ -42,8 +42,8 @@ class RadioDevice {
/** Stop the USRP */
virtual bool stop()=0;
- /** Get the bus type */
- virtual enum busType getBus()=0;
+ /** Get the Tx window type */
+ virtual enum TxWindowType getWindowType()=0;
/** Enable thread priority */
virtual void setPriority()=0;
diff --git a/Transceiver52M/radioInterface.h b/Transceiver52M/radioInterface.h
index 6e15a1f..3c58222 100644
--- a/Transceiver52M/radioInterface.h
+++ b/Transceiver52M/radioInterface.h
@@ -140,8 +140,8 @@ public:
/** set thread priority on current thread */
void setPriority() { mRadio->setPriority(); }
- /** get transport bus type of attached device */
- enum RadioDevice::busType getBus() { return mRadio->getBus(); }
+ /** get transport window type of attached device */
+ enum RadioDevice::TxWindowType getWindowType() { return mRadio->getWindowType(); }
protected: