dnl
-dnl Copyright 2003,2008 Free Software Foundation, Inc.
+dnl Copyright 2003,2008,2009 Free Software Foundation, Inc.
dnl
dnl This file is part of GNU Radio
dnl
dnl Boston, MA 02110-1301, USA.
# $1 is $req_libusb1:
-# yes : check libusb-1.0
-# no : check libusb-0.12
-# "" : check libusb-0.12
+# yes : check libusb-1.0
+# no : check libusb-0.12
+# "" : check libusb-0.12
AC_DEFUN([USRP_LIBUSB], [
-/* -*- Mode: C++ -*- */
+/* -*- c++ -*- */
/*
* Copyright 2005,2009 Free Software Foundation, Inc.
*
* Boston, MA 02110-1301, USA.
*/
-#ifndef _USRP_BASIC_H_
-#define _USRP_BASIC_H_
+#ifndef INCLUDED_USRP_BASIC_H
+#define INCLUDED_USRP_BASIC_H
#include <usrp/db_base.h>
#include <usrp/usrp_slots.h>
bool stop ();
};
-#endif
+#endif /* INCLUDED_USRP_BASIC_H */
-/* -*- Mode: C++ -*- */
+/* -*- c++ -*- */
/*
* Copyright 2005,2009 Free Software Foundation, Inc.
*
* Boston, MA 02110-1301, USA.
*/
-#ifndef _USRP_PRIMS_H_
-#define _USRP_PRIMS_H_
+#ifndef INCLUDED_USRP_PRIMS_H
+#define INCLUDED_USRP_PRIMS_H
#include <usrp/usrp_slots.h>
#include <usrp/libusb_types.h>
*
* Probe busses and devices. The argument is ignored and defaults to NULL.
* Safe to call more than once.
- *
+ *
* libusb-1.0
*
* If an location to a libusb_context is passed in, create and write in the new
* context. If no argument is provided, initialize libusb with the default
- * (NULL) context.
+ * (NULL) context.
*
* Generally _not_ safe to call more than once with non-NULL argument since a
- * new context will be created each time.
+ * new context will be created each time.
*/
void usrp_one_time_init (libusb_context **ctx = NULL);
*/
std::string usrp_serial_number(libusb_device_handle *udh);
-#endif /* _USRP_PRIMS_H_ */
+#endif /* INCLUDED_USRP_PRIMS_H */
//
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright 2008,2009 Free Software Foundation, Inc.
//
// This file is part of GNU Radio
//
/* -*- c++ -*- */
//
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright 2008,2009 Free Software Foundation, Inc.
//
// This file is part of GNU Radio
//
/* -*- c++ -*- */
//
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright 2008,2009 Free Software Foundation, Inc.
//
// This file is part of GNU Radio
//
//
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright 2008,2009 Free Software Foundation, Inc.
//
// This file is part of GNU Radio
//
* Boston, MA 02110-1301, USA.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <usrp/db_flexrf_mimo.h>
#include <fpga_regs_standard.h>
#include <fpga_regs_common.h>
//
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright 2008,2009 Free Software Foundation, Inc.
//
// This file is part of GNU Radio
//
//
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright 2008,2009 Free Software Foundation, Inc.
//
// This file is part of GNU Radio
//
// the Free Software Foundation, Inc., 51 Franklin Street,
// Boston, MA 02110-1301, USA.
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <usrp/db_tv_rx_mimo.h>
db_tv_rx_mimo::db_tv_rx_mimo(usrp_basic_sptr usrp, int which,
/* -*- c++ -*- */
/*
- * Copyright 2003 Free Software Foundation, Inc.
+ * Copyright 2003,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
-/* -*- Mode: C++ -*- */
+/* -*- c++ -*- */
/*
* Copyright 2005,2009 Free Software Foundation, Inc.
*
/* -*- c++ -*- */
/*
- * Copyright 2003 Free Software Foundation, Inc.
- *
+ * Copyright 2003,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,
#include <errno.h>
#include <string.h>
-#define MINIMIZE_TX_BUFFERING true
+#define MINIMIZE_TX_BUFFERING true
-static const int MAX_BLOCK_SIZE = fusb_sysconfig::max_block_size();
+static const int MAX_BLOCK_SIZE = fusb_sysconfig::max_block_size();
static const int DEFAULT_BLOCK_SIZE = MAX_BLOCK_SIZE;
static const int DEFAULT_BUFFER_SIZE = 4 * (1L << 20); // 4 MB endpoint
static const int LIBUSB_TIMEOUT = 0; // no timeout
}
// ------------------------------------------------------------------------
-// libusb_transfer allocation, deallocation, and callback
+// libusb_transfer allocation, deallocation, and callback
// ------------------------------------------------------------------------
static void
if (lut->endpoint & 0x80)
delete [] ((unsigned char *) lut->buffer);
- libusb_free_transfer(lut);
+ libusb_free_transfer(lut);
}
/*
* The callback means the libusb_transfer is completed whether sent, cancelled,
* or failed. Move the libusb_transfer from the pending list to the
- * completed list. If the cancel is from the destructor then free the
+ * completed list. If the cancel is from the destructor then free the
* transfer instead; normally this won't happen since all endpoints should be
* destroyed first leaving the pending list empty.
*/
{
// Fish out devhandle from endpoint
- fusb_devhandle_libusb1* dev_handle =
+ fusb_devhandle_libusb1* dev_handle =
lut_get_ephandle(lut)->get_fusb_devhandle_libusb1();
dev_handle->pending_remove(lut);
free_lut (lut);
return;
}
-
+
lut_get_ephandle(lut)->completed_list_add(lut);
-}
+}
static libusb_transfer*
alloc_lut (fusb_ephandle_libusb1 *self, int buffer_length, int endpoint,
// Load the libusb_transfer for bulk transfer
libusb_fill_bulk_transfer (lut, // transfer
- dev_handle, // dev_handle
+ dev_handle, // dev_handle
endpoint, // endpoint
write_buffer, // buffer
buffer_length, // length
- generic_callback, // callback
+ generic_callback, // callback
self, // user_data
LIBUSB_TIMEOUT); // timeout
libusb_context *ctx)
: fusb_devhandle (udh), d_ctx (ctx), d_teardown (false)
{
- // that's it
+ // that's it
}
fusb_devhandle_libusb1::~fusb_devhandle_libusb1 ()
}
/*
- * devhandle list manipulators
+ * devhandle list manipulators
*/
-void
+void
fusb_devhandle_libusb1::pending_add (libusb_transfer *lut)
{
d_pending_rqsts.push_back (lut);
}
/*
- * Match libusb_tranfer with the pending list and erase
+ * Match libusb_tranfer with the pending list and erase
* Return true if found, false otherwise
*/
}
/*
- * Attempt to cancel any pending libusb_transfer transactions.
+ * Attempt to cancel any pending libusb_transfer transactions.
* Return true in the absence of errors, which does not mean that the transfer
* is cancelled. Cancellation can be checked after the callback is fired off
- * by libusb.
- */
+ * by libusb.
+ */
bool
fusb_devhandle_libusb1::_cancel_lut (libusb_transfer *lut)
tv.tv_sec = 0;
tv.tv_usec = 0;
}
-
+
if ((ret = libusb_handle_events_timeout(d_ctx, &tv)) < 0) {
fprintf (stderr, "fusb::_reap libusb_handle_events() %i\n", ret);
return false;
}
-
+
return true;
}
fusb_devhandle_libusb1::_wait_for_completion ()
{
- while (!d_pending_rqsts.empty ())
- if (!_reap(true))
- break;
+ while (!d_pending_rqsts.empty ())
+ if (!_reap(true))
+ break;
}
fprintf(stderr, "fusb_ephandle_libusb1::ctor: d_block_size = %d d_nblocks = %d\n",
d_block_size, d_nblocks);
- // allocate libusb_transfers
+ // allocate libusb_transfers
for (int i = 0; i < d_nblocks; i++)
d_free_list.push_back (alloc_lut (this, d_block_size, d_endpoint,
d_input_p, d_write_buffer, d_devhandle));
}
/*
- * Cancel all transfers in progress or pending and return to initial state
+ * Cancel all transfers in progress or pending and return to initial state
*/
bool
}
// ------------------------------------------------------------------------
-// routines for writing
+// routines for writing
// ------------------------------------------------------------------------
#if (MINIMIZE_TX_BUFFERING)
{
if (!d_started) // doesn't matter here, but keeps semantics constant
return -1;
-
+
if (d_input_p)
return -1;
n += m;
src += m;
-
+
if (!submit_lut(lut))
return -1;
while ((lut = completed_list_get ()) != 0) {
// Check for any errors or short writes that were reporetd in the transfer.
- // libusb1 sets status, actual_length.
+ // libusb1 sets status, actual_length.
- if (lut->status != LIBUSB_TRANSFER_COMPLETED) {
+ if (lut->status != LIBUSB_TRANSFER_COMPLETED) {
fprintf (stderr, "fusb: (status %d) \n", lut->status );
- }
+ }
else if (lut->actual_length != lut->length){
fprintf (stderr, "fusb: short write xfer: %d != %d\n",
lut->actual_length, lut->length);
}
// ------------------------------------------------------------------------
-// routines for reading
+// routines for reading
// ------------------------------------------------------------------------
int
while (1) {
- while ((lut = completed_list_get ()) == 0 )
+ while ((lut = completed_list_get ()) == 0 )
if (!d_devhandle->_reap(true))
- return false;
+ return false;
if (lut->status != LIBUSB_TRANSFER_COMPLETED) {
- fprintf (stderr, "fust: (rd status %d) %s\n", lut->status,
+ fprintf (stderr, "fust: (rd status %d) %s\n", lut->status,
strerror (-lut->status));
lut->actual_length = 0;
free_list_add (lut);
/*
- * ephandle list manipulation
+ * ephandle list manipulation
*/
/* -*- c++ -*- */
/*
- * Copyright 2003 Free Software Foundation, Inc.
- *
+ * Copyright 2003,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,
libusb_transfer *get_write_work_in_progress ();
void reap_complete_writes ();
bool reload_read_buffer ();
- bool submit_lut (libusb_transfer *lut);
-
+ bool submit_lut (libusb_transfer *lut);
+
public:
// CREATORS
fusb_ephandle_libusb1 (fusb_devhandle_libusb1 *dh, int endpoint, bool input_p,
struct libusb_transfer *free_list_get ();
struct libusb_transfer *completed_list_get ();
- // accessor to work from callback context
+ // accessor to work from callback context
fusb_devhandle_libusb1* get_fusb_devhandle_libusb1 () const {
return d_devhandle;
}
/* -*- c++ -*- */
/*
- * Copyright 2003 Free Software Foundation, Inc.
+ * Copyright 2003,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
/* -*- c++ -*- */
/*
- * Copyright 2003 Free Software Foundation, Inc.
+ * Copyright 2003,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
/* -*- c++ -*- */
/*
- * Copyright 2003 Free Software Foundation, Inc.
+ * Copyright 2003,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
/* -*- c++ -*- */
/*
- * Copyright 2003 Free Software Foundation, Inc.
- *
+ * Copyright 2003,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,
fusb_devhandle *
fusb_sysconfig::make_devhandle (usb_dev_handle *udh, libusb_context *ctx)
{
- return new fusb_devhandle_linux (udh);
+ return new fusb_devhandle_linux (udh);
}
int fusb_sysconfig::max_block_size ()
/* -*- c++ -*- */
/*
- * Copyright 2003,2006 Free Software Foundation, Inc.
+ * Copyright 2003,2006,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
/* -*- c++ -*- */
/*
- * Copyright 2003,2005 Free Software Foundation, Inc.
+ * Copyright 2003,2005,2009 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
/* -*- 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,
// Given:
// CLKIN = 64 MHz
-// CLKSEL pin = high
+// CLKSEL pin = high
//
// These settings give us:
// CLKOUT1 = CLKIN = 64 MHz
// nuke d'boards before we close down USB in ~usrp_basic
// shutdown() will do any board shutdown while the USRP can still
// be talked to
- for(size_t i = 0; i < d_db.size(); i++)
- for(size_t j = 0; j < d_db[i].size(); j++)
+ for(size_t i = 0; i < d_db.size(); i++)
+ for(size_t j = 0; j < d_db[i].size(); j++)
d_db[i][j]->shutdown();
}
d_db[1] = instantiate_dbs(d_dbid[1], u, 1);
}
-std::vector<db_base_sptr>
+std::vector<db_base_sptr>
usrp_basic::db(int which_side)
{
which_side &= 0x1; // clamp it to avoid any reporting any errors
bool
usrp_basic::set_dc_offset_cl_enable(int bits, int mask)
{
- return _write_fpga_reg(FR_DC_OFFSET_CL_EN,
+ return _write_fpga_reg(FR_DC_OFFSET_CL_EN,
(d_fpga_shadows[FR_DC_OFFSET_CL_EN] & ~mask) | (bits & mask));
}
{
if (len <= 0)
return "";
-
+
char buf[len];
if (!usrp_spi_read (d_udh, optional_header, enables, format, buf, len))
if (fusb_nblocks < 0)
throw std::out_of_range ("usrp_basic_rx: invalid fusb_nblocks");
-
+
if (fusb_block_size == 0)
fusb_block_size = fusb_sysconfig::default_block_size();
fprintf (stderr, "usrp_basic_rx: set_rx_enable failed\n");
return false;
}
-
+
return true;
}
const std::string firmware_filename)
{
usrp_basic_rx *u = 0;
-
+
try {
u = new usrp_basic_rx (which_board, fusb_block_size, fusb_nblocks,
fpga_filename, firmware_filename);
usrp_basic_rx::read (void *buf, int len, bool *overrun)
{
int r;
-
+
if (overrun)
*overrun = false;
-
+
if (len < 0 || (len % 512) != 0){
fprintf (stderr, "usrp_basic_rx::read: invalid length = %d\n", len);
return -1;
fprintf (stderr, "usrp_basic_rx: usrp_check_rx_overrun failed\n");
}
}
-
+
return r;
}
_write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | eeprom.oe);
_write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
break;
-
+
case UDBE_NO_EEPROM:
d_dbid[i] = -1;
msg = "<none>";
_write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | 0x0000);
_write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
break;
-
+
case UDBE_INVALID_EEPROM:
d_dbid[i] = -2;
msg = "Invalid EEPROM contents";
_write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | 0x0000);
_write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
break;
-
+
case UDBE_BAD_SLOT:
default:
assert (0);
if (fusb_nblocks < 0)
throw std::out_of_range ("usrp_basic_rx: invalid fusb_nblocks");
-
+
if (fusb_block_size == 0)
fusb_block_size = FUSB_BLOCK_SIZE;
fprintf (stderr, "usrp_basic_tx: set_tx_enable failed\n");
return false;
}
-
+
if (!d_ephandle->start ()){
fprintf (stderr, "usrp_basic_tx: failed to start end point streaming");
return false;
const std::string firmware_filename)
{
usrp_basic_tx *u = 0;
-
+
try {
u = new usrp_basic_tx (which_board, fusb_block_size, fusb_nblocks,
fpga_filename, firmware_filename);
usrp_basic_tx::write (const void *buf, int len, bool *underrun)
{
int r;
-
+
if (underrun)
*underrun = false;
-
+
if (len < 0 || (len % 512) != 0){
fprintf (stderr, "usrp_basic_tx::write: invalid length = %d\n", len);
return -1;
r = d_ephandle->write (buf, len);
if (r > 0)
d_bytes_seen += r;
-
+
/*
* In many cases, the FPGA reports an tx underrun right after we
* enable the Tx path. If this is our first write, check for the
_write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | eeprom.oe);
_write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
break;
-
+
case UDBE_NO_EEPROM:
d_dbid[i] = -1;
msg = "<none>";
_write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | 0x0000);
_write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
break;
-
+
case UDBE_INVALID_EEPROM:
d_dbid[i] = -2;
msg = "Invalid EEPROM contents";
_write_fpga_reg (slot_id_to_oe_reg(slot_id), (0xffff << 16) | 0x0000);
_write_fpga_reg (slot_id_to_io_reg(slot_id), (0xffff << 16) | 0x0000);
break;
-
+
case UDBE_BAD_SLOT:
default:
assert (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,
// Given:
// CLKIN = 64 MHz
-// CLKSEL pin = high
+// CLKSEL pin = high
//
// CLKOUT1 = CLKIN = 64 MHz
// CLKOUT2 = CLKIN = 64 MHz
};
-usrp_basic::usrp_basic (int which_board,
+usrp_basic::usrp_basic (int which_board,
struct usb_dev_handle *
open_interface (struct usb_device *dev),
const std::string fpga_filename,
* 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.,
+ * 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
/* -*- 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,
// Given:
// CLKIN = 64 MHz
-// CLKSEL pin = high
+// CLKSEL pin = high
//
// These settings give us:
// CLKOUT1 = CLKIN = 64 MHz
REG_AUX_ADC_CLK, AUX_ADC_CLK_CLK_OVER_4
};
-usrp_basic::usrp_basic (int which_board,
+usrp_basic::usrp_basic (int which_board,
struct libusb_device_handle *
open_interface (struct libusb_device *dev),
const std::string fpga_filename,
* 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.,
+ * 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
/* -*- c++ -*- */
/*
* Copyright 2003,2004,2006,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,
if (!reset_cpu (udh, true)) // hold CPU in reset while loading firmware
goto fail;
-
+
char s[1024];
int length;
int addr;
if (write_cmd (udh, VRQ_FPGA_LOAD, 0, FL_BEGIN, 0, 0) != 0)
goto fail;
-
+
while ((n = fread (buf, 1, sizeof (buf), fp)) > 0){
if (write_cmd (udh, VRQ_FPGA_LOAD, 0, FL_XFER, buf, n) != n)
goto fail;
if (write_cmd (udh, VRQ_FPGA_LOAD, 0, FL_END, 0, 0) != 0)
goto fail;
-
+
fclose (fp);
if (!usrp_set_hash (udh, FPGA_HASH_SLOT, hash))
usrp_set_fpga_reset (udh, 0); // fpga out of master reset
// now these commands will work
-
+
ok &= usrp_set_fpga_tx_enable (udh, 0);
ok &= usrp_set_fpga_rx_enable (udh, 0);
// ----------------------------------------------------------------
-bool
+bool
usrp_set_led (libusb_device_handle *udh, int which, bool on)
{
int r = write_cmd (udh, VRQ_SET_LED, on, which, 0, 0);
(unsigned char *) hash, USRP_HASH_SIZE, 1000);
return r == USRP_HASH_SIZE;
}
-
+
bool
usrp_get_hash (libusb_device_handle *udh, int which,
unsigned char hash[USRP_HASH_SIZE])
buf[1] = (value >> 16) & 0xff;
buf[2] = (value >> 8) & 0xff;
buf[3] = (value >> 0) & 0xff;
-
+
return usrp_spi_write (udh, 0x00 | (regno & 0x7f),
SPI_ENABLE_FPGA,
SPI_FMT_MSB | SPI_FMT_HDR_1,
}
}
-bool
+bool
usrp_set_fpga_reset (libusb_device_handle *udh, bool on)
{
return usrp_set_switch (udh, VRQ_FPGA_SET_RESET, on);
}
-bool
+bool
usrp_set_fpga_tx_enable (libusb_device_handle *udh, bool on)
{
return usrp_set_switch (udh, VRQ_FPGA_SET_TX_ENABLE, on);
}
-bool
+bool
usrp_set_fpga_rx_enable (libusb_device_handle *udh, bool on)
{
return usrp_set_switch (udh, VRQ_FPGA_SET_RX_ENABLE, on);
}
-bool
+bool
usrp_set_fpga_tx_reset (libusb_device_handle *udh, bool on)
{
return usrp_set_switch (udh, VRQ_FPGA_SET_TX_RESET, on);
}
-bool
+bool
usrp_set_fpga_rx_reset (libusb_device_handle *udh, bool on)
{
return usrp_set_switch (udh, VRQ_FPGA_SET_RX_RESET, on);
}
int r = md5_stream (fp, hash);
fclose (fp);
-
+
return r == 0;
}
{
unsigned char file_hash[USRP_HASH_SIZE];
unsigned char usrp_hash[USRP_HASH_SIZE];
-
+
if (access (filename, R_OK) != 0){
perror (filename);
return ULS_ERROR;
case ULS_OK:
// we loaded firmware successfully.
-
+
// It's highly likely that the board will renumerate (simulate a
// disconnect/reconnect sequence), invalidating our current
// handle.
// FIXME. Turn this into a loop that rescans until we refind ourselves
-
+
struct timespec t; // delay for 1 second
t.tv_sec = 2;
t.tv_nsec = 0;
{
char *e = getenv("USRP_VERBOSE");
bool verbose = e != 0;
-
+
switch (s){
case ULS_ERROR:
fprintf (stderr, "usrp: failed to load %s %s.\n", type, filename);
break;
-
+
case ULS_ALREADY_LOADED:
if (verbose)
fprintf (stderr, "usrp: %s %s already loaded.\n", type, filename);
libusb_device_handle *udh = open_nth_cmd_interface (nth, ctx);
if (udh == 0)
return false;
-
+
s = usrp_load_fpga (udh, filename, force);
usrp_close_interface (udh);
load_status_msg (s, "fpga bitstream", filename);
{
unsigned char status;
*trouble = true;
-
+
if (write_cmd (udh, VRQ_GET_STATUS, 0, which,
&status, sizeof (status)) != sizeof (status))
return false;
unsigned char buf[1];
buf[0] = value;
-
+
return usrp_spi_write (udh, 0x00 | (regno & 0x3f),
which_codec == 0 ? SPI_ENABLE_CODEC_A : SPI_ENABLE_CODEC_B,
SPI_FMT_MSB | SPI_FMT_HDR_1,
{
unsigned char cmd[2];
const unsigned char *p = (unsigned char *) buf;
-
+
// The simplest thing that could possibly work:
// all writes are single byte writes.
//
if (!r)
return false;
}
-
+
return true;
}
}
return true;
}
-
+
// ----------------------------------------------------------------
static bool
slot_to_codec (int slot, int *which_codec)
{
*which_codec = 0;
-
+
switch (slot){
case SLOT_TX_A:
case SLOT_RX_A:
int which_dac, int value)
{
int which_codec;
-
+
if (!slot_to_codec (slot, &which_codec))
return false;
}
value &= 0x0fff; // mask to 12-bits
-
+
if (which_dac == 3){
// dac 3 is really 12-bits. Use value as is.
bool r = true;
return r;
}
else {
- // dac 0, 1, and 2 are really 8 bits.
+ // dac 0, 1, and 2 are really 8 bits.
value = value >> 4; // shift value appropriately
return usrp_9862_write (udh, which_codec, 36 + which_dac, value);
}
| AUX_ADC_CTRL_REFSEL_B; // on chip reference
int rd_reg = 26; // base address of two regs to read for result
-
+
// program the ADC mux bits
if (tx_slot_p (slot))
aux_adc_control |= AUX_ADC_CTRL_SELECT_A2 | AUX_ADC_CTRL_SELECT_B2;
rd_reg += 2;
aux_adc_control |= AUX_ADC_CTRL_SELECT_A1 | AUX_ADC_CTRL_SELECT_B1;
}
-
+
// I'm not sure if we can set the mux and issue a start conversion
// in the same cycle, so let's do them one at a time.
if (r)
*value = ((v_hi << 2) | ((v_lo >> 6) & 0x3)) << 2; // format as 12-bit
-
+
return r;
}
/* -*- c++ -*- */
/*
* Copyright 2003,2004,2006,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,
int n_found = 0;
usrp_one_time_init ();
-
+
p = usb_get_busses();
while (p != NULL){
q = p->devices;
// Appears to be required for libusb-win32 and Cygwin -- dew 09/20/06
if (usb_set_configuration (udh, 1) < 0){
/*
- * Ignore this error.
+ * Ignore this error.
*
* Seems that something changed in drivers/usb/core/devio.c:proc_setconfig such that
* it returns -EBUSY if _any_ of the interfaces of a device are open.
/* -*- c++ -*- */
/*
* Copyright 2003,2004,2006,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,
/* -*- c++ -*- */
/*
- * Copyright 2003 Free Software Foundation, Inc.
- *
+ * Copyright 2003,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,
#include "usrp/usrp_prims.h"
/*
- * Internal functions
+ * Internal functions
*/
libusb_device_handle *
unsigned char *bytes, int len);
/*
- * Compatibility functions
+ * Compatibility functions
*/
libusb_device *_get_usb_device (libusb_device_handle *udh);