summaryrefslogtreecommitdiff
path: root/usrp/host
diff options
context:
space:
mode:
Diffstat (limited to 'usrp/host')
-rw-r--r--usrp/host/include/usrp/usrp_prims.h9
-rw-r--r--usrp/host/lib/Makefile.am24
-rw-r--r--usrp/host/lib/db_wbxng_adf4350.cc10
-rw-r--r--usrp/host/lib/db_wbxng_adf4350_regs.cc10
-rw-r--r--usrp/host/lib/db_wbxng_adf4350_regs.h2
-rw-r--r--usrp/host/lib/fusb_libusb1.cc10
-rw-r--r--usrp/host/lib/usrp_basic.cc (renamed from usrp/host/lib/usrp_basic_common.cc)67
-rw-r--r--usrp/host/lib/usrp_basic_libusb0.cc137
-rw-r--r--usrp/host/lib/usrp_basic_libusb1.cc145
-rw-r--r--usrp/host/lib/usrp_prims_libusb0.cc6
-rw-r--r--usrp/host/lib/usrp_prims_libusb1.cc11
11 files changed, 122 insertions, 309 deletions
diff --git a/usrp/host/include/usrp/usrp_prims.h b/usrp/host/include/usrp/usrp_prims.h
index 323287d02..4780d0004 100644
--- a/usrp/host/include/usrp/usrp_prims.h
+++ b/usrp/host/include/usrp/usrp_prims.h
@@ -53,6 +53,15 @@ enum usrp_load_status_t { ULS_ERROR = 0, ULS_OK, ULS_ALREADY_LOADED };
void usrp_one_time_init (libusb_context **ctx = NULL);
+/*!
+ * \brief deinitialize libusb
+ *
+ * libusb-0.1: No effect
+ *
+ * libusb-1.0: Deinitialize context ctx
+ */
+void usrp_deinit (libusb_context *ctx);
+
/*
* force a rescan of the buses and devices
*/
diff --git a/usrp/host/lib/Makefile.am b/usrp/host/lib/Makefile.am
index 72312ebbb..e80f27112 100644
--- a/usrp/host/lib/Makefile.am
+++ b/usrp/host/lib/Makefile.am
@@ -61,8 +61,7 @@ BUILT_SOURCES += usrp_dbid.cc \
generic_CODE = \
fusb_generic.cc \
fusb_sysconfig_generic.cc \
- usrp_prims_libusb0.cc \
- usrp_basic_libusb0.cc
+ usrp_prims_libusb0.cc
darwin_CODE = \
fusb_darwin.cc \
@@ -72,34 +71,29 @@ darwin_CODE = \
circular_linked_list.h \
darwin_libusb.h \
mld_threads.h \
- usrp_prims_libusb0.cc \
- usrp_basic_libusb0.cc
+ usrp_prims_libusb0.cc
win32_CODE = \
fusb_win32.cc \
fusb_sysconfig_win32.cc \
- usrp_prims_libusb0.cc \
- usrp_basic_libusb0.cc
+ usrp_prims_libusb0.cc
linux_CODE = \
fusb_linux.cc \
fusb_sysconfig_linux.cc \
- usrp_prims_libusb0.cc \
- usrp_basic_libusb0.cc
+ usrp_prims_libusb0.cc
ra_wb_CODE = \
fusb_ra_wb.cc \
fusb_sysconfig_ra_wb.cc \
- usrp_prims_libusb0.cc \
- usrp_basic_libusb0.cc
+ usrp_prims_libusb0.cc
libusb1_CODE = \
fusb_libusb1.cc \
fusb_sysconfig_libusb1.cc \
- usrp_prims_libusb1.cc \
- usrp_basic_libusb1.cc
+ usrp_prims_libusb1.cc
#
# include each <foo>_CODE entry here...
@@ -116,14 +110,14 @@ EXTRA_libusrp_la_SOURCES = \
libusrp_la_common_SOURCES = \
fusb.cc \
md5.c \
- usrp_basic_common.cc \
+ usrp_basic.cc \
usrp_config.cc \
usrp_dbid.cc \
usrp_local_sighandler.cc \
usrp_prims_common.cc \
usrp_standard.cc \
- db_wbxng_adf4350.cc \
- db_wbxng_adf4350_regs.cc \
+ db_wbxng_adf4350.cc \
+ db_wbxng_adf4350_regs.cc \
db_boards.cc \
db_base.cc \
db_basic.cc \
diff --git a/usrp/host/lib/db_wbxng_adf4350.cc b/usrp/host/lib/db_wbxng_adf4350.cc
index af4eac573..2cec972b0 100644
--- a/usrp/host/lib/db_wbxng_adf4350.cc
+++ b/usrp/host/lib/db_wbxng_adf4350.cc
@@ -34,7 +34,7 @@
#define MAX_RF_DIV uint8_t(16) /* max rf divider, divides rf output */
#define MIN_VCO_FREQ FREQ_C(2.2e9) /* minimum vco freq */
#define MAX_VCO_FREQ FREQ_C(4.4e9) /* minimum vco freq */
-#define MAX_FREQ MAX_VCO_FREQ /* upper bound freq (rf div = 1) */
+#define MAX_FREQ DIV_ROUND(MAX_VCO_FREQ, 1) /* upper bound freq (rf div = 1) */
#define MIN_FREQ DIV_ROUND(MIN_VCO_FREQ, MAX_RF_DIV) /* calculated lower bound freq */
#define CE_PIN (1 << 3)
@@ -133,6 +133,12 @@ adf4350::_set_freq(freq_t freq)
{
/* Set the frequency by setting int, frac, mod, r, div */
if (freq > MAX_FREQ || freq < MIN_FREQ) return false;
+ int min_int_div = 23;
+ d_regs->d_prescaler = 0;
+ if (freq > FREQ_C(3e9)) {
+ min_int_div = 75;
+ d_regs->d_prescaler = 1;
+ }
/* Ramp up the RF divider until the VCO is within range. */
d_regs->d_divider_select = 0;
while (freq < MIN_VCO_FREQ){
@@ -159,7 +165,7 @@ adf4350::_set_freq(freq_t freq)
d_regs->d_mod, d_regs->d_10_bit_r_counter, (1 << d_regs->d_divider_select)
);
*/
- }while(d_regs->d_int < MIN_INT_DIV);
+ }while(d_regs->d_int < min_int_div);
/* calculate the band select so PFD is under 125 KHz */
d_regs->d_8_bit_band_select_clock_divider_value = \
INPUT_REF_FREQ/(FREQ_C(30e3)*d_regs->d_10_bit_r_counter) + 1;
diff --git a/usrp/host/lib/db_wbxng_adf4350_regs.cc b/usrp/host/lib/db_wbxng_adf4350_regs.cc
index 11dcf8816..696b7c1d4 100644
--- a/usrp/host/lib/db_wbxng_adf4350_regs.cc
+++ b/usrp/host/lib/db_wbxng_adf4350_regs.cc
@@ -9,7 +9,6 @@
/* reg 0 */
/* reg 1 */
-const uint8_t adf4350_regs::s_prescaler = 0;
const uint16_t adf4350_regs::s_phase = 0;
/* reg 2 */
const uint8_t adf4350_regs::s_low_noise_and_low_spur_modes = 0;
@@ -32,9 +31,9 @@ const uint16_t adf4350_regs::s_12_bit_clock_divider_value = 0;
const uint8_t adf4350_regs::s_feedback_select = 1;
const uint8_t adf4350_regs::s_vco_power_down = 0;
const uint8_t adf4350_regs::s_mtld = 0;
-const uint8_t adf4350_regs::s_aux_output_select = 0;
-const uint8_t adf4350_regs::s_aux_output_enable = 1;
-const uint8_t adf4350_regs::s_aux_output_power = 3;
+const uint8_t adf4350_regs::s_aux_output_select = 1;
+const uint8_t adf4350_regs::s_aux_output_enable = 0;
+const uint8_t adf4350_regs::s_aux_output_power = 0;
const uint8_t adf4350_regs::s_rf_output_enable = 1;
const uint8_t adf4350_regs::s_output_power = 3;
/* reg 5 */
@@ -47,6 +46,7 @@ adf4350_regs::adf4350_regs(adf4350* _adf4350){
d_int = uint16_t(100);
d_frac = 0;
/* reg 1 */
+ d_prescaler = uint8_t(0);
d_mod = uint16_t(0xfff); /* max fractional accuracy */
/* reg 2 */
d_10_bit_r_counter = uint16_t(2);
@@ -73,7 +73,7 @@ adf4350_regs::_load_register(uint8_t addr){
_reg_shift(d_int, 15) |
_reg_shift(d_frac, 3)); break;
case 1: data = (
- _reg_shift(s_prescaler, 27) |
+ _reg_shift(d_prescaler, 27) |
_reg_shift(s_phase, 15) |
_reg_shift(d_mod, 3)); break;
case 2: data = (
diff --git a/usrp/host/lib/db_wbxng_adf4350_regs.h b/usrp/host/lib/db_wbxng_adf4350_regs.h
index dc941ee87..3973b4d6b 100644
--- a/usrp/host/lib/db_wbxng_adf4350_regs.h
+++ b/usrp/host/lib/db_wbxng_adf4350_regs.h
@@ -25,7 +25,7 @@ public:
uint16_t d_int;
uint16_t d_frac;
/* reg 1 */
- static const uint8_t s_prescaler;
+ uint8_t d_prescaler;
static const uint16_t s_phase;
uint16_t d_mod;
/* reg 2 */
diff --git a/usrp/host/lib/fusb_libusb1.cc b/usrp/host/lib/fusb_libusb1.cc
index 4846f51a5..770708451 100644
--- a/usrp/host/lib/fusb_libusb1.cc
+++ b/usrp/host/lib/fusb_libusb1.cc
@@ -279,6 +279,9 @@ fusb_devhandle_libusb1::_reap (bool ok_to_block_p)
int ret;
struct timeval tv;
+ // Save pending size
+ int pnd_size = d_pending_rqsts.size();
+
if (ok_to_block_p) {
tv.tv_sec = 2;
tv.tv_usec = 0;
@@ -293,7 +296,12 @@ fusb_devhandle_libusb1::_reap (bool ok_to_block_p)
return false;
}
- return true;
+ // Check that a pending transfer was removed
+ if (pnd_size > d_pending_rqsts.size())
+ return true;
+ else {
+ return false;
+ }
}
void
diff --git a/usrp/host/lib/usrp_basic_common.cc b/usrp/host/lib/usrp_basic.cc
index 721301dec..5b2f7ff71 100644
--- a/usrp/host/lib/usrp_basic_common.cc
+++ b/usrp/host/lib/usrp_basic.cc
@@ -74,14 +74,12 @@ open_tx_interface (libusb_device *dev)
return udh;
}
-
//////////////////////////////////////////////////////////////////
//
// usrp_basic
//
////////////////////////////////////////////////////////////////
-
// Given:
// CLKIN = 64 MHz
// CLKSEL pin = high
@@ -101,6 +99,71 @@ static unsigned char common_regs[] = {
REG_AUX_ADC_CLK, AUX_ADC_CLK_CLK_OVER_4
};
+usrp_basic::usrp_basic (int which_board,
+ libusb_device_handle *
+ open_interface (libusb_device *dev),
+ const std::string fpga_filename,
+ const std::string firmware_filename)
+ : d_udh (0), d_ctx (0),
+ d_usb_data_rate (16000000), // SWAG, see below
+ d_bytes_per_poll ((int) (POLLING_INTERVAL * d_usb_data_rate)),
+ d_verbose (false), d_fpga_master_clock_freq(64000000), d_db(2)
+{
+ /*
+ * SWAG: Scientific Wild Ass Guess.
+ *
+ * d_usb_data_rate is used only to determine how often to poll for over- and
+ * under-runs. We defualt it to 1/2 of our best case. Classes derived from
+ * usrp_basic (e.g., usrp_standard_tx and usrp_standard_rx) call
+ * set_usb_data_rate() to tell us the actual rate. This doesn't change our
+ * throughput, that's determined by the signal processing code in the FPGA
+ * (which we know nothing about), and the system limits determined by libusb,
+ * fusb_*, and the underlying drivers.
+ */
+ memset (d_fpga_shadows, 0, sizeof (d_fpga_shadows));
+
+ usrp_one_time_init (&d_ctx);
+
+ if (!usrp_load_standard_bits (which_board, false, fpga_filename,
+ firmware_filename, d_ctx))
+ throw std::runtime_error ("usrp_basic/usrp_load_standard_bits");
+
+ libusb_device *dev = usrp_find_device (which_board, false, d_ctx);
+ if (dev == 0){
+ fprintf (stderr, "usrp_basic: can't find usrp[%d]\n", which_board);
+ throw std::runtime_error ("usrp_basic/usrp_find_device");
+ }
+
+ if (!(usrp_usrp_p(dev) && usrp_hw_rev(dev) >= 1)){
+ fprintf (stderr, "usrp_basic: sorry, this code only works with USRP revs >= 1\n");
+ throw std::runtime_error ("usrp_basic/bad_rev");
+ }
+
+ if ((d_udh = open_interface (dev)) == 0)
+ throw std::runtime_error ("usrp_basic/open_interface");
+
+ // initialize registers that are common to rx and tx
+
+ if (!usrp_9862_write_many_all (d_udh, common_regs, sizeof (common_regs))) {
+ fprintf (stderr, "usrp_basic: failed to init common AD9862 regs\n");
+ throw std::runtime_error ("usrp_basic/init_9862");
+ }
+
+ _write_fpga_reg (FR_MODE, 0); // ensure we're in normal mode
+ _write_fpga_reg (FR_DEBUG_EN, 0); // disable debug outputs
+
+}
+
+usrp_basic::~usrp_basic ()
+{
+ d_db.resize(0); // forget db shared ptrs
+
+ if (d_udh)
+ usrp_close_interface (d_udh);
+
+ usrp_deinit (d_ctx);
+}
+
void
usrp_basic::shutdown_daughterboards()
{
diff --git a/usrp/host/lib/usrp_basic_libusb0.cc b/usrp/host/lib/usrp_basic_libusb0.cc
deleted file mode 100644
index 217480580..000000000
--- a/usrp/host/lib/usrp_basic_libusb0.cc
+++ /dev/null
@@ -1,137 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003,2004,2008,2009 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <usrp/usrp_basic.h>
-#include "usrp/usrp_prims.h"
-#include "usrp_interfaces.h"
-#include "fpga_regs_common.h"
-#include "fpga_regs_standard.h"
-#include "fusb.h"
-#include "db_boards.h"
-#include <usb.h>
-#include <stdexcept>
-#include <assert.h>
-#include <math.h>
-#include <ad9862.h>
-#include <string.h>
-#include <cstdio>
-
-using namespace ad9862;
-
-#define NELEM(x) (sizeof (x) / sizeof (x[0]))
-
-
-static const double POLLING_INTERVAL = 0.1; // seconds
-
-
-//////////////////////////////////////////////////////////////////
-//
-// usrp_basic
-//
-////////////////////////////////////////////////////////////////
-
-
-// Given:
-// CLKIN = 64 MHz
-// CLKSEL pin = high
-//
-// CLKOUT1 = CLKIN = 64 MHz
-// CLKOUT2 = CLKIN = 64 MHz
-// ADC is clocked at 64 MHz
-// DAC is clocked at 128 MHz
-
-static unsigned char common_regs[] = {
- REG_GENERAL, 0,
- REG_DLL, (DLL_DISABLE_INTERNAL_XTAL_OSC
- | DLL_MULT_2X
- | DLL_FAST),
- REG_CLKOUT, CLKOUT2_EQ_DLL_OVER_2,
- REG_AUX_ADC_CLK, AUX_ADC_CLK_CLK_OVER_4
-};
-
-
-usrp_basic::usrp_basic (int which_board,
- struct usb_dev_handle *
- open_interface (struct usb_device *dev),
- const std::string fpga_filename,
- const std::string firmware_filename)
- : d_udh (0),
- d_usb_data_rate (16000000), // SWAG, see below
- d_bytes_per_poll ((int) (POLLING_INTERVAL * d_usb_data_rate)),
- d_verbose (false), d_fpga_master_clock_freq(64000000), d_db(2)
-{
- /*
- * SWAG: Scientific Wild Ass Guess.
- *
- * d_usb_data_rate is used only to determine how often to poll for over- and under-runs.
- * We defualt it to 1/2 of our best case. Classes derived from usrp_basic (e.g.,
- * usrp_standard_tx and usrp_standard_rx) call set_usb_data_rate() to tell us the
- * actual rate. This doesn't change our throughput, that's determined by the signal
- * processing code in the FPGA (which we know nothing about), and the system limits
- * determined by libusb, fusb_*, and the underlying drivers.
- */
- memset (d_fpga_shadows, 0, sizeof (d_fpga_shadows));
-
- usrp_one_time_init ();
-
- if (!usrp_load_standard_bits (which_board, false, fpga_filename, firmware_filename))
- throw std::runtime_error ("usrp_basic/usrp_load_standard_bits");
-
- struct usb_device *dev = usrp_find_device (which_board);
- if (dev == 0){
- fprintf (stderr, "usrp_basic: can't find usrp[%d]\n", which_board);
- throw std::runtime_error ("usrp_basic/usrp_find_device");
- }
-
- if (!(usrp_usrp_p(dev) && usrp_hw_rev(dev) >= 1)){
- fprintf (stderr, "usrp_basic: sorry, this code only works with USRP revs >= 1\n");
- throw std::runtime_error ("usrp_basic/bad_rev");
- }
-
- if ((d_udh = open_interface (dev)) == 0)
- throw std::runtime_error ("usrp_basic/open_interface");
-
- // initialize registers that are common to rx and tx
-
- if (!usrp_9862_write_many_all (d_udh, common_regs, sizeof (common_regs))){
- fprintf (stderr, "usrp_basic: failed to init common AD9862 regs\n");
- throw std::runtime_error ("usrp_basic/init_9862");
- }
-
- _write_fpga_reg (FR_MODE, 0); // ensure we're in normal mode
- _write_fpga_reg (FR_DEBUG_EN, 0); // disable debug outputs
-}
-
-usrp_basic::~usrp_basic ()
-{
- // shutdown_daughterboards(); // call from ~usrp_basic_{tx,rx}
-
- d_db.resize(0); // forget db shared ptrs
-
- if (d_udh)
- usb_close (d_udh);
-}
-
diff --git a/usrp/host/lib/usrp_basic_libusb1.cc b/usrp/host/lib/usrp_basic_libusb1.cc
deleted file mode 100644
index 35009dc66..000000000
--- a/usrp/host/lib/usrp_basic_libusb1.cc
+++ /dev/null
@@ -1,145 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003,2004,2008,2009 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <usrp/usrp_basic.h>
-#include "usrp/usrp_prims.h"
-#include "usrp_interfaces.h"
-#include "fpga_regs_common.h"
-#include "fpga_regs_standard.h"
-#include "fusb.h"
-#include "db_boards.h"
-#include <libusb-1.0/libusb.h>
-#include <stdexcept>
-#include <assert.h>
-#include <math.h>
-#include <ad9862.h>
-#include <string.h>
-#include <cstdio>
-
-
-using namespace ad9862;
-
-#define NELEM(x) (sizeof (x) / sizeof (x[0]))
-
-
-static const double POLLING_INTERVAL = 0.1; // seconds
-
-
-//////////////////////////////////////////////////////////////////
-//
-// usrp_basic
-//
-////////////////////////////////////////////////////////////////
-
-
-// Given:
-// CLKIN = 64 MHz
-// CLKSEL pin = high
-//
-// These settings give us:
-// CLKOUT1 = CLKIN = 64 MHz
-// CLKOUT2 = CLKIN = 64 MHz
-// ADC is clocked at 64 MHz
-// DAC is clocked at 128 MHz
-
-static unsigned char common_regs[] = {
- REG_GENERAL, 0,
- REG_DLL, (DLL_DISABLE_INTERNAL_XTAL_OSC
- | DLL_MULT_2X
- | DLL_FAST),
- REG_CLKOUT, CLKOUT2_EQ_DLL_OVER_2,
- REG_AUX_ADC_CLK, AUX_ADC_CLK_CLK_OVER_4
-};
-
-usrp_basic::usrp_basic (int which_board,
- struct libusb_device_handle *
- open_interface (struct libusb_device *dev),
- const std::string fpga_filename,
- const std::string firmware_filename)
- : d_udh (0), d_ctx (0),
- d_usb_data_rate (16000000), // SWAG, see below
- d_bytes_per_poll ((int) (POLLING_INTERVAL * d_usb_data_rate)),
- d_verbose (false), d_fpga_master_clock_freq(64000000), d_db(2)
-{
- /*
- * SWAG: Scientific Wild Ass Guess.
- *
- * d_usb_data_rate is used only to determine how often to poll for over- and under-runs.
- * We defualt it to 1/2 of our best case. Classes derived from usrp_basic (e.g.,
- * usrp_standard_tx and usrp_standard_rx) call set_usb_data_rate() to tell us the
- * actual rate. This doesn't change our throughput, that's determined by the signal
- * processing code in the FPGA (which we know nothing about), and the system limits
- * determined by libusb, fusb_*, and the underlying drivers.
- */
- memset (d_fpga_shadows, 0, sizeof (d_fpga_shadows));
-
- usrp_one_time_init (&d_ctx);
-
- if (!usrp_load_standard_bits (which_board, false, fpga_filename, firmware_filename, d_ctx))
- throw std::runtime_error ("usrp_basic/usrp_load_standard_bits");
-
- struct libusb_device *dev = usrp_find_device (which_board, false, d_ctx);
- if (dev == 0){
- fprintf (stderr, "usrp_basic: can't find usrp[%d]\n", which_board);
- throw std::runtime_error ("usrp_basic/usrp_find_device");
- }
-
- if (!(usrp_usrp_p(dev) && usrp_hw_rev(dev) >= 1)){
- fprintf (stderr, "usrp_basic: sorry, this code only works with USRP revs >= 1\n");
- throw std::runtime_error ("usrp_basic/bad_rev");
- }
-
- if ((d_udh = open_interface (dev)) == 0)
- throw std::runtime_error ("usrp_basic/open_interface");
-
- // initialize registers that are common to rx and tx
-
- if (!usrp_9862_write_many_all (d_udh, common_regs, sizeof (common_regs))){
- fprintf (stderr, "usrp_basic: failed to init common AD9862 regs\n");
- throw std::runtime_error ("usrp_basic/init_9862");
- }
-
- _write_fpga_reg (FR_MODE, 0); // ensure we're in normal mode
- _write_fpga_reg (FR_DEBUG_EN, 0); // disable debug outputs
-
-}
-
-usrp_basic::~usrp_basic ()
-{
- // shutdown_daughterboards(); // call from ~usrp_basic_{tx,rx}
-
- d_db.resize(0); // forget db shared ptrs
-
- if (d_udh)
- libusb_close (d_udh);
-
- // Each object _should_ be running in its own context. If running in default
- // context then leave the instance open as it may be shared.
-
- if (d_ctx != NULL)
- libusb_exit (d_ctx);
-}
-
diff --git a/usrp/host/lib/usrp_prims_libusb0.cc b/usrp/host/lib/usrp_prims_libusb0.cc
index 7053786d8..4d1fd78c9 100644
--- a/usrp/host/lib/usrp_prims_libusb0.cc
+++ b/usrp/host/lib/usrp_prims_libusb0.cc
@@ -106,6 +106,12 @@ usrp_one_time_init (libusb_context **ctx)
}
void
+usrp_deinit (libusb_context *ctx)
+{
+ // nop
+}
+
+void
usrp_rescan ()
{
usb_find_busses ();
diff --git a/usrp/host/lib/usrp_prims_libusb1.cc b/usrp/host/lib/usrp_prims_libusb1.cc
index fdd497abc..5dfe416e1 100644
--- a/usrp/host/lib/usrp_prims_libusb1.cc
+++ b/usrp/host/lib/usrp_prims_libusb1.cc
@@ -135,6 +135,7 @@ _usb_control_transfer (struct libusb_device_handle *udh, int request_type,
return ret;
}
+
// ----------------------------------------------------------------
@@ -155,12 +156,20 @@ usrp_one_time_init (libusb_context **ctx)
}
void
+usrp_deinit (struct libusb_context *ctx)
+{
+ // Each object _should_ be running in its own context. If running in default
+ // context then leave the instance open as it may be shared.
+ if (ctx != NULL)
+ libusb_exit (ctx);
+}
+
+void
usrp_rescan ()
{
// nop
}
-
struct libusb_device *
usrp_find_device (int nth, bool fx2_ok_p, libusb_context *ctx)
{