diff options
Diffstat (limited to 'gr-usrp/src')
36 files changed, 0 insertions, 4171 deletions
diff --git a/gr-usrp/src/.gitignore b/gr-usrp/src/.gitignore deleted file mode 100644 index 96caf587f..000000000 --- a/gr-usrp/src/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -/Makefile -/Makefile.in -/.deps -/.libs -/*.la -/*.lo -/usrp_swig.cc -/usrp_swig.py -/usrp_swig.scm -/run_tests -/run_guile_tests -/usrp_dbids.py -/*.pyc -/gnuradio -/guile -/python diff --git a/gr-usrp/src/Makefile.am b/gr-usrp/src/Makefile.am deleted file mode 100644 index 29cedc96a..000000000 --- a/gr-usrp/src/Makefile.am +++ /dev/null @@ -1,119 +0,0 @@ -# -# Copyright 2004,2005,2006,2008,2009,2010 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. -# - -include $(top_srcdir)/Makefile.common -include $(top_srcdir)/Makefile.swig - - -TESTS = -EXTRA_DIST += run_tests.in run_guile_tests.in $(nobase_guile_DATA) -DISTCLEANFILES += run_tests run_guile_tests - -noinst_PYTHON = qa_usrp.py -noinst_GUILE = usrp.test - -if GUILE -nobase_guile_DATA = gnuradio/usrp.scm -endif - -# ---------------------------------------------------------------- -# The straight C++ library - -AM_CPPFLAGS = \ - $(USRP_INCLUDES) \ - $(STD_DEFINES_AND_INCLUDES) \ - $(PYTHON_CPPFLAGS) \ - $(USB_INCLUDES) \ - $(WITH_INCLUDES) - -lib_LTLIBRARIES = \ - libgnuradio-usrp.la - -libgnuradio_usrp_la_SOURCES = \ - usrp_base.cc \ - usrp_sink_base.cc \ - usrp_sink_c.cc \ - usrp_sink_s.cc \ - usrp_source_base.cc \ - usrp_source_c.cc \ - usrp_source_s.cc - -libgnuradio_usrp_la_LIBADD = \ - $(GNURADIO_CORE_LA) \ - $(USRP_LA) - -libgnuradio_usrp_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) - -grinclude_HEADERS = \ - usrp_base.h \ - usrp_sink_base.h \ - usrp_sink_c.h \ - usrp_sink_s.h \ - usrp_source_base.h \ - usrp_source_c.h \ - usrp_source_s.h - -# ---------------------------------------------------------------- -# The SWIG library - -TOP_SWIG_IFILES = \ - usrp_swig.i - -# Install so that they end up available as: -# import gnuradio.usrp -# This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gnuradio/usrp -usrp_swig_pythondir_category = \ - gnuradio/usrp - -# additional arguments to the SWIG command -usrp_swig_swig_args = \ - $(DEFAULT_INCLUDES) \ - $(USRP_INCLUDES) - -# additional libraries for linking with the SWIG-generated library -usrp_swig_la_swig_libadd = \ - libgnuradio-usrp.la - -# additional Python files to be installed along with the SWIG-generated one -usrp_swig_python = \ - __init__.py - -# additional SWIG files to be installed -usrp_swig_swiginclude_headers = \ - usrp_base.i \ - usrp_source_base.i \ - usrp_source_c.i \ - usrp_source_s.i \ - usrp_sink_base.i \ - usrp_sink_c.i \ - usrp_sink_s.i \ - usrp_standard.i - - -if PYTHON -TESTS += run_tests -endif - -if GUILE -TESTS += run_guile_tests -endif - diff --git a/gr-usrp/src/Makefile.swig.gen b/gr-usrp/src/Makefile.swig.gen deleted file mode 100644 index 00ecfcb54..000000000 --- a/gr-usrp/src/Makefile.swig.gen +++ /dev/null @@ -1,145 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 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. -# - -# Makefile.swig.gen for usrp_swig.i - -## Default install locations for these files: -## -## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/usrp_swig -## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/usrp_swig -## -## The following can be overloaded to change the install location, but -## this has to be done in the including Makefile.am -before- -## Makefile.swig is included. - -usrp_swig_pythondir_category ?= gnuradio/usrp_swig -usrp_swig_pylibdir_category ?= $(usrp_swig_pythondir_category) -usrp_swig_pythondir = $(pythondir)/$(usrp_swig_pythondir_category) -usrp_swig_pylibdir = $(pyexecdir)/$(usrp_swig_pylibdir_category) - -# The .so libraries for the guile modules get installed whereever guile -# is installed, usually /usr/lib/guile/gnuradio/ -# FIXME: determince whether these should be installed with gnuradio. -usrp_swig_scmlibdir = $(libdir) - -# The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/usrp_swig -# FIXME: determince whether these should be installed with gnuradio. -usrp_swig_scmdir = $(guiledir) - -## SWIG headers are always installed into the same directory. - -usrp_swig_swigincludedir = $(swigincludedir) - -## This is a template file for a "generated" Makefile addition (in -## this case, "Makefile.swig.gen"). By including the top-level -## Makefile.swig, this file will be used to generate the SWIG -## dependencies. Assign the variable TOP_SWIG_FILES to be the list of -## SWIG .i files to generated wrappings for; there can be more than 1 -## so long as the names are unique (no sorting is done on the -## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i -## file will generate .cc, .py, and possibly .h files -- meaning that -## all of these files will have the same base name (that provided for -## the SWIG .i file). -## -## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the -## right thing. For more info, see < -## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > - -## Other cleaned files: dependency files generated by SWIG or this Makefile - -MOSTLYCLEANFILES += $(DEPDIR)/*.S* - -## Various SWIG variables. These can be overloaded in the including -## Makefile.am by setting the variable value there, then including -## Makefile.swig . - -usrp_swig_swiginclude_HEADERS = \ - usrp_swig.i \ - $(usrp_swig_swiginclude_headers) - -if PYTHON -usrp_swig_pylib_LTLIBRARIES = \ - _usrp_swig.la - -_usrp_swig_la_SOURCES = \ - python/usrp_swig.cc \ - $(usrp_swig_la_swig_sources) - -usrp_swig_python_PYTHON = \ - usrp_swig.py \ - $(usrp_swig_python) - -_usrp_swig_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(usrp_swig_la_swig_libadd) - -_usrp_swig_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(usrp_swig_la_swig_ldflags) - -_usrp_swig_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(usrp_swig_la_swig_cxxflags) - -python/usrp_swig.cc: usrp_swig.py -usrp_swig.py: usrp_swig.i - -# Include the python dependencies for this file --include python/usrp_swig.d - -endif # end of if python - -if GUILE - -usrp_swig_scmlib_LTLIBRARIES = \ - libguile-gnuradio-usrp_swig.la -libguile_gnuradio_usrp_swig_la_SOURCES = \ - guile/usrp_swig.cc \ - $(usrp_swig_la_swig_sources) -nobase_usrp_swig_scm_DATA = \ - gnuradio/usrp_swig.scm \ - gnuradio/usrp_swig-primitive.scm -libguile_gnuradio_usrp_swig_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(usrp_swig_la_swig_libadd) -libguile_gnuradio_usrp_swig_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(usrp_swig_la_swig_ldflags) -libguile_gnuradio_usrp_swig_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(usrp_swig_la_swig_cxxflags) - -guile/usrp_swig.cc: gnuradio/usrp_swig.scm -gnuradio/usrp_swig.scm: usrp_swig.i -gnuradio/usrp_swig-primitive.scm: gnuradio/usrp_swig.scm - -# Include the guile dependencies for this file --include guile/usrp_swig.d - -endif # end of GUILE - - diff --git a/gr-usrp/src/__init__.py b/gr-usrp/src/__init__.py deleted file mode 100644 index c81b2f2b0..000000000 --- a/gr-usrp/src/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright 2008 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. -# - -# The presence of this file turns this directory into a Python package - -# Add SWIG generated code to this namespace -from usrp_swig import * - -# Add other content from pure-Python modules here - diff --git a/gr-usrp/src/flexrf_debug_gui.py b/gr-usrp/src/flexrf_debug_gui.py deleted file mode 100755 index ff32900a5..000000000 --- a/gr-usrp/src/flexrf_debug_gui.py +++ /dev/null @@ -1,176 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005 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. -# - -import sys -import wx -from gnuradio.wxgui import form - -class flexrf_debug_gui(wx.Frame): - def __init__(self, flexrf, title="Flexrf Debug"): - wx.Frame.__init__(self, None, -1, title) - - self.flexrf = flexrf - - self.CreateStatusBar (1) - - self.panel = wx.Panel(self, -1) - self.vbox = wx.BoxSizer(wx.VERTICAL) - self.panel.SetSizer(self.vbox) - self.panel.SetAutoLayout(True) - - self._create_form() - - self.vbox.Fit(self.panel) - - self.frame_vbox = wx.BoxSizer(wx.VERTICAL) - self.frame_vbox.Add(self.panel, 1, wx.EXPAND) - self.SetSizer(self.frame_vbox) - self.SetAutoLayout(True) - self.frame_vbox.Fit(self) - - def _create_form(self): - self._create_set_freq() - self._create_write_fpga() - self._create_write_all() - self._create_write_it() - #self._create_set_gain() - - # ---------------------------------------------------------------- - - def _create_set_freq(self): - - def _set_freq(kv): - return self.flexrf.set_freq(kv['freq'])[0] - - sbs = wx.StaticBoxSizer(wx.StaticBox(self.panel), wx.HORIZONTAL) - sbs.Add((5,0), 0.1) # stretchy space - #sbs.Add(wx.StaticText(self.panel, -1, "set_freq "), 0, 0) - #sbs.Add((5,0), 0.1) # stretchy space - myform = form.form() - myform['freq'] = form.float_field(self.panel, sbs, "Set Frequency") - sbs.Add((5,0), 0.1) # stretchy space - sbs.Add(form.button_with_callback(self.panel, "Do It!", - self._generic_doit(_set_freq, myform)), 1, wx.EXPAND) - sbs.Add((5,0), 0.1) # stretchy space - self.vbox.Add(sbs, 0, wx.EXPAND) - - - def _create_write_fpga(self): - - def _write_fpga(kv): - return self.flexrf._u._write_fpga_reg(kv['regno'], kv['value']) - - sbs = wx.StaticBoxSizer(wx.StaticBox(self.panel), wx.HORIZONTAL) - sbs.Add((5,0), 0.1) # stretchy space - sbs.Add(wx.StaticText(self.panel, -1, "write_fpga_reg "), 0, 0) - sbs.Add((5,0), 0.1) # stretchy space - myform = form.form() - myform['regno'] = form.int_field(self.panel, sbs, "regno") - sbs.Add((5,0), 0.1) # stretchy space - myform['value'] = form.int_field(self.panel, sbs, "value") - sbs.Add((5,0), 0.1) # stretchy space - sbs.Add(form.button_with_callback(self.panel, "Do It!", - self._generic_doit(_write_fpga, myform)), 1, wx.EXPAND) - sbs.Add((5,0), 0.1) # stretchy space - self.vbox.Add(sbs, 0, wx.EXPAND) - - - def _create_write_all(self): - - def _write_all(kv): - self.flexrf._write_all(kv['R'], kv['control'], kv['N']) # void - return True - - sbs = wx.StaticBoxSizer(wx.StaticBox(self.panel), wx.HORIZONTAL) - sbs.Add((5,0), 0.1) # stretchy space - sbs.Add(wx.StaticText(self.panel, -1, "write_all "), 0, 0) - sbs.Add((5,0), 0.1) # stretchy space - myform = form.form() - myform['R'] = form.int_field(self.panel, sbs, "R") - sbs.Add((5,0), 0.1) # stretchy space - myform['control'] = form.int_field(self.panel, sbs, "control") - sbs.Add((5,0), 0.1) # stretchy space - myform['N'] = form.int_field(self.panel, sbs, "N") - sbs.Add((5,0), 0.1) # stretchy space - sbs.Add(form.button_with_callback(self.panel, "Do It!", - self._generic_doit(_write_all, myform)), 1, wx.EXPAND) - sbs.Add((5,0), 0.1) # stretchy space - self.vbox.Add(sbs, 0, wx.EXPAND) - - - def _create_write_it(self): - - def _write_it(kv): - self.flexrf._write_it(kv['v']) # void - return True - - sbs = wx.StaticBoxSizer(wx.StaticBox(self.panel), wx.HORIZONTAL) - sbs.Add((5,0), 0.1) # stretchy space - sbs.Add(wx.StaticText(self.panel, -1, "write_it "), 0, 0) - sbs.Add((5,0), 0.1) # stretchy space - myform = form.form() - myform['v'] = form.int_field(self.panel, sbs, "24-bit value") - sbs.Add((5,0), 0.1) # stretchy space - sbs.Add(form.button_with_callback(self.panel, "Do It!", - self._generic_doit(_write_it, myform)), 1, wx.EXPAND) - sbs.Add((5,0), 0.1) # stretchy space - self.vbox.Add(sbs, 0, wx.EXPAND) - - - # ---------------------------------------------------------------- - - def _set_status_msg(self, msg): - self.GetStatusBar().SetStatusText(msg, 0) - - def _generic_doit(self, callback, form): - - def button_callback(): - errors = form.check_input_for_errors() - if errors: - self._set_status_msg(errors[0]) - print '\n'.join(tuple(errors)) - else: - kv = form.get_key_vals() - if callback(kv): - self._set_status_msg("OK") - else: - self._set_status_msg("Failed") - - return button_callback - - - -if False and __name__ == '__main__': - - class demo_app (wx.App): - def __init__ (self): - wx.App.__init__(self) - - def OnInit (self): - frame = flexrf_debug_gui(None, "Debug FlexRF TX") - frame.Show(True) - self.SetTopWindow (frame) - return True - - app = demo_app() - app.MainLoop() - diff --git a/gr-usrp/src/gnuradio/.gitignore b/gr-usrp/src/gnuradio/.gitignore deleted file mode 100644 index 0c4d489ab..000000000 --- a/gr-usrp/src/gnuradio/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -usrp_swig-primitive.scm -usrp_swig.scm diff --git a/gr-usrp/src/gnuradio/usrp.scm b/gr-usrp/src/gnuradio/usrp.scm deleted file mode 100644 index e01c9454a..000000000 --- a/gr-usrp/src/gnuradio/usrp.scm +++ /dev/null @@ -1,27 +0,0 @@ -;;; -;;; Copyright 2010 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 this program. If not, see <http://www.gnu.org/licenses/>. -;;; - -;;; Semi bogus module that just re-exports the usrp_swig module - -(define-module (gnuradio usrp) - #:use-module (gnuradio export-safely) - #:use-module (gnuradio usrp_swig) - #:duplicates (merge-generics replace check)) - -(re-export-all '(gnuradio usrp_swig)) diff --git a/gr-usrp/src/qa_usrp.py b/gr-usrp/src/qa_usrp.py deleted file mode 100755 index 06e630330..000000000 --- a/gr-usrp/src/qa_usrp.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2010 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. -# - -from gnuradio import gr, gr_unittest -import usrp_swig - -class test_usrp (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_000_nop (self): - """Just see if we can import the module... - They may not have a USRP connected, etc. Don't try to run anything""" - pass - -if __name__ == '__main__': - gr_unittest.run(test_usrp, "test_usrp.xml") diff --git a/gr-usrp/src/run_guile_tests.in b/gr-usrp/src/run_guile_tests.in deleted file mode 100644 index 5d08b0dd5..000000000 --- a/gr-usrp/src/run_guile_tests.in +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -. @top_builddir@/setup_guile_test_env - -# 1st argument is absolute path to hand coded guile source directory -# 2nd argument is absolute path to component C++ shared library build directory -# 3nd argument is absolute path to component SWIG build directory - -add_local_paths \ - @srcdir@ \ - @abs_builddir@ \ - @abs_builddir@ - -@GUILE@ -e main -c '(use-modules (gnuradio test-suite guile-test))' -t @srcdir@ diff --git a/gr-usrp/src/run_tests.in b/gr-usrp/src/run_tests.in deleted file mode 100644 index c03f96e0b..000000000 --- a/gr-usrp/src/run_tests.in +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -# 1st parameter is absolute path to component source directory -# 2nd parameter is absolute path to component build directory -# 3rd parameter is path to Python QA directory - -# For OS/X -DYLD_LIBRARY_PATH=@abs_top_builddir@/usrp/host/lib:@abs_top_builddir@/usrp/host/lib/.libs:$DYLD_LIBRARY_PATH -export DYLD_LIBRARY_PATH - -# For Win32 -PATH=@abs_top_builddir@/usrp/host/lib:@abs_top_builddir@/usrp/host/lib/.libs:$PATH - -@top_builddir@/run_tests.sh \ - @abs_top_srcdir@/gr-usrp \ - @abs_top_builddir@/gr-usrp \ - @srcdir@ diff --git a/gr-usrp/src/tx_debug_gui.py b/gr-usrp/src/tx_debug_gui.py deleted file mode 100755 index 6b2a0c259..000000000 --- a/gr-usrp/src/tx_debug_gui.py +++ /dev/null @@ -1,187 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005 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. -# - -import sys -import wx -from gnuradio.wxgui import form - -class tx_debug_gui(wx.Frame): - def __init__(self, tx_subdev, title="Tx Debug"): - wx.Frame.__init__(self, None, -1, title) - - self.subdev = tx_subdev - self.subdev._u.set_verbose(True) - - self.CreateStatusBar (1) - - self.panel = wx.Panel(self, -1) - self.vbox = wx.BoxSizer(wx.VERTICAL) - self.panel.SetSizer(self.vbox) - self.panel.SetAutoLayout(True) - - self._create_form() - - self.vbox.Fit(self.panel) - - self.frame_vbox = wx.BoxSizer(wx.VERTICAL) - self.frame_vbox.Add(self.panel, 1, wx.EXPAND) - self.SetSizer(self.frame_vbox) - self.SetAutoLayout(True) - self.frame_vbox.Fit(self) - - # ---------------------------------------------------------------- - - def _write_9862(self, regno, v): - return self.subdev._u._write_9862(self.subdev._which, regno, v) - - def _set_dac_offset(self, i_or_q, offset, offset_pin): - return self.subdev._u.set_dac_offset(self.subdev._which * 2 + i_or_q, offset, offset_pin) - - def _set_dac_fine_gain(self, i_or_q, gain, coarse): - return self._write_9862(14 + i_or_q, (coarse & 0xC0) | (gain & 0x3f)) - - def _create_form(self): - self._create_dac_offset() - self._create_dac_fine_gain() - self._create_pga() - - # ---------------------------------------------------------------- - - def _create_dac_offset(self): - - sbs = wx.StaticBoxSizer(wx.StaticBox(self.panel), wx.VERTICAL) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add(wx.StaticText(self.panel, -1, "DAC Offset"), 5, 0) - sbs.Add(hbox, 0, 1) - - - self._create_dac_offset_helper(sbs, 0) - self._create_dac_offset_helper(sbs, 1) - - self.vbox.Add(sbs, 0, wx.EXPAND) - - def _create_dac_offset_helper(self, vbox, i_or_q): - - def doit(kv): - drive_positive = kv['drive_positive'] - dac_offset = kv['dac_offset'] - print "drive_positive =", drive_positive - print "dac_offset[%d] = %4d" % (i_or_q, dac_offset) - - # FIXME signed magnitude?? - # dac_offset = signed_mag10(dac_offset) - return self._set_dac_offset(i_or_q, dac_offset, int(drive_positive)) - - def signed_mag10(x): - # not clear from doc if this is really 2's comp or 10-bit signed magnitude - # we'll guess it's 10-bit signed mag - if x < 0: - return (1 << 9) | min(511, max(0, abs(x))) - else: - return (0 << 9) | min(511, max(0, abs(x))) - - myform = form.form() - hbox = wx.BoxSizer(wx.HORIZONTAL) - vbox.Add(hbox, 0, wx.EXPAND) - myform['drive_positive'] = form.checkbox_field(parent=self.panel, sizer=hbox, - callback=myform.check_input_and_call(doit), - weight=0, - label="drive +ve") - myform['dac_offset'] = form.slider_field(parent=self.panel, sizer=hbox, - callback=myform.check_input_and_call(doit), - min=-512, max=511, value=0, - weight=5) - - # ---------------------------------------------------------------- - - def _create_dac_fine_gain(self): - sbs = wx.StaticBoxSizer(wx.StaticBox(self.panel), wx.VERTICAL) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add(wx.StaticText(self.panel, -1, "DAC Gain"), 5, 0) - sbs.Add(hbox, 0, 1) - - self._create_dac_gain_helper(sbs, 0) - self._create_dac_gain_helper(sbs, 1) - - self.vbox.Add(sbs, 0, wx.EXPAND) - - def _create_dac_gain_helper(self, vbox, i_or_q): - - d = { "1/1" : 0xC0, - "1/2" : 0x40, - "1/11" : 0x00 } - - def doit(kv): - dac_gain = kv['dac_gain'] - coarse_s = kv['coarse'] - print "dac_gain[%d] = %4d" % (i_or_q, dac_gain) - print "coarse = ", coarse_s - return self._set_dac_fine_gain(i_or_q, dac_gain, d[coarse_s]) - - myform = form.form() - hbox = wx.BoxSizer(wx.HORIZONTAL) - vbox.Add(hbox, 0, wx.EXPAND) - myform['coarse'] = form.radiobox_field(parent=self.panel, sizer=hbox, - callback=myform.check_input_and_call(doit), - choices=['1/11', '1/2', '1/1'], - weight=1, value='1/1') - myform['dac_gain'] = form.slider_field(parent=self.panel, sizer=hbox, - callback=myform.check_input_and_call(doit), - min=-32, max=31, value=0, - weight=4) - - - # ---------------------------------------------------------------- - - def _create_pga(self): - sbs = wx.StaticBoxSizer(wx.StaticBox(self.panel), wx.VERTICAL) - - form.quantized_slider_field(parent=self.panel, sizer=sbs, label="PGA", - weight=3, range=self.subdev.gain_range(), - callback=self.subdev.set_gain) - - self.vbox.Add(sbs, 0, wx.EXPAND) - - - # ---------------------------------------------------------------- - - - def _set_status_msg(self, msg): - self.GetStatusBar().SetStatusText(msg, 0) - - -if False and __name__ == '__main__': - - class demo_app (wx.App): - def __init__ (self): - wx.App.__init__(self) - - def OnInit (self): - frame = tx_debug_gui(None, "Debug TX") - frame.Show(True) - self.SetTopWindow (frame) - return True - - app = demo_app() - app.MainLoop() diff --git a/gr-usrp/src/usrp.test b/gr-usrp/src/usrp.test deleted file mode 100644 index 740fe3055..000000000 --- a/gr-usrp/src/usrp.test +++ /dev/null @@ -1,37 +0,0 @@ -;;; -*- Scheme -*- -;;; -;;; Copyright 2010 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 this program. If not, see <http://www.gnu.org/licenses/>. -;;; - -;;; If you're using Emacs's Scheme mode: -;;; (put 'with-test-prefix 'scheme-indent-function 1) - -;;; See the comments in gnuradio/test-suite/lib.scm for info on writing tests. -;;; See also the very end of the file, where the test-equal, test-eqv -;;; and test-eq macros are defined. - -(define-module (test-module) - #:use-module (oop goops) - #:use-module (gnuradio core) - #:use-module (gnuradio test-suite lib) - #:duplicates (merge-generics replace check)) - -;;; Just see if we can import the module... -;;; They may not have a USRP attached and powered up - -(use-modules (gnuradio usrp)) diff --git a/gr-usrp/src/usrp_base.cc b/gr-usrp/src/usrp_base.cc deleted file mode 100644 index 1d632a567..000000000 --- a/gr-usrp/src/usrp_base.cc +++ /dev/null @@ -1,322 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <usrp_base.h> -#include <usrp/usrp_basic.h> - -class truth_table_element_t -{ -public: - truth_table_element_t(int side, unsigned int uses, bool swap_iq, unsigned int mux_val); - bool operator==(const truth_table_element_t &in); - bool operator!=(const truth_table_element_t &in); - - unsigned int mux_val() { return d_mux_val; } - -private: - int d_side; - unsigned int d_uses; - bool d_swap_iq; - unsigned int d_mux_val; -}; - - -usrp_base::~usrp_base() -{ -} - -void -usrp_base::set_usrp_basic(boost::shared_ptr<usrp_basic> u) -{ - d_usrp_basic = u; -} - -std::vector<std::vector<db_base_sptr> > -usrp_base::db() -{ - return d_usrp_basic->db(); -} - -std::vector<db_base_sptr> -usrp_base::db(int which_side) -{ - return d_usrp_basic->db(which_side); -} - -db_base_sptr -usrp_base::db(int which_side, int which_dev) -{ - return d_usrp_basic->selected_subdev(usrp_subdev_spec(which_side, which_dev)); -} - -db_base_sptr -usrp_base::selected_subdev(usrp_subdev_spec ss) -{ - return d_usrp_basic->selected_subdev(ss); -} - -long -usrp_base::fpga_master_clock_freq() const -{ - return d_usrp_basic->fpga_master_clock_freq(); -} - -void -usrp_base::set_fpga_master_clock_freq(long master_clock) -{ - d_usrp_basic->set_fpga_master_clock_freq(master_clock); -} - -void -usrp_base::set_verbose (bool verbose) -{ - d_usrp_basic->set_verbose (verbose); -} - -bool -usrp_base::write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf) -{ - return d_usrp_basic->write_eeprom (i2c_addr, eeprom_offset, buf); -} - -std::string -usrp_base::read_eeprom (int i2c_addr, int eeprom_offset, int len) -{ - return d_usrp_basic->read_eeprom (i2c_addr, eeprom_offset, len); -} - -bool -usrp_base::write_i2c (int i2c_addr, const std::string buf) -{ - return d_usrp_basic->write_i2c (i2c_addr, buf); -} - -std::string -usrp_base::read_i2c (int i2c_addr, int len) -{ - return d_usrp_basic->read_i2c (i2c_addr, len); -} - -bool -usrp_base::set_adc_offset (int which, int offset) -{ - return d_usrp_basic->set_adc_offset (which, offset); -} - -bool -usrp_base::set_dac_offset (int which, int offset, int offset_pin) -{ - return d_usrp_basic->set_dac_offset (which, offset, offset_pin); -} - -bool -usrp_base::set_adc_buffer_bypass (int which, bool bypass) -{ - return d_usrp_basic->set_adc_buffer_bypass (which, bypass); -} - -bool -usrp_base::set_dc_offset_cl_enable(int bits, int mask) -{ - return d_usrp_basic->set_dc_offset_cl_enable(bits, mask); -} - -std::string -usrp_base::serial_number() -{ - return d_usrp_basic->serial_number(); -} - -int -usrp_base::daughterboard_id (int which) const -{ - return d_usrp_basic->daughterboard_id (which); -} - -bool -usrp_base::write_atr_tx_delay(int value) -{ - return d_usrp_basic->write_atr_tx_delay(value); -} - -bool -usrp_base::write_atr_rx_delay(int value) -{ - return d_usrp_basic->write_atr_rx_delay(value); -} - -bool -usrp_base::set_pga (int which, double gain) -{ - return d_usrp_basic->set_pga (which, gain); -} - -double -usrp_base::pga (int which) const -{ - return d_usrp_basic->pga (which); -} - -double -usrp_base::pga_min () const -{ - return d_usrp_basic->pga_min (); -} - -double -usrp_base::pga_max () const -{ - return d_usrp_basic->pga_max (); -} - -double -usrp_base::pga_db_per_step () const -{ - return d_usrp_basic->pga_db_per_step (); -} - -bool -usrp_base::_write_oe (int which_dboard, int value, int mask) -{ - return d_usrp_basic->_write_oe (which_dboard, value, mask); -} - -bool -usrp_base::write_io (int which_dboard, int value, int mask) -{ - return d_usrp_basic->write_io (which_dboard, value, mask); -} - -int -usrp_base::read_io (int which_dboard) -{ - return d_usrp_basic->read_io (which_dboard); -} - -bool -usrp_base::write_atr_mask(int which_side, int value) -{ - return d_usrp_basic->write_atr_mask(which_side, value); -} - -bool -usrp_base::write_atr_txval(int which_side, int value) -{ - return d_usrp_basic->write_atr_txval(which_side, value); -} - -bool -usrp_base::write_atr_rxval(int which_side, int value) -{ - return d_usrp_basic->write_atr_rxval(which_side, value); -} - -bool -usrp_base::write_aux_dac (int which_dboard, int which_dac, int value) -{ - return d_usrp_basic->write_aux_dac (which_dboard, which_dac, value); -} - -int -usrp_base::read_aux_adc (int which_dboard, int which_adc) -{ - return d_usrp_basic->read_aux_adc (which_dboard, which_adc); -} - -long -usrp_base::converter_rate() const -{ - return d_usrp_basic->converter_rate(); -} - -bool -usrp_base::_set_led(int which_led, bool on) -{ - return d_usrp_basic->_set_led(which_led, on); -} - -bool -usrp_base::_write_fpga_reg (int regno, int value) -{ - return d_usrp_basic->_write_fpga_reg (regno, value); -} - -bool -usrp_base::_write_fpga_reg_masked (int regno, int value, int mask) -{ - return d_usrp_basic->_write_fpga_reg_masked (regno, value, mask); -} - -int -usrp_base::_read_fpga_reg (int regno) -{ - return d_usrp_basic->_read_fpga_reg (regno); -} - -bool -usrp_base::_write_9862 (int which_codec, int regno, unsigned char value) -{ - return d_usrp_basic->_write_9862 (which_codec, regno, value); -} - -int -usrp_base::_read_9862 (int which_codec, int regno) const -{ - return d_usrp_basic->_read_9862 (which_codec, regno); -} - -bool -usrp_base::_write_spi (int optional_header, int enables, - int format, std::string buf) -{ - return d_usrp_basic->_write_spi (optional_header, enables, format, buf); -} - -std::string -usrp_base::_read_spi (int optional_header, int enables, int format, int len) -{ - return d_usrp_basic->_read_spi (optional_header, enables, format, len); -} - -usrp_subdev_spec -usrp_base::pick_subdev(std::vector<int> candidates) -{ - int dbid0 = db(0, 0)->dbid(); - int dbid1 = db(1, 0)->dbid(); - - for (int i = 0; i < candidates.size(); i++) { - int dbid = candidates[i]; - if (dbid0 == dbid) - return usrp_subdev_spec(0, 0); - if (dbid1 == dbid) - return usrp_subdev_spec(1, 0); - } - - if (dbid0 >= 0) - return usrp_subdev_spec(0, 0); - if (dbid1 >= 0) - return usrp_subdev_spec(1, 0); - - throw std::runtime_error("No suitable daughterboard found!"); -} diff --git a/gr-usrp/src/usrp_base.h b/gr-usrp/src/usrp_base.h deleted file mode 100644 index 7947723fb..000000000 --- a/gr-usrp/src/usrp_base.h +++ /dev/null @@ -1,452 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_USRP_BASE_H -#define INCLUDED_USRP_BASE_H - -#include <gr_sync_block.h> -#include <stdexcept> -#include <boost/shared_ptr.hpp> -#include <usrp/db_base.h> -#include <usrp/usrp_subdev_spec.h> - -class usrp_basic; - -/*! - * \brief base class for GNU Radio interface to the USRP - */ -class usrp_base : public gr_sync_block { -private: - boost::shared_ptr<usrp_basic> d_usrp_basic; - -protected: - usrp_base(const std::string &name, - gr_io_signature_sptr input_signature, - gr_io_signature_sptr output_signature) - : gr_sync_block(name, input_signature, output_signature) {} - - - void set_usrp_basic(boost::shared_ptr<usrp_basic> u); - -public: - virtual ~usrp_base(); - - /* ! - * Return a vector of vectors of daughterboard instances associated with - * the USRP source or sink. The first dimension of the returned vector - * corresponds to the side of the USRP, the second dimension, the subdevice - * on the particular daughterboard. - * - * N.B. To ensure proper lifetime management, the caller should - * continue to hold these as weak pointers, not shared pointers. - * As long as the caller does not attempt to directly use the weak - * pointers after this usrp object has been destroyed, everything - * will work out fine. - */ - std::vector<std::vector<db_base_sptr> > db(); - - /*! - * Return a vector of size 1 or 2 that contains shared pointers - * to the daughterboard instance(s) associated with the specified side. - * - * \param which_side [0,1] which daughterboard - * - * N.B. To ensure proper lifetime management, the caller should - * continue to hold these as weak pointers, not shared pointers. - * As long as the caller does not attempt to directly use the weak - * pointers after this usrp object has been destroyed, everything - * will work out fine. - */ - std::vector<db_base_sptr> db(int which_side); - - /*! - * Return the daughterboard instance corresponding to the selected - * side of the USRP and selected daughterboard subdevice. - * N.B. To ensure proper lifetime management, the caller should - * continue to hold these as weak pointers, not shared pointers. - * As long as the caller does not attempt to directly use the weak - * pointers after this usrp object has been destroyed, everything - * will work out fine. - */ - db_base_sptr db(int which_side, int which_dev); - - /*! - * \brief given a usrp_subdev_spec, return the corresponding daughterboard object. - * \throws std::invalid_argument if ss is invalid. - * - * \param ss specifies the side and subdevice - */ - db_base_sptr selected_subdev(usrp_subdev_spec ss); - - /*! - * \brief return frequency of master oscillator on USRP - */ - long fpga_master_clock_freq() const; - - /*! - * Tell API that the master oscillator on the USRP is operating at a non-standard - * fixed frequency. This is only needed for custom USRP hardware modified to - * operate at a different frequency from the default factory configuration. This - * function must be called prior to any other API function. - * \param master_clock USRP2 FPGA master clock frequency in Hz (10..64 MHz) - */ - void set_fpga_master_clock_freq (long master_clock); - - void set_verbose (bool on); - - //! magic value used on alternate register read interfaces - static const int READ_FAILED = -99999; - - /*! - * \brief Write EEPROM on motherboard or any daughterboard. - * \param i2c_addr I2C bus address of EEPROM - * \param eeprom_offset byte offset in EEPROM to begin writing - * \param buf the data to write - * \returns true iff sucessful - */ - bool write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf); - - /*! - * \brief Read EEPROM on motherboard or any daughterboard. - * \param i2c_addr I2C bus address of EEPROM - * \param eeprom_offset byte offset in EEPROM to begin reading - * \param len number of bytes to read - * \returns the data read if successful, else a zero length string. - */ - std::string read_eeprom (int i2c_addr, int eeprom_offset, int len); - - /*! - * \brief Write to I2C peripheral - * \param i2c_addr I2C bus address (7-bits) - * \param buf the data to write - * \returns true iff successful - * Writes are limited to a maximum of of 64 bytes. - */ - bool write_i2c (int i2c_addr, const std::string buf); - - /*! - * \brief Read from I2C peripheral - * \param i2c_addr I2C bus address (7-bits) - * \param len number of bytes to read - * \returns the data read if successful, else a zero length string. - * Reads are limited to a maximum of 64 bytes. - */ - std::string read_i2c (int i2c_addr, int len); - - /*! - * \brief Set ADC offset correction - * \param which_adc which ADC[0,3]: 0 = RX_A I, 1 = RX_A Q... - * \param offset 16-bit value to subtract from raw ADC input. - */ - bool set_adc_offset (int which_adc, int offset); - - /*! - * \brief Set DAC offset correction - * \param which_dac which DAC[0,3]: 0 = TX_A I, 1 = TX_A Q... - * \param offset 10-bit offset value (ambiguous format: See AD9862 datasheet). - * \param offset_pin 1-bit value. If 0 offset applied to -ve differential pin; - * If 1 offset applied to +ve differential pin. - */ - bool set_dac_offset (int which_dac, int offset, int offset_pin); - - /*! - * \brief Control ADC input buffer - * \param which_adc which ADC[0,3] - * \param bypass if non-zero, bypass input buffer and connect input - * directly to switched cap SHA input of RxPGA. - */ - bool set_adc_buffer_bypass (int which_adc, bool bypass); - - /*! - * \brief Enable/disable automatic DC offset removal control loop in FPGA - * - * \param bits which control loops to enable - * \param mask which \p bits to pay attention to - * - * If the corresponding bit is set, enable the automatic DC - * offset correction control loop. - * - * <pre> - * The 4 low bits are significant: - * - * ADC0 = (1 << 0) - * ADC1 = (1 << 1) - * ADC2 = (1 << 2) - * ADC3 = (1 << 3) - * </pre> - * - * By default the control loop is enabled on all ADC's. - */ - bool set_dc_offset_cl_enable(int bits, int mask); - - /*! - * \brief return the usrp's serial number. - * - * \returns non-zero length string iff successful. - */ - std::string serial_number(); - - /*! - * \brief Return daughterboard ID for given side [0,1]. - * - * \param which_side [0,1] which daughterboard - * - * \return daughterboard id >= 0 if successful - * \return -1 if no daugherboard - * \return -2 if invalid EEPROM on daughterboard - */ - virtual int daughterboard_id (int which_side) const; - - /*! - * \brief Clock ticks to delay rising of T/R signal - * \sa write_atr_mask, write_atr_txval, write_atr_rxval - */ - bool write_atr_tx_delay(int value); - - /*! - * \brief Clock ticks to delay falling edge of T/R signal - * \sa write_atr_mask, write_atr_txval, write_atr_rxval - */ - bool write_atr_rx_delay(int value); - - /*! - * \brief Set Programmable Gain Amplifier (PGA) - * - * \param which_amp which amp [0,3] - * \param gain_in_db gain value (linear in dB) - * - * gain is rounded to closest setting supported by hardware. - * - * \returns true iff sucessful. - * - * \sa pga_min(), pga_max(), pga_db_per_step() - */ - bool set_pga (int which_amp, double gain_in_db); - - /*! - * \brief Return programmable gain amplifier gain setting in dB. - * - * \param which_amp which amp [0,3] - */ - double pga (int which_amp) const; - - /*! - * \brief Return minimum legal PGA gain in dB. - */ - double pga_min () const; - - /*! - * \brief Return maximum legal PGA gain in dB. - */ - double pga_max () const; - - /*! - * \brief Return hardware step size of PGA (linear in dB). - */ - double pga_db_per_step () const; - - /*! - * \brief Write direction register (output enables) for pins that go to daughterboard. - * - * \param which_side [0,1] which size - * \param value value to write into register - * \param mask which bits of value to write into reg - * - * Each d'board has 16-bits of general purpose i/o. - * Setting the bit makes it an output from the FPGA to the d'board. - * - * This register is initialized based on a value stored in the - * d'board EEPROM. In general, you shouldn't be using this routine - * without a very good reason. Using this method incorrectly will - * kill your USRP motherboard and/or daughterboard. - */ - bool _write_oe (int which_side, int value, int mask); - - /*! - * \brief Write daughterboard i/o pin value - * - * \param which_side [0,1] which d'board - * \param value value to write into register - * \param mask which bits of value to write into reg - */ - bool write_io (int which_side, int value, int mask); - - /*! - * \brief Read daughterboard i/o pin value - * - * \param which_side [0,1] which d'board - * \returns register value if successful, else READ_FAILED - */ - int read_io (int which_side); - - /*! - * \brief Write daughterboard refclk config register - * - * \param which_side [0,1] which d'board - * \param value value to write into register, see below - * - * <pre> - * Control whether a reference clock is sent to the daughterboards, - * and what frequency. The refclk is sent on d'board i/o pin 0. - * - * 3 2 1 - * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 - * +-----------------------------------------------+-+------------+ - * | Reserved (Must be zero) |E| DIVISOR | - * +-----------------------------------------------+-+------------+ - * - * Bit 7 -- 1 turns on refclk, 0 allows IO use - * Bits 6:0 Divider value - * </pre> - */ - bool write_refclk(int which_side, int value); - - bool write_atr_mask(int which_side, int value); - bool write_atr_txval(int which_side, int value); - bool write_atr_rxval(int which_side, int value); - - /*! - * \brief Write auxiliary digital to analog converter. - * - * \param which_side [0,1] which d'board - * N.B., SLOT_TX_A and SLOT_RX_A share the same AUX DAC's. - * SLOT_TX_B and SLOT_RX_B share the same AUX DAC's. - * \param which_dac [2,3] TX slots must use only 2 and 3. - * \param value [0,4095] - * \returns true iff successful - */ - bool write_aux_dac (int which_side, int which_dac, int value); - - /*! - * \brief Read auxiliary analog to digital converter. - * - * \param which_side [0,1] which d'board - * \param which_adc [0,1] - * \returns value in the range [0,4095] if successful, else READ_FAILED. - */ - int read_aux_adc (int which_side, int which_adc); - - /*! - * \brief returns A/D or D/A converter rate in Hz - */ - long converter_rate() const; - - - // ---------------------------------------------------------------- - // Low level implementation routines. - // You probably shouldn't be using these... - // - - bool _set_led (int which_led, bool on); - - /*! - * \brief Write FPGA register. - * \param regno 7-bit register number - * \param value 32-bit value - * \returns true iff successful - */ - bool _write_fpga_reg (int regno, int value); //< 7-bit regno, 32-bit value - - /*! - * \brief Read FPGA register. - * \param regno 7-bit register number - * \param value 32-bit value - * \returns true iff successful - */ - bool _read_fpga_reg (int regno, int *value); //< 7-bit regno, 32-bit value - - /*! - * \brief Read FPGA register. - * \param regno 7-bit register number - * \returns register value if successful, else READ_FAILED - */ - int _read_fpga_reg (int regno); - - /*! - * \brief Write FPGA register with mask. - * \param regno 7-bit register number - * \param value 16-bit value - * \param mask 16-bit value - * \returns true if successful - * Only use this for registers who actually implement a mask in the verilog firmware, like FR_RX_MASTER_SLAVE - */ - bool _write_fpga_reg_masked (int regno, int value, int mask); - - /*! - * \brief Write AD9862 register. - * \param which_codec 0 or 1 - * \param regno 6-bit register number - * \param value 8-bit value - * \returns true iff successful - */ - bool _write_9862 (int which_codec, int regno, unsigned char value); - - /*! - * \brief Read AD9862 register. - * \param which_codec 0 or 1 - * \param regno 6-bit register number - * \returns register value if successful, else READ_FAILED - */ - int _read_9862 (int which_codec, int regno) const; - - /*! - * \brief Write data to SPI bus peripheral. - * - * \param optional_header 0,1 or 2 bytes to write before buf. - * \param enables bitmask of peripherals to write. See usrp_spi_defs.h - * \param format transaction format. See usrp_spi_defs.h SPI_FMT_* - * \param buf the data to write - * \returns true iff successful - * Writes are limited to a maximum of 64 bytes. - * - * If \p format specifies that optional_header bytes are present, they are - * written to the peripheral immediately prior to writing \p buf. - */ - bool _write_spi (int optional_header, int enables, int format, std::string buf); - - /* - * \brief Read data from SPI bus peripheral. - * - * \param optional_header 0,1 or 2 bytes to write before buf. - * \param enables bitmask of peripheral to read. See usrp_spi_defs.h - * \param format transaction format. See usrp_spi_defs.h SPI_FMT_* - * \param len number of bytes to read. Must be in [0,64]. - * \returns the data read if sucessful, else a zero length string. - * - * Reads are limited to a maximum of 64 bytes. - * - * If \p format specifies that optional_header bytes are present, they - * are written to the peripheral first. Then \p len bytes are read from - * the peripheral and returned. - */ - std::string _read_spi (int optional_header, int enables, int format, int len); - - /*! - * Return an existing daughterboard from list of candidate dbids, or the first found - * on side A or side B. - * - * \param candidates Vector of candidate dbids - * - * Throws std::runtime_error if not found - */ - usrp_subdev_spec pick_subdev(std::vector<int> candidates=std::vector<int>(0)); -}; - -#endif /* INCLUDED_USRP_BASE_H */ diff --git a/gr-usrp/src/usrp_base.i b/gr-usrp/src/usrp_base.i deleted file mode 100644 index 0fd62911f..000000000 --- a/gr-usrp/src/usrp_base.i +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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. - */ - -%{ -#include "usrp_base.h" -%} - -%ignore usrp_base; -class usrp_base : public gr_sync_block -{ -protected: - usrp_base(const std::string &name, - gr_io_signature_sptr input_signature, - gr_io_signature_sptr output_signature) - : gr_sync_block(name, input_signature, output_signature) {} - -public: - std::vector<std::vector<db_base_sptr> > db(); - std::vector<db_base_sptr> db(int which_side); - db_base_sptr db(int which_side, int which_dev); - %rename (_real_selected_subdev) selected_subdev; - db_base_sptr selected_subdev(usrp_subdev_spec ss); - long fpga_master_clock_freq() const; - void set_fpga_master_clock_freq(long master_clock); - void set_verbose (bool on); - static const int READ_FAILED = -99999; - bool write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf); - std::string read_eeprom (int i2c_addr, int eeprom_offset, int len); - bool write_i2c (int i2c_addr, const std::string buf); - std::string read_i2c (int i2c_addr, int len); - bool set_adc_offset (int which_adc, int offset); - bool set_dac_offset (int which_dac, int offset, int offset_pin); - bool set_adc_buffer_bypass (int which_adc, bool bypass); - bool set_dc_offset_cl_enable(int bits, int mask); - std::string serial_number(); - virtual int daughterboard_id (int which_side) const; - bool write_atr_tx_delay(int value); - bool write_atr_rx_delay(int value); - bool set_pga (int which_amp, double gain_in_db); - double pga (int which_amp) const; - double pga_min () const; - double pga_max () const; - double pga_db_per_step () const; - bool _write_oe (int which_side, int value, int mask); - bool write_io (int which_side, int value, int mask); - int read_io (int which_side); - //bool write_refclk(int which_side, int value); - bool write_atr_mask(int which_side, int value); - bool write_atr_txval(int which_side, int value); - bool write_atr_rxval(int which_side, int value); - bool write_aux_dac (int which_side, int which_dac, int value); - int read_aux_adc (int which_side, int which_adc); - long converter_rate() const; - bool _set_led (int which_led, bool on); - bool _write_fpga_reg (int regno, int value); - //bool _read_fpga_reg (int regno, int *value); - int _read_fpga_reg (int regno); - bool _write_fpga_reg_masked (int regno, int value, int mask); - bool _write_9862 (int which_codec, int regno, unsigned char value); - int _read_9862 (int which_codec, int regno) const; - bool _write_spi (int optional_header, int enables, int format, std::string buf); - std::string _read_spi (int optional_header, int enables, int format, int len); - %rename(_real_pick_subdev) pick_subdev; - usrp_subdev_spec pick_subdev(std::vector<int> candidates=std::vector<int>(0)) - throw (std::runtime_error); -}; diff --git a/gr-usrp/src/usrp_multi.py b/gr-usrp/src/usrp_multi.py deleted file mode 100644 index c04d73124..000000000 --- a/gr-usrp/src/usrp_multi.py +++ /dev/null @@ -1,233 +0,0 @@ -# -# Copyright 2005,2008 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. -# - -import math -from gnuradio import gr, gru -from gnuradio.gr import hier_block2 -from gnuradio import usrp -from usrpm import usrp_prims -import sys - - -class multi_source_align(object): - def __init__(self, fg, master_serialno, decim, nchan=2, pga_gain=0.0, - cordic_freq=0.0, mux=None, align_interval=-1, - fpga_filename="multi_2rxhb_2tx.rbf"): - """ - Align multiple sources (usrps) using samplenumbers in the first channel. - - Takes two ore more sources producing interleaved shorts. - produces nchan * nsources gr_complex output streams. - - @param nchan: number of interleaved channels in source - @param align_interval: number of samples to minimally skip between alignments - default = -1 which means align only once per work call. - @param master_serial_no: serial number of the source which must be the master. - - - Exported sub-blocks (attributes): - master_source - slave_source - usrp_master - usrp_slave - """ - mode=usrp.FPGA_MODE_NORMAL - mode = mode | usrp_prims.bmFR_MODE_RX_COUNTING_32BIT #(1 << 2) #usrp1.FPGA_MODE_COUNTING_32BIT - align=gr.align_on_samplenumbers_ss (nchan,align_interval) - self.usrp_master = None - self.usrp_slave = None - # um is master usrp - # us is slave usrp - if mux is None: - mux=self.get_default_mux() #Note that all channels have shifted left because of the added 32 bit counter channel - - u1 = usrp.source_s (1, decim, nchan, gru.hexint(mux), mode,fpga_filename=fpga_filename ) - u0 = usrp.source_s (0, decim, nchan, gru.hexint(mux), mode,fpga_filename=fpga_filename ) - print 'usrp[0] serial',u0.serial_number() - print 'usrp[1] serial',u1.serial_number() - #default, choose the second found usrp as master (which is usually the usrp which was first plugged in) - um_index=1 - um=u1 - us_index=0 - us=u0 - if (not (master_serialno is None)): #((master_serialno>0) | (master_serialno <-2)): - if (u0.serial_number() == master_serialno): - um_index=0 - um=u0 - us_index=1 - us=u1 - elif (u1.serial_number() != master_serialno): - errorstring = 'Error. requested master_serialno ' + master_serialno +' not found\n' - errorstring = errorstring + 'Available are:\n' - errorstring = errorstring + 'usrp[1] serial_no = ' + u1.serial_number() +'\n' - errorstring = errorstring + 'usrp[0] serial_no = ' + u0.serial_number() +'\n' - print errorstring - raise ValueError, errorstring - else: #default, just choose the first found usrp as master - um_index=1 - um=u1 - us_index=0 - us=u0 - - self.usrp_master=um - self.usrp_slave=us - print 'usrp_master=usrp[%i] serial_no = %s' % (um_index,self.usrp_master.serial_number() ,) - print 'usrp_slave=usrp[%i] serial_no = %s' % (us_index,self.usrp_slave.serial_number() ,) - self.subdev_mAr = usrp.selected_subdev(self.usrp_master, (0,0)) - self.subdev_mBr = usrp.selected_subdev(self.usrp_master, (1,0)) - self.subdev_sAr = usrp.selected_subdev(self.usrp_slave, (0,0)) - self.subdev_sBr = usrp.selected_subdev(self.usrp_slave, (1,0)) - #throttle = gr.throttle(gr.sizeof_gr_complex, input_rate) - if not (pga_gain is None): - um.set_pga (0, pga_gain) - um.set_pga (1, pga_gain) - - us.set_pga (0, pga_gain) - us.set_pga (1, pga_gain) - - self.input_rate = um.adc_freq () / um.decim_rate () - deintm=gr.deinterleave(gr.sizeof_gr_complex) - deints=gr.deinterleave(gr.sizeof_gr_complex) - nullsinkm=gr.null_sink(gr.sizeof_gr_complex) - nullsinks=gr.null_sink(gr.sizeof_gr_complex) - - tocomplexm=gr.interleaved_short_to_complex() - tocomplexs=gr.interleaved_short_to_complex() - - fg.connect(um,(align,0)) - fg.connect(us,(align,1)) - fg.connect((align,0),tocomplexm) - fg.connect((align,1),tocomplexs) - fg.connect(tocomplexm,deintm) - fg.connect(tocomplexs,deints) - fg.connect((deintm,0),nullsinkm) #The counters are not usefull for the user but must be connected to something - fg.connect((deints,0),nullsinks) #The counters are not usefull for the user but must be connected to something - if 4==nchan: - nullsinkm3=gr.null_sink(gr.sizeof_gr_complex) - nullsinks3=gr.null_sink(gr.sizeof_gr_complex) - fg.connect((deintm,3), nullsinkm3) #channel 4 is not used but must be connected - fg.connect((deints,3), nullsinks3) #channel 4 is not used but must be connected - - self.fg=fg - self.master_source=deintm - self.slave_source=deints - - if not (cordic_freq is None): - um.set_rx_freq (1, cordic_freq) - um.set_rx_freq (0, cordic_freq) - us.set_rx_freq (1, cordic_freq) - us.set_rx_freq (0, cordic_freq) - - self.enable_master_and_slave() - # add an idle handler - self.unsynced=True - - # wire the block together - #hier_block_multi_tail.__init__(self, fg, nchan,deintm,deints) - - def get_default_mux(self): - return 0x10321032 # Note that all channels have shifted left because of the added 32 bit counter channel - - def get_master_source_c(self): - return self.master_source - - def get_slave_source_c(self): - return self.slave_source - - def get_master_usrp(self): - return self.usrp_master - - def get_slave_usrp(self): - return self.usrp_slave - - def enable_master_and_slave(self): - # Warning, allways FIRST enable the slave before you enable the master - # This is to be sure you don't have two masters connecting to each other - # Otherwise you could ruin your hardware because the two sync outputs would be connected together - - #SLAVE - #disable master, enable slave and set sync pulse to zero - reg_mask = usrp_prims.bmFR_RX_SYNC_SLAVE | usrp_prims.bmFR_RX_SYNC_MASTER | usrp_prims.bmFR_RX_SYNC - self.usrp_slave._u._write_fpga_reg_masked(usrp_prims.FR_RX_MASTER_SLAVE, usrp_prims.bmFR_RX_SYNC_SLAVE,reg_mask) - #set SYNC slave iopin on daughterboards RXA as input - oe = 0 # set rx_a_io[bitnoFR_RX_SYNC_INPUT_IOPIN] as input - oe_mask = usrp_prims.bmFR_RX_SYNC_INPUT_IOPIN - self.usrp_slave._u._write_oe(0,oe,oe_mask) - #Now it is save to enable the master - - #MASTER - #enable master, disable slave and set sync pulse to zero - reg_mask = usrp_prims.bmFR_RX_SYNC_SLAVE | usrp_prims.bmFR_RX_SYNC_MASTER | usrp_prims.bmFR_RX_SYNC - self.usrp_master._u._write_fpga_reg_masked(usrp_prims.FR_RX_MASTER_SLAVE,usrp_prims.bmFR_RX_SYNC_MASTER,reg_mask) - #set SYNC master iopin on daughterboards RXA as output - oe = usrp_prims.bmFR_RX_SYNC_OUTPUT_IOPIN # set rx_a_io[bitnoFR_RX_SYNC_OUTPUT_IOPIN] as output - oe_mask = usrp_prims.bmFR_RX_SYNC_OUTPUT_IOPIN - self.usrp_master._u._write_oe(0,oe,oe_mask) - - def sync_usrps(self, evt): - self.sync() - - def sync(self): - result=False - result = self.usrp_master._u._write_fpga_reg_masked (usrp_prims.FR_RX_MASTER_SLAVE, usrp_prims.bmFR_RX_SYNC, usrp_prims.bmFR_RX_SYNC ) - #There should be a small delay here, but the time it takes to get the sync to the usrp is long enough - #turn sync pulse off - result = result & self.usrp_master._u._write_fpga_reg_masked (usrp_prims.FR_RX_MASTER_SLAVE,0 ,usrp_prims.bmFR_RX_SYNC); - return result; - - def nullsink_counters(self): - nullsinkm=gr.null_sink(gr.sizeof_gr_complex) - nullsinks=gr.null_sink(gr.sizeof_gr_complex) - self.fg.connect((self.master_source,0),nullsinkm) - self.fg.connect((self.slave_source,0),nullsinks) - - - def print_db_info(self): - print "MASTER RX d'board %s" % (self.subdev_mAr.side_and_name(),) - print "MASTER RX d'board %s" % (self.subdev_mBr.side_and_name(),) - #print "TX d'board %s" % (self.subdev_At.side_and_name(),) - #print "TX d'board %s" % (self.subdev_Bt.side_and_name(),) - print "SLAVE RX d'board %s" % (self.subdev_sAr.side_and_name(),) - print "SLAVE RX d'board %s" % (self.subdev_sBr.side_and_name(),) - #print "TX d'board %s" % (self.subdev_At.side_and_name(),) - #print "TX d'board %s" % (self.subdev_Bt.side_and_name(),) - - def tune_all_rx(self,target_freq): - result = True - r1 = usrp.tune(self.usrp_master, 0, self.subdev_mAr, target_freq) - if r1 is None: - result=False - r2 = usrp.tune(self.usrp_master, 1, self.subdev_mBr, target_freq) - if r2 is None: - result=False - r3 = usrp.tune(self.usrp_slave, 0, self.subdev_sAr, target_freq) - if r3 is None: - result=False - r4 = usrp.tune(self.usrp_slave, 1, self.subdev_sBr, target_freq) - if r4 is None: - result=False - return result,r1,r2,r3,r4 - - def set_gain_all_rx(self, gain): - self.subdev_mAr.set_gain(gain) - self.subdev_mBr.set_gain(gain) - self.subdev_sAr.set_gain(gain) - self.subdev_sBr.set_gain(gain) diff --git a/gr-usrp/src/usrp_sink_base.cc b/gr-usrp/src/usrp_sink_base.cc deleted file mode 100644 index 635d9345f..000000000 --- a/gr-usrp/src/usrp_sink_base.cc +++ /dev/null @@ -1,248 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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_sink_base.h> -#include <gr_io_signature.h> -#include <usrp/usrp_standard.h> -#include <assert.h> -#include <cstdio> - -static const int OUTPUT_MULTIPLE_SAMPLES = 128; // DON'T CHANGE THIS VALUE! - -usrp_sink_base::usrp_sink_base (const std::string &name, - gr_io_signature_sptr input_signature, - int which_board, - unsigned int interp_rate, - int nchan, - int mux, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error) - : usrp_base(name, - input_signature, - gr_make_io_signature (0, 0, 0)), - d_nunderruns (0) -{ - d_usrp = usrp_standard_tx::make (which_board, - interp_rate, - nchan, mux, - fusb_block_size, - fusb_nblocks, - fpga_filename, - firmware_filename - ); - if (d_usrp == 0) - throw std::runtime_error ("can't open usrp"); - - set_usrp_basic(d_usrp); - - // All calls to d_usrp->write must be multiples of 512 bytes. - - set_output_multiple (OUTPUT_MULTIPLE_SAMPLES); -} - -usrp_sink_base::~usrp_sink_base () -{ -} - -int -usrp_sink_base::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - static const int BUFSIZE = 16 * (1L << 10); // 16kB - unsigned char outbuf[BUFSIZE]; - int obi = 0; - int input_index = 0; - int input_items_consumed; - int bytes_written; - bool underrun; - - - while (input_index < noutput_items){ - - copy_to_usrp_buffer (input_items, - input_index, - noutput_items - input_index, // input_items_available - input_items_consumed, // [out] - &outbuf[obi], // [out] usrp_buffer - BUFSIZE - obi, // usrp_buffer_length - bytes_written); // [out] - - assert (input_index + input_items_consumed <= noutput_items); - assert (obi + bytes_written <= BUFSIZE); - - input_index += input_items_consumed; - obi += bytes_written; - - if (obi >= BUFSIZE){ // flush - if (d_usrp->write (outbuf, obi, &underrun) != obi) - return -1; // indicate we're done - - if (underrun){ - d_nunderruns++; - // fprintf (stderr, "usrp_sink: underrun\n"); - fputs ("uU", stderr); - } - obi = 0; - } - } - - if (obi != 0){ - assert (obi % 512 == 0); - if (d_usrp->write (outbuf, obi, &underrun) != obi) - return -1; // indicate we're done - - if (underrun){ - d_nunderruns++; - // fprintf (stderr, "usrp_sink: underrun\n"); - fputs ("uU", stderr); - } - } - - return noutput_items; -} - -bool -usrp_sink_base::set_interp_rate (unsigned int rate) -{ - return d_usrp->set_interp_rate (rate); -} - -bool -usrp_sink_base::set_nchannels (int nchan) -{ - return d_usrp->set_nchannels (nchan); -} - -bool -usrp_sink_base::set_mux (int mux) -{ - return d_usrp->set_mux (mux); -} - -int -usrp_sink_base::determine_tx_mux_value(usrp_subdev_spec ss) -{ - return d_usrp->determine_tx_mux_value(ss); -} - -int -usrp_sink_base::determine_tx_mux_value(usrp_subdev_spec ss_a, usrp_subdev_spec ss_b) -{ - return d_usrp->determine_tx_mux_value(ss_a, ss_b); -} - -bool -usrp_sink_base::set_tx_freq (int channel, double freq) -{ - return d_usrp->set_tx_freq (channel, freq); -} - -unsigned int -usrp_sink_base::interp_rate () const -{ - return d_usrp->interp_rate (); -} - -int -usrp_sink_base::nchannels () const -{ - return d_usrp->nchannels (); -} - -int -usrp_sink_base::mux () const -{ - return d_usrp->mux (); -} - - -double -usrp_sink_base::tx_freq (int channel) const -{ - return d_usrp->tx_freq (channel); -} - -bool -usrp_sink_base::has_rx_halfband() -{ - return d_usrp->has_rx_halfband(); -} - -bool -usrp_sink_base::has_tx_halfband() -{ - return d_usrp->has_tx_halfband(); -} - -int -usrp_sink_base::nddcs() -{ - return d_usrp->nddcs(); -} - -int -usrp_sink_base::nducs() -{ - return d_usrp->nducs(); -} - -bool -usrp_sink_base::start() -{ - return d_usrp->start(); -} - -bool -usrp_sink_base::stop() -{ - return d_usrp->stop(); -} - - -bool -usrp_sink_base::tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result *result) -{ - return d_usrp->tune(chan, db, target_freq, result); -} - -usrp_subdev_spec -usrp_sink_base::pick_tx_subdevice() -{ - int dbids[] = { - USRP_DBID_FLEX_400_TX, - USRP_DBID_FLEX_900_TX, - USRP_DBID_FLEX_1200_TX, - USRP_DBID_FLEX_2400_TX, - USRP_DBID_BASIC_TX - }; - - std::vector<int> candidates(dbids, dbids+(sizeof(dbids)/sizeof(int))); - return pick_subdev(candidates); -} diff --git a/gr-usrp/src/usrp_sink_base.h b/gr-usrp/src/usrp_sink_base.h deleted file mode 100644 index 8d573af1b..000000000 --- a/gr-usrp/src/usrp_sink_base.h +++ /dev/null @@ -1,152 +0,0 @@ - -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,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. - */ - -#ifndef INCLUDED_USRP_SINK_BASE_H -#define INCLUDED_USRP_SINK_BASE_H - -#include <usrp_base.h> -#include <stdexcept> -#include <usrp/usrp_tune_result.h> -#include <usrp/usrp_dbid.h> - -class usrp_standard_tx; - -/*! - * \brief abstract interface to Universal Software Radio Peripheral Tx path (Rev 1) - */ -class usrp_sink_base : public usrp_base { - private: - boost::shared_ptr<usrp_standard_tx> d_usrp; - int d_nunderruns; - - protected: - usrp_sink_base (const std::string &name, - gr_io_signature_sptr input_signature, - int which_board, - unsigned int interp_rate, - int nchan, - int mux, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error); - - /*! - * \brief convert between input item format and usrp native format - * - * \param[in] input_items stream(s) of input items - * \param[in] input_index starting index in input_items - * \param[in] input_items_available number of items available starting at item[index] - * \param[out] input_items_consumed number of input items consumed by copy - * \param[out] usrp_buffer destination buffer - * \param[in] usrp_buffer_length \p usrp_buffer length in bytes - * \param[out] bytes_written number of bytes written into \p usrp_buffer - */ - virtual void copy_to_usrp_buffer (gr_vector_const_void_star &input_items, - int input_index, - int input_items_available, - int &input_items_consumed, - void *usrp_buffer, - int usrp_buffer_length, - int &bytes_written) = 0; - - public: - ~usrp_sink_base (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - /*! - * \brief Set interpolator rate. \p rate must be in [4, 1024] and a multiple of 4. - * - * The final complex sample rate across the USB is - * dac_freq () / interp_rate () * nchannels () - */ - bool set_interp_rate (unsigned int rate); - bool set_nchannels (int nchan); - bool set_mux (int mux); - int determine_tx_mux_value(usrp_subdev_spec ss); - int determine_tx_mux_value(usrp_subdev_spec ss_a, usrp_subdev_spec ss_b); - - /*! - * \brief set the frequency of the digital up converter. - * - * \p channel must be 0. \p freq is the center frequency in Hz. - * It must be in the range [-44M, 44M]. The frequency specified is - * quantized. Use tx_freq to retrieve the actual value used. - */ - bool set_tx_freq (int channel, double freq); - - long dac_rate() const { return converter_rate(); } // alias - long dac_freq() const { return converter_rate(); } // deprecated alias - - unsigned int interp_rate () const; - int nchannels () const; - int mux () const; - double tx_freq (int channel) const; - int nunderruns () const { return d_nunderruns; } - - bool has_rx_halfband(); - bool has_tx_halfband(); - int nddcs(); - int nducs(); - - /*! - * \brief Called to enable drivers, etc for i/o devices. - * - * This allows a block to enable an associated driver to begin - * transfering data just before we start to execute the scheduler. - * The end result is that this reduces latency in the pipeline when - * dealing with audio devices, usrps, etc. - */ - bool start(); - - /*! - * \brief Called to disable drivers, etc for i/o devices. - */ - bool stop(); - - /*! - * \brief High-level "tune" method. Works for the single channel case. - * - * This method adjusts both the daughterboard LO and the DUC so that - * DC in the complex baseband samples ends up at RF target_freq. - * - * \param chan which DUC channel we're controlling (usually == which_side). - * \param db the daughterboard we're controlling. - * \param target_freq the RF frequency we want our baseband translated to. - * \param[out] result details how the hardware was configured. - * - * \returns true iff everything was successful. - */ - bool tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result *result); - - /*! - * \brief Select suitable Tx daughterboard - */ - usrp_subdev_spec pick_tx_subdevice(); -}; - -#endif /* INCLUDED_USRP_SINK_BASE_H */ diff --git a/gr-usrp/src/usrp_sink_base.i b/gr-usrp/src/usrp_sink_base.i deleted file mode 100644 index 17fca441d..000000000 --- a/gr-usrp/src/usrp_sink_base.i +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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. - */ - -%{ -#include "usrp_sink_base.h" -%} - -class usrp_sink_base : public usrp_base -{ -private: - usrp_sink_base() throw (std::runtime_error); - -public: - bool set_interp_rate (unsigned int rate); - bool set_nchannels (int nchan); - bool set_mux (int mux); - %rename(_real_determine_tx_mux_value) determine_tx_mux_value; - int determine_tx_mux_value(usrp_subdev_spec ss); - int determine_tx_mux_value(usrp_subdev_spec ss_a, usrp_subdev_spec ss_b); - bool set_tx_freq (int channel, double freq); - long dac_rate() const { return converter_rate(); } - long dac_freq() const { return converter_rate(); } - unsigned int interp_rate () const; - int nchannels () const; - int mux () const; - double tx_freq (int channel) const; - int nunderruns () const { return d_nunderruns; } - bool has_rx_halfband(); - bool has_tx_halfband(); - int nddcs(); - int nducs(); - %rename(_real_tune) tune; - bool tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result *result); - %rename(_real_pick_tx_subdevice) pick_tx_subdevice(); - usrp_subdev_spec pick_tx_subdevice(); -}; diff --git a/gr-usrp/src/usrp_sink_c.cc b/gr-usrp/src/usrp_sink_c.cc deleted file mode 100644 index 7054158d8..000000000 --- a/gr-usrp/src/usrp_sink_c.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2009,2010 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_sink_c.h> -#include <gr_io_signature.h> -#include <usrp/usrp_standard.h> -#include <usrp/usrp_bytesex.h> - -usrp_sink_c_sptr -usrp_make_sink_c (int which_board, - unsigned int interp_rate, - int nchan, - int mux, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error) -{ - return gnuradio::get_initial_sptr(new usrp_sink_c (which_board, - interp_rate, - nchan, - mux, - fusb_block_size, - fusb_nblocks, - fpga_filename, - firmware_filename - )); -} - - -usrp_sink_c::usrp_sink_c (int which_board, - unsigned int interp_rate, - int nchan, - int mux, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error) - : usrp_sink_base ("usrp_sink_c", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - which_board, interp_rate, nchan, mux, - fusb_block_size, fusb_nblocks, - fpga_filename, firmware_filename) -{ -} - -usrp_sink_c::~usrp_sink_c () -{ - // NOP -} - -/* - * Take one complex input stream and format it into interleaved short I & Q - * for the usrp. - */ -void -usrp_sink_c::copy_to_usrp_buffer (gr_vector_const_void_star &input_items, - int input_index, - int input_items_available, - int &input_items_consumed, // out - void *usrp_buffer, - int usrp_buffer_length, - int &bytes_written) // out -{ - gr_complex *in = &((gr_complex *) input_items[0])[input_index]; - short *dst = (short *) usrp_buffer; - - static const int usrp_bytes_per_input_item = 2 * sizeof (short); // I & Q - - int nitems = std::min (input_items_available, - usrp_buffer_length / usrp_bytes_per_input_item); - - for (int i = 0; i < nitems; i++){ - dst[2*i + 0] = host_to_usrp_short((short) real(in[i])); // FIXME saturate? - dst[2*i + 1] = host_to_usrp_short((short) imag(in[i])); // FIXME saturate? - } - - input_items_consumed = nitems; - bytes_written = nitems * usrp_bytes_per_input_item; -} - diff --git a/gr-usrp/src/usrp_sink_c.h b/gr-usrp/src/usrp_sink_c.h deleted file mode 100644 index 59ebace38..000000000 --- a/gr-usrp/src/usrp_sink_c.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -#ifndef INCLUDED_USRP_SINK_C_H -#define INCLUDED_USRP_SINK_C_H - -#include <usrp_sink_base.h> - -class usrp_sink_c; -typedef boost::shared_ptr<usrp_sink_c> usrp_sink_c_sptr; - - -// public shared_ptr constructor - -usrp_sink_c_sptr -usrp_make_sink_c (int which_board=0, - unsigned int interp_rate=32, - int nchan=1, - int mux=-1, - int fusb_block_size=0, - int fusb_nblocks=0, - const std::string fpga_filename="", - const std::string firmware_filename="" - ) throw (std::runtime_error); - - -/*! - * \brief Interface to Universal Software Radio Peripheral Tx path - * \ingroup usrp - * \ingroup sink_blk - * - * input: gr_complex - */ -class usrp_sink_c : public usrp_sink_base { - private: - - friend usrp_sink_c_sptr - usrp_make_sink_c (int which_board, - unsigned int interp_rate, - int nchan, - int mux, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error); - - protected: - usrp_sink_c (int which_board, - unsigned int interp_rate, - int nchan, - int mux, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error); - - virtual void copy_to_usrp_buffer (gr_vector_const_void_star &input_items, - int input_index, - int input_items_available, - int &input_items_consumed, - void *usrp_buffer, - int usrp_buffer_length, - int &bytes_written); - public: - ~usrp_sink_c (); -}; - -#endif /* INCLUDED_USRP_SINK_C_H */ diff --git a/gr-usrp/src/usrp_sink_c.i b/gr-usrp/src/usrp_sink_c.i deleted file mode 100644 index 15480883e..000000000 --- a/gr-usrp/src/usrp_sink_c.i +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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. - */ - -%{ -#include "usrp_sink_c.h" -%} - -GR_SWIG_BLOCK_MAGIC(usrp,sink_c) - -class usrp_sink_c; -typedef boost::shared_ptr<usrp_sink_c> usrp_sink_c_sptr; - -usrp_sink_c_sptr -usrp_make_sink_c(int which=0, - unsigned int interp_rate=32, - int nchan=1, - int mux=-1, - int fusb_block_size=0, - int fusb_nblocks=0, - const std::string fpga_filename="", - const std::string firmware_filename="" - ) throw (std::runtime_error); - -class usrp_sink_c : public usrp_sink_base -{ -private: - usrp_sink_c() throw (std::runtime_error); -}; diff --git a/gr-usrp/src/usrp_sink_s.cc b/gr-usrp/src/usrp_sink_s.cc deleted file mode 100644 index 1ffaeed96..000000000 --- a/gr-usrp/src/usrp_sink_s.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2009,2010 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_sink_s.h> -#include <gr_io_signature.h> -#include <usrp/usrp_standard.h> -#include <usrp/usrp_bytesex.h> - -usrp_sink_s_sptr -usrp_make_sink_s (int which_board, - unsigned int interp_rate, - int nchan, - int mux, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error) -{ - return gnuradio::get_initial_sptr(new usrp_sink_s (which_board, - interp_rate, - nchan, - mux, - fusb_block_size, - fusb_nblocks, - fpga_filename, - firmware_filename - )); -} - - -usrp_sink_s::usrp_sink_s (int which_board, - unsigned int interp_rate, - int nchan, - int mux, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error) - : usrp_sink_base ("usrp_sink_s", - gr_make_io_signature (1, 1, sizeof (short)), - which_board, interp_rate, nchan, mux, - fusb_block_size, fusb_nblocks, - fpga_filename, firmware_filename) -{ - set_output_multiple (512 / sizeof(short)); // don't change -} - -usrp_sink_s::~usrp_sink_s () -{ - // NOP -} - -/* - * Take one short input stream and format it into interleaved short I & Q - * for the usrp. - */ -void -usrp_sink_s::copy_to_usrp_buffer (gr_vector_const_void_star &input_items, - int input_index, - int input_items_available, - int &input_items_consumed, // out - void *usrp_buffer, - int usrp_buffer_length, - int &bytes_written) // out -{ - short *in = &((short *) input_items[0])[input_index]; - short *dst = (short *) usrp_buffer; - - static const int usrp_bytes_per_input_item = sizeof (short); - - int nitems = std::min (input_items_available, - usrp_buffer_length / usrp_bytes_per_input_item); - - for (int i = 0; i < nitems; i++){ // FIXME unroll - dst[i] = host_to_usrp_short(in[i]); - } - - input_items_consumed = nitems; - bytes_written = nitems * usrp_bytes_per_input_item; -} - diff --git a/gr-usrp/src/usrp_sink_s.h b/gr-usrp/src/usrp_sink_s.h deleted file mode 100644 index f23b86125..000000000 --- a/gr-usrp/src/usrp_sink_s.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -#ifndef INCLUDED_USRP_SINK_S_H -#define INCLUDED_USRP_SINK_S_H - -#include <usrp_sink_base.h> - -class usrp_sink_s; -typedef boost::shared_ptr<usrp_sink_s> usrp_sink_s_sptr; - - -// public shared_ptr constructor - -usrp_sink_s_sptr -usrp_make_sink_s (int which_board=0, - unsigned int interp_rate=32, - int nchan=1, - int mux=-1, - int fusb_block_size=0, - int fusb_nblocks=0, - const std::string fpga_filename="", - const std::string firmware_filename="" - ) throw (std::runtime_error); - -/*! - * \brief Interface to Universal Software Radio Peripheral Tx path - * \ingroup usrp - * \ingroup sink_blk - * - * input: short - */ -class usrp_sink_s : public usrp_sink_base { - private: - - friend usrp_sink_s_sptr - usrp_make_sink_s (int which_board, - unsigned int interp_rate, - int nchan, - int mux, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error); - - protected: - usrp_sink_s (int which_board, - unsigned int interp_rate, - int nchan, - int mux, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error); - - virtual void copy_to_usrp_buffer (gr_vector_const_void_star &input_items, - int input_index, - int input_items_available, - int &input_items_consumed, - void *usrp_buffer, - int usrp_buffer_length, - int &bytes_written); - public: - ~usrp_sink_s (); -}; - -#endif /* INCLUDED_USRP_SINK_S_H */ diff --git a/gr-usrp/src/usrp_sink_s.i b/gr-usrp/src/usrp_sink_s.i deleted file mode 100644 index 9993d5214..000000000 --- a/gr-usrp/src/usrp_sink_s.i +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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. - */ - -%{ -#include "usrp_sink_s.h" -%} - -GR_SWIG_BLOCK_MAGIC(usrp,sink_s) - -class usrp_sink_s; -typedef boost::shared_ptr<usrp_sink_s> usrp_sink_s_sptr; - -usrp_sink_s_sptr -usrp_make_sink_s(int which=0, - unsigned int interp_rate=32, - int nchan=1, - int mux=-1, - int fusb_block_size=0, - int fusb_nblocks=0, - const std::string fpga_filename="", - const std::string firmware_filename="" - ) throw (std::runtime_error); - -class usrp_sink_s : public usrp_sink_base -{ -private: - usrp_sink_s() throw (std::runtime_error); -}; diff --git a/gr-usrp/src/usrp_source_base.cc b/gr-usrp/src/usrp_source_base.cc deleted file mode 100644 index 5a5e20f3e..000000000 --- a/gr-usrp/src/usrp_source_base.cc +++ /dev/null @@ -1,305 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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_source_base.h> -#include <gr_io_signature.h> -#include <usrp/usrp_standard.h> -#include <assert.h> -#include <cstdio> - -static const int OUTPUT_MULTIPLE_BYTES = 4 * 1024; - -usrp_source_base::usrp_source_base (const std::string &name, - gr_io_signature_sptr output_signature, - int which_board, - unsigned int decim_rate, - int nchan, - int mux, - int mode, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error) - : usrp_base(name, - gr_make_io_signature (0, 0, 0), - output_signature), - d_noverruns (0) -{ - d_usrp = usrp_standard_rx::make (which_board, decim_rate, - nchan, mux, mode, - fusb_block_size, - fusb_nblocks, - fpga_filename, - firmware_filename); - if (d_usrp == 0) - throw std::runtime_error ("can't open usrp"); - - set_usrp_basic(d_usrp); - - // All calls to d_usrp->read must be multiples of 512 bytes. - // We jack this up to 4k to reduce overhead. - - set_output_multiple (OUTPUT_MULTIPLE_BYTES / output_signature->sizeof_stream_item (0)); -} - -usrp_source_base::~usrp_source_base () -{ -} - -unsigned int -usrp_source_base::sizeof_basic_sample() const -{ - return usrp_standard_rx::format_width(d_usrp->format()) / 8; -} - -int -usrp_source_base::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - static const int BUFSIZE = 4 * OUTPUT_MULTIPLE_BYTES; - unsigned char buf[BUFSIZE]; - int output_index = 0; - int output_items_produced; - int bytes_read; - bool overrun; - - while (output_index < noutput_items){ - int nbytes = ninput_bytes_reqd_for_noutput_items (noutput_items - output_index); - nbytes = std::min (nbytes, BUFSIZE); - - int result_nbytes = d_usrp->read (buf, nbytes, &overrun); - if (overrun){ - // fprintf (stderr, "usrp_source: overrun\n"); - fputs ("uO", stderr); - d_noverruns++; - } - - if (result_nbytes < 0) // We've got a problem. Usually board unplugged or powered down. - return -1; // Indicate we're done. - - if (result_nbytes != nbytes){ // not really an error, but unexpected - fprintf (stderr, "usrp_source: short read. Expected %d, got %d\n", - nbytes, result_nbytes); - } - - copy_from_usrp_buffer (output_items, - output_index, - noutput_items - output_index, // output_items_available - output_items_produced, // [out] - buf, // usrp_buffer - result_nbytes, // usrp_buffer_length - bytes_read); // [out] - - assert (output_index + output_items_produced <= noutput_items); - assert (bytes_read == result_nbytes); - - output_index += output_items_produced; - } - - return noutput_items; -} - - -bool -usrp_source_base::set_decim_rate (unsigned int rate) -{ - return d_usrp->set_decim_rate (rate); -} - -bool -usrp_source_base::set_nchannels (int nchan) -{ - return d_usrp->set_nchannels (nchan); -} - -bool -usrp_source_base::set_mux (int mux) -{ - return d_usrp->set_mux (mux); -} - -int -usrp_source_base::determine_rx_mux_value(usrp_subdev_spec ss) -{ - return d_usrp->determine_rx_mux_value(ss); -} - -int -usrp_source_base::determine_rx_mux_value(usrp_subdev_spec ss_a, usrp_subdev_spec ss_b) -{ - return d_usrp->determine_rx_mux_value(ss_a, ss_b); -} - -bool -usrp_source_base::set_rx_freq (int channel, double freq) -{ - return d_usrp->set_rx_freq (channel, freq); -} - -unsigned int -usrp_source_base::decim_rate () const -{ - return d_usrp->decim_rate (); -} - -int -usrp_source_base::nchannels () const -{ - return d_usrp->nchannels (); -} - -int -usrp_source_base::mux () const -{ - return d_usrp->mux (); -} - -double -usrp_source_base::rx_freq (int channel) const -{ - return d_usrp->rx_freq (channel); -} - -bool -usrp_source_base::set_fpga_mode (int mode) -{ - return d_usrp->set_fpga_mode (mode); -} - -bool -usrp_source_base::set_ddc_phase (int channel, int phase) -{ - return d_usrp->set_ddc_phase(channel, phase); -} - - -bool -usrp_source_base::set_format(unsigned int format) -{ - return d_usrp->set_format(format); -} - -unsigned int -usrp_source_base::format() const -{ - return d_usrp->format(); -} - -unsigned int -usrp_source_base::make_format(int width, int shift, bool want_q, bool bypass_halfband) -{ - return usrp_standard_rx::make_format(width, shift, want_q, bypass_halfband); -} - -int -usrp_source_base::format_width(unsigned int format) -{ - return usrp_standard_rx::format_width(format); -} - -int -usrp_source_base::format_shift(unsigned int format) -{ - return usrp_standard_rx::format_shift(format); -} - -bool -usrp_source_base::format_want_q(unsigned int format) -{ - return usrp_standard_rx::format_want_q(format); -} - -bool -usrp_source_base::format_bypass_halfband(unsigned int format) -{ - return usrp_standard_rx::format_bypass_halfband(format); -} - -bool -usrp_source_base::has_rx_halfband() -{ - return d_usrp->has_rx_halfband(); -} - -bool -usrp_source_base::has_tx_halfband() -{ - return d_usrp->has_tx_halfband(); -} - -int -usrp_source_base::nddcs() -{ - return d_usrp->nddcs(); -} - -int -usrp_source_base::nducs() -{ - return d_usrp->nducs(); -} - -bool -usrp_source_base::start() -{ - return d_usrp->start(); -} - -bool -usrp_source_base::stop() -{ - return d_usrp->stop(); -} - -bool -usrp_source_base::tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result *result) -{ - return d_usrp->tune(chan, db, target_freq, result); -} - -usrp_subdev_spec -usrp_source_base::pick_rx_subdevice() -{ - int dbids[] = { - USRP_DBID_FLEX_400_RX, - USRP_DBID_FLEX_900_RX, - USRP_DBID_FLEX_1200_RX, - USRP_DBID_FLEX_2400_RX, - USRP_DBID_TV_RX, - USRP_DBID_TV_RX_REV_2, - USRP_DBID_TV_RX_REV_3, - USRP_DBID_TV_RX_MIMO, - USRP_DBID_TV_RX_REV_2_MIMO, - USRP_DBID_TV_RX_REV_3_MIMO, - USRP_DBID_DBS_RX, - USRP_DBID_BASIC_RX - }; - - std::vector<int> candidates(dbids, dbids+(sizeof(dbids)/sizeof(int))); - return pick_subdev(candidates); -} diff --git a/gr-usrp/src/usrp_source_base.h b/gr-usrp/src/usrp_source_base.h deleted file mode 100644 index 4def48e24..000000000 --- a/gr-usrp/src/usrp_source_base.h +++ /dev/null @@ -1,220 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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. - */ - -#ifndef INCLUDED_USRP_SOURCE_BASE_H -#define INCLUDED_USRP_SOURCE_BASE_H - -#include <usrp_base.h> -#include <stdexcept> -#include <usrp/usrp_tune_result.h> -#include <usrp/usrp_dbid.h> - -class usrp_standard_rx; - -/*! - * \brief abstract interface to Universal Software Radio Peripheral Rx path (Rev 1) - */ -class usrp_source_base : public usrp_base { - private: - boost::shared_ptr<usrp_standard_rx> d_usrp; - int d_noverruns; - - protected: - usrp_source_base (const std::string &name, - gr_io_signature_sptr output_signature, - int which_board, - unsigned int decim_rate, - int nchan, - int mux, - int mode, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error); - - /*! - * \brief return number of usrp input bytes required to produce noutput items. - */ - virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items) = 0; - - /*! - * \brief number of bytes in a low-level sample - */ - unsigned int sizeof_basic_sample() const; - - /*! - * \brief convert between native usrp format and output item format - * - * \param[out] output_items stream(s) of output items - * \param[in] output_index starting index in output_items - * \param[in] output_items_available number of empty items available at item[index] - * \param[out] output_items_produced number of items produced by copy - * \param[in] usrp_buffer source buffer - * \param[in] usrp_buffer_length number of bytes available in \p usrp_buffer - * \param[out] bytes_read number of bytes read from \p usrp_buffer - * - * The copy must consume all bytes available. That is, \p bytes_read must equal - * \p usrp_buffer_length. - */ - virtual void copy_from_usrp_buffer (gr_vector_void_star &output_items, - int output_index, - int output_items_available, - int &output_items_produced, - const void *usrp_buffer, - int usrp_buffer_length, - int &bytes_read) = 0; - - public: - ~usrp_source_base (); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - /*! - * \brief Set decimator rate. \p rate must be EVEN and in [8, 256]. - * - * The final complex sample rate across the USB is - * adc_freq () / decim_rate () - */ - bool set_decim_rate (unsigned int rate); - bool set_nchannels (int nchan); - bool set_mux (int mux); - int determine_rx_mux_value(usrp_subdev_spec ss); - int determine_rx_mux_value(usrp_subdev_spec ss_a, usrp_subdev_spec ss_b); - - /*! - * \brief set the center frequency of the digital down converter. - * - * \p channel must be 0. \p freq is the center frequency in Hz. - * It must be in the range [-FIXME, FIXME]. The frequency specified is - * quantized. Use rx_freq to retrieve the actual value used. - */ - bool set_rx_freq (int channel, double freq); - - /*! - * \brief set fpga special modes - */ - bool set_fpga_mode (int mode); - - /*! - * \brief Set the digital down converter phase register. - * - * \param channel which ddc channel [0, 3] - * \param phase 32-bit integer phase value. - */ - bool set_ddc_phase(int channel, int phase); - - long adc_rate() const { return converter_rate(); } // alias - long adc_freq() const { return converter_rate(); } // deprecated alias - - unsigned int decim_rate () const; - int nchannels () const; - int mux () const; - double rx_freq (int channel) const; - int noverruns () const { return d_noverruns; } - - bool has_rx_halfband(); - bool has_tx_halfband(); - int nddcs(); - int nducs(); - - /*! - * \brief Called to enable drivers, etc for i/o devices. - * - * This allows a block to enable an associated driver to begin - * transfering data just before we start to execute the scheduler. - * The end result is that this reduces latency in the pipeline when - * dealing with audio devices, usrps, etc. - */ - bool start(); - - /*! - * \brief Called to disable drivers, etc for i/o devices. - */ - bool stop(); - - /*! - * \brief Specify Rx data format. - * - * \param format format specifier - * - * Rx data format control register - * - * 3 2 1 - * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 - * +-----------------------------------------+-+-+---------+-------+ - * | Reserved (Must be zero) |B|Q| WIDTH | SHIFT | - * +-----------------------------------------+-+-+---------+-------+ - * - * SHIFT specifies arithmetic right shift [0, 15] - * WIDTH specifies bit-width of I & Q samples across the USB [1, 16] (not all valid) - * Q if set deliver both I & Q, else just I - * B if set bypass half-band filter. - * - * Right now the acceptable values are: - * - * B Q WIDTH SHIFT - * 0 1 16 0 - * 0 1 8 8 - * - * More valid combos to come. - * - * Default value is 0x00000300 16-bits, 0 shift, deliver both I & Q. - */ - bool set_format(unsigned int format); - - /*! - * \brief return current format - */ - unsigned int format () const; - - static unsigned int make_format(int width=16, int shift=0, - bool want_q=true, bool bypass_halfband=false); - static int format_width(unsigned int format); - static int format_shift(unsigned int format); - static bool format_want_q(unsigned int format); - static bool format_bypass_halfband(unsigned int format); - - /*! - * \brief High-level "tune" method. Works for the single channel case. - * - * This method adjusts both the daughterboard LO and the DDC so that - * target_freq ends up at DC in the complex baseband samples. - * - * \param chan which DDC channel we're controlling (almost always 0). - * \param db the daughterboard we're controlling. - * \param target_freq the RF frequency we want at DC in the complex baseband. - * \param[out] result details how the hardware was configured. - * - * \returns true iff everything was successful. - */ - bool tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result *result); - - /*! - * \brief Select suitable Rx daughterboard - */ - usrp_subdev_spec pick_rx_subdevice(); -}; - -#endif /* INCLUDED_USRP_SOURCE_BASE_H */ diff --git a/gr-usrp/src/usrp_source_base.i b/gr-usrp/src/usrp_source_base.i deleted file mode 100644 index aed751de9..000000000 --- a/gr-usrp/src/usrp_source_base.i +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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. - */ - -%{ -#include "usrp_source_base.h" -%} - -class usrp_source_base : public usrp_base -{ -private: - usrp_source_base() throw (std::runtime_error); - -public: - bool set_decim_rate (unsigned int rate); - bool set_nchannels (int nchan); - bool set_mux (int mux); - %rename(_real_determine_rx_mux_value) determine_rx_mux_value; - int determine_rx_mux_value(usrp_subdev_spec ss); - int determine_rx_mux_value(usrp_subdev_spec ss_a, usrp_subdev_spec ss_b); - bool set_rx_freq (int channel, double freq); - bool set_fpga_mode (int mode); - bool set_ddc_phase(int channel, int phase); - long adc_rate() const { return converter_rate(); } - long adc_freq() const { return converter_rate(); } - unsigned int decim_rate () const; - int nchannels () const; - int mux () const; - double rx_freq (int channel) const; - int noverruns () const { return d_noverruns; } - bool has_rx_halfband(); - bool has_tx_halfband(); - int nddcs(); - int nducs(); - bool set_format(unsigned int format); - static unsigned int make_format(int width=16, int shift=0, - bool want_q=true, bool bypass_halfband=false); - static int format_width(unsigned int format); - static int format_shift(unsigned int format); - static bool format_want_q(unsigned int format); - static bool format_bypass_halfband(unsigned int format); - %rename(_real_tune) tune; - bool tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result *result); - %rename(_real_pick_rx_subdevice) pick_rx_subdevice(); - usrp_subdev_spec pick_rx_subdevice(); -}; diff --git a/gr-usrp/src/usrp_source_c.cc b/gr-usrp/src/usrp_source_c.cc deleted file mode 100644 index 9055f3ee7..000000000 --- a/gr-usrp/src/usrp_source_c.cc +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2009,2010 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_source_c.h> -#include <gr_io_signature.h> -#include <usrp/usrp_standard.h> -#include <usrp/usrp_bytesex.h> - -static const int NBASIC_SAMPLES_PER_ITEM = 2; // I & Q - -usrp_source_c_sptr -usrp_make_source_c (int which_board, - unsigned int decim_rate, - int nchan, - int mux, - int mode, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error) -{ - return gnuradio::get_initial_sptr(new usrp_source_c (which_board, - decim_rate, - nchan, - mux, - mode, - fusb_block_size, - fusb_nblocks, - fpga_filename, - firmware_filename - )); -} - - -usrp_source_c::usrp_source_c (int which_board, - unsigned int decim_rate, - int nchan, - int mux, - int mode, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error) - : usrp_source_base ("usrp_source_c", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - which_board, decim_rate, nchan, mux, mode, - fusb_block_size, fusb_nblocks, - fpga_filename, firmware_filename) -{ -} - -usrp_source_c::~usrp_source_c () -{ - // NOP -} - -int -usrp_source_c::ninput_bytes_reqd_for_noutput_items (int noutput_items) -{ - return noutput_items * NBASIC_SAMPLES_PER_ITEM * sizeof_basic_sample(); -} - -/* - * Convert interleaved 8 or 16-bit I & Q from usrp buffer into a single - * complex output stream. - */ -void -usrp_source_c::copy_from_usrp_buffer (gr_vector_void_star &output_items, - int output_index, - int output_items_available, - int &output_items_produced, - const void *usrp_buffer, - int usrp_buffer_length, - int &bytes_read) -{ - gr_complex *out = &((gr_complex *) output_items[0])[output_index]; - unsigned sbs = sizeof_basic_sample(); - unsigned nusrp_bytes_per_item = NBASIC_SAMPLES_PER_ITEM * sbs; - - int nitems = std::min (output_items_available, - (int)(usrp_buffer_length / nusrp_bytes_per_item)); - - signed char *s8 = (signed char *) usrp_buffer; - short *s16 = (short *) usrp_buffer; - - switch (sbs){ - case 1: - for (int i = 0; i < nitems; i++){ - out[i] = gr_complex ((float)(s8[2*i+0] << 8), (float)(s8[2*i+1] << 8)); - } - break; - - case 2: - for (int i = 0; i < nitems; i++){ - out[i] = gr_complex ((float) usrp_to_host_short(s16[2*i+0]), - (float) usrp_to_host_short(s16[2*i+1])); - } - break; - - default: - assert(0); - } - - output_items_produced = nitems; - bytes_read = nitems * nusrp_bytes_per_item; -} diff --git a/gr-usrp/src/usrp_source_c.h b/gr-usrp/src/usrp_source_c.h deleted file mode 100644 index 3fb04d657..000000000 --- a/gr-usrp/src/usrp_source_c.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -#ifndef INCLUDED_USRP_SOURCE_C_H -#define INCLUDED_USRP_SOURCE_C_H - -#include <usrp_source_base.h> -#include <stdexcept> - -class usrp_standard_rx; - - -class usrp_source_c; -typedef boost::shared_ptr<usrp_source_c> usrp_source_c_sptr; - - -// public shared_ptr constructor - -usrp_source_c_sptr -usrp_make_source_c (int which_board=0, - unsigned int decim_rate=16, - int nchan = 1, - int mux = -1, - int mode = 0, - int fusb_block_size = 0, - int fusb_nblocks = 0, - const std::string fpga_filename = "", - const std::string firmware_filename = "" - ) throw (std::runtime_error); - -/*! - * \brief Interface to Universal Software Radio Peripheral Rx path - * \ingroup usrp - * \ingroup source_blk - * - * output: 1 stream of complex<float> - */ -class usrp_source_c : public usrp_source_base { - private: - friend usrp_source_c_sptr - usrp_make_source_c (int which_board, - unsigned int decim_rate, - int nchan, - int mux, - int mode, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error); - - protected: - usrp_source_c (int which_board, - unsigned int decim_rate, - int nchan, - int mux, - int mode, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error); - - virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items); - - virtual void copy_from_usrp_buffer (gr_vector_void_star &output_items, - int output_index, - int output_items_available, - int &output_items_produced, - const void *usrp_buffer, - int usrp_buffer_length, - int &bytes_read); - - public: - ~usrp_source_c (); -}; - -#endif /* INCLUDED_USRP_SOURCE_C_H */ diff --git a/gr-usrp/src/usrp_source_c.i b/gr-usrp/src/usrp_source_c.i deleted file mode 100644 index 499f7f740..000000000 --- a/gr-usrp/src/usrp_source_c.i +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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. - */ - -%{ -#include "usrp_source_c.h" -%} - -GR_SWIG_BLOCK_MAGIC(usrp,source_c) - -class usrp_source_c; -typedef boost::shared_ptr<usrp_source_c> usrp_source_c_sptr; - -usrp_source_c_sptr -usrp_make_source_c(int which=0, - unsigned int decim_rate=16, - int nchan=1, - int mux=-1, - int mode=0, - int fusb_block_size=0, - int fusb_nblocks=0, - const std::string fpga_filename="", - const std::string firmware_filename="" - ) throw (std::runtime_error); - -class usrp_source_c : public usrp_source_base -{ -private: - usrp_source_c() throw (std::runtime_error); -}; diff --git a/gr-usrp/src/usrp_source_s.cc b/gr-usrp/src/usrp_source_s.cc deleted file mode 100644 index 8e1c2f188..000000000 --- a/gr-usrp/src/usrp_source_s.cc +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006,2009,2010 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_source_s.h> -#include <gr_io_signature.h> -#include <usrp/usrp_standard.h> -#include <usrp/usrp_bytesex.h> - -static const int NBASIC_SAMPLES_PER_ITEM = 1; - -usrp_source_s_sptr -usrp_make_source_s (int which_board, - unsigned int decim_rate, - int nchan, - int mux, - int mode, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error) -{ - return gnuradio::get_initial_sptr(new usrp_source_s (which_board, - decim_rate, - nchan, - mux, - mode, - fusb_block_size, - fusb_nblocks, - fpga_filename, - firmware_filename - )); -} - - -usrp_source_s::usrp_source_s (int which_board, - unsigned int decim_rate, - int nchan, - int mux, - int mode, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error) - : usrp_source_base ("usrp_source_s", - gr_make_io_signature (1, 1, sizeof (short)), - which_board, decim_rate, nchan, mux, mode, - fusb_block_size, - fusb_nblocks, - fpga_filename, firmware_filename) -{ -} - -usrp_source_s::~usrp_source_s () -{ - // NOP -} - -int -usrp_source_s::ninput_bytes_reqd_for_noutput_items (int noutput_items) -{ - return noutput_items * NBASIC_SAMPLES_PER_ITEM * sizeof_basic_sample(); -} - -/* - * Convert interleaved 8 or 16-bit I & Q from usrp buffer into a single - * short output stream. - */ -void -usrp_source_s::copy_from_usrp_buffer (gr_vector_void_star &output_items, - int output_index, - int output_items_available, - int &output_items_produced, - const void *usrp_buffer, - int usrp_buffer_length, - int &bytes_read) -{ - short *out = &((short *) output_items[0])[output_index]; - unsigned sbs = sizeof_basic_sample(); - unsigned nusrp_bytes_per_item = NBASIC_SAMPLES_PER_ITEM * sbs; - - int nitems = std::min (output_items_available, - (int)(usrp_buffer_length / nusrp_bytes_per_item)); - - signed char *s8 = (signed char *) usrp_buffer; - short *s16 = (short *) usrp_buffer; - - switch(sbs){ - case 1: - for (int i = 0; i < nitems; i++){ - out[i] = s8[i] << 8; - } - break; - - case 2: - for (int i = 0; i < nitems; i++){ - out[i] = usrp_to_host_short(s16[i]); - } - break; - - default: - assert(0); - } - - output_items_produced = nitems; - bytes_read = nitems * nusrp_bytes_per_item; -} diff --git a/gr-usrp/src/usrp_source_s.h b/gr-usrp/src/usrp_source_s.h deleted file mode 100644 index 9118b4e0f..000000000 --- a/gr-usrp/src/usrp_source_s.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -#ifndef INCLUDED_USRP_SOURCE_S_H -#define INCLUDED_USRP_SOURCE_S_H - -#include <usrp_source_base.h> -#include <stdexcept> - -class usrp_standard_rx; - - -class usrp_source_s; -typedef boost::shared_ptr<usrp_source_s> usrp_source_s_sptr; - - -// public shared_ptr constructor - -usrp_source_s_sptr -usrp_make_source_s (int which_board=0, - unsigned int decim_rate=16, - int nchan=1, - int mux=-1, - int mode=0, - int fusb_block_size=0, - int fusb_nblocks=0, - const std::string fpga_filename="", - const std::string firmware_filename="" - ) throw (std::runtime_error); - -/*! - * \brief Interface to Universal Software Radio Peripheral Rx path - * \ingroup usrp - * \ingroup source_blk - * - * output: 1 stream of short - */ -class usrp_source_s : public usrp_source_base { - private: - friend usrp_source_s_sptr - usrp_make_source_s (int which_board, - unsigned int decim_rate, - int nchan, - int mux, - int mode, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error); - - protected: - usrp_source_s (int which_board, - unsigned int decim_rate, - int nchan, - int mux, - int mode, - int fusb_block_size, - int fusb_nblocks, - const std::string fpga_filename, - const std::string firmware_filename - ) throw (std::runtime_error); - - virtual int ninput_bytes_reqd_for_noutput_items (int noutput_items); - - virtual void copy_from_usrp_buffer (gr_vector_void_star &output_items, - int output_index, - int output_items_available, - int &output_items_produced, - const void *usrp_buffer, - int usrp_buffer_length, - int &bytes_read); - public: - ~usrp_source_s (); -}; - -#endif /* INCLUDED_USRP_SOURCE_S_H */ diff --git a/gr-usrp/src/usrp_source_s.i b/gr-usrp/src/usrp_source_s.i deleted file mode 100644 index d8b285c99..000000000 --- a/gr-usrp/src/usrp_source_s.i +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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. - */ - -%{ -#include "usrp_source_s.h" -%} - -GR_SWIG_BLOCK_MAGIC(usrp,source_s) - -class usrp_source_s; -typedef boost::shared_ptr<usrp_source_s> usrp_source_s_sptr; - -usrp_source_s_sptr -usrp_make_source_s(int which=0, - unsigned int decim_rate=16, - int nchan=1, - int mux=-1, - int mode=0, - int fusb_block_size=0, - int fusb_nblocks=0, - const std::string fpga_filename="", - const std::string firmware_filename="" - ) throw (std::runtime_error); - -class usrp_source_s : public usrp_source_base -{ -private: - usrp_source_s() throw (std::runtime_error); -}; diff --git a/gr-usrp/src/usrp_standard.i b/gr-usrp/src/usrp_standard.i deleted file mode 100644 index 61053bb3b..000000000 --- a/gr-usrp/src/usrp_standard.i +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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. - */ - -// FIXME: move to usrp/usrpm component - -%{ -#include <usrp/usrp_standard.h> -#include <usrp_spi_defs.h> -#include <usrp/usrp_dbid.h> -%} - -%include <usrp_spi_defs.h> -%include <usrp/usrp_dbid.h> - -%constant int FPGA_MODE_NORMAL = usrp_standard_rx::FPGA_MODE_NORMAL; -%constant int FPGA_MODE_LOOPBACK = usrp_standard_rx::FPGA_MODE_LOOPBACK; -%constant int FPGA_MODE_COUNTING = usrp_standard_rx::FPGA_MODE_COUNTING; diff --git a/gr-usrp/src/usrp_swig.i b/gr-usrp/src/usrp_swig.i deleted file mode 100644 index 80d59abc9..000000000 --- a/gr-usrp/src/usrp_swig.i +++ /dev/null @@ -1,157 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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. - */ - -%include "gnuradio.i" // the common stuff - -%{ -#include "config.h" // for NOMINMAX -#include <vector> -%} - -%include <usrp/usrp_subdev_spec.h> -%include <usrp/db_base.i> -%include <fpga_regs_common.h> -%include <fpga_regs_standard.h> -%include "usrp_standard.i" -%include "usrp_base.i" -%include "usrp_source_base.i" -%include "usrp_source_c.i" -%include "usrp_source_s.i" -%include "usrp_sink_base.i" -%include "usrp_sink_c.i" -%include "usrp_sink_s.i" - -#ifdef SWIGPYTHON -//---Allow a more Pythonic interface -%pythoncode %{ - -# Allow subdev_spec to be tuple -def __selected_subdev(self, subdev_spec): - ss = usrp_subdev_spec(subdev_spec[0], subdev_spec[1]) - return self._real_selected_subdev(ss) - -# Allow subdev_spec to be tuple -def __determine_tx_mux_value(self, subdev_spec, subdev_spec_=None): - ss = usrp_subdev_spec(subdev_spec[0], subdev_spec[1]) - if subdev_spec_ is None: return self._real_determine_tx_mux_value(ss) - ss_ = usrp_subdev_spec(subdev_spec_[0], subdev_spec_[1]) - return self._real_determine_tx_mux_value(ss, ss_) - -# Allow subdev_spec to be tuple -def __determine_rx_mux_value(self, subdev_spec, subdev_spec_=None): - ss = usrp_subdev_spec(subdev_spec[0], subdev_spec[1]) - if subdev_spec_ is None: return self._real_determine_rx_mux_value(ss) - ss_ = usrp_subdev_spec(subdev_spec_[0], subdev_spec_[1]) - return self._real_determine_rx_mux_value(ss, ss_) - -# Allow subdev_spec to be tuple -def __pick_subdev(self, candidates=[]): - ss = self._real_pick_subdev(candidates) - return (ss.side, ss.subdev) - -# Allow subdev_spec to be tuple -def __pick_tx_subdevice(self): - ss = self._real_pick_tx_subdevice() - return (ss.side, ss.subdev) - -# Allow subdev_spec to be tuple -def __pick_rx_subdevice(self): - ss = self._real_pick_rx_subdevice() - return (ss.side, ss.subdev) - -# Make return tune_result or None on failure -def __tune(self, chan, db, target_freq): - tr = usrp_tune_result() - r = self._real_tune(chan, db, target_freq, tr) - if r: - return tr - else: - return None - -# Allow to be called as a free function -def tune(u, chan, subdev, target_freq): - return u.tune(chan, subdev, target_freq) - -# Allow to be called as free function -def determine_tx_mux_value(u, subdev_spec, subdev_spec_=None): - return u.determine_tx_mux_value(subdev_spec, subdev_spec_) - -# Allow to be called as free function -def determine_rx_mux_value(u, subdev_spec, subdev_spec_=None): - return u.determine_rx_mux_value(subdev_spec, subdev_spec_) - -# Allow to be called as free function -def selected_subdev(u, subdev_spec): - return u.selected_subdev(subdev_spec) - -# Allow to be called as free function -def pick_subdev(u, candidates=[]): - return u.pick_subdev(candidates); - -# Allow to be called as free function -def pick_tx_subdevice(u): - return u.pick_tx_subdevice(); - -# Allow to be called as free function -def pick_rx_subdevice(u): - return u.pick_rx_subdevice(); - -# Jam into Python objects -usrp_sink_c_sptr.determine_tx_mux_value = __determine_tx_mux_value -usrp_sink_s_sptr.determine_tx_mux_value = __determine_tx_mux_value - -usrp_source_c_sptr.determine_rx_mux_value = __determine_rx_mux_value -usrp_source_s_sptr.determine_rx_mux_value = __determine_rx_mux_value - -usrp_sink_c_sptr.selected_subdev = __selected_subdev -usrp_sink_s_sptr.selected_subdev = __selected_subdev -usrp_source_c_sptr.selected_subdev = __selected_subdev -usrp_source_s_sptr.selected_subdev = __selected_subdev - -usrp_sink_c_sptr.tune = __tune -usrp_sink_s_sptr.tune = __tune -usrp_source_c_sptr.tune = __tune -usrp_source_s_sptr.tune = __tune - -usrp_sink_c_sptr.pick_subdev = __pick_subdev -usrp_sink_s_sptr.pick_subdev = __pick_subdev -usrp_source_c_sptr.pick_subdev = __pick_subdev -usrp_source_s_sptr.pick_subdev = __pick_subdev - -usrp_sink_c_sptr.pick_tx_subdevice = __pick_tx_subdevice -usrp_sink_s_sptr.pick_tx_subdevice = __pick_tx_subdevice -usrp_source_c_sptr.pick_rx_subdevice = __pick_rx_subdevice -usrp_source_s_sptr.pick_rx_subdevice = __pick_rx_subdevice - -%} -#endif - - -#if SWIGGUILE -%scheme %{ -(load-extension-global "libguile-gnuradio-usrp_swig" "scm_init_gnuradio_usrp_swig_module") -%} - -%goops %{ -(use-modules (gnuradio gnuradio_core_runtime)) -%} -#endif |