From c5480830c6e8e8e862523b3ebf3117fda8a100df Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 9 Feb 2010 16:28:16 -0800 Subject: renamed usrp_uhd to uhd --- .gitignore | 2 +- Makefile.am | 8 +- Makefile.common | 8 +- apps/Makefile.am | 2 +- apps/discover_usrps.cpp | 8 +- configure.ac | 12 +- include/Makefile.am | 4 +- include/uhd.hpp | 24 ++++ include/uhd/.gitignore | 2 + include/uhd/Makefile.am | 30 +++++ include/uhd/device.hpp | 90 +++++++++++++++ include/uhd/device_addr.hpp | 97 ++++++++++++++++ include/uhd/gain_handler.hpp | 101 +++++++++++++++++ include/uhd/props.hpp | 165 ++++++++++++++++++++++++++++ include/uhd/quadradio/.gitignore | 2 + include/uhd/quadradio/Makefile.am | 20 ++++ include/uhd/time_spec.hpp | 57 ++++++++++ include/uhd/usrp/.gitignore | 2 + include/uhd/usrp/Makefile.am | 24 ++++ include/uhd/usrp/dboard/.gitignore | 2 + include/uhd/usrp/dboard/Makefile.am | 27 +++++ include/uhd/usrp/dboard/base.hpp | 111 +++++++++++++++++++ include/uhd/usrp/dboard/id.hpp | 34 ++++++ include/uhd/usrp/dboard/interface.hpp | 167 ++++++++++++++++++++++++++++ include/uhd/usrp/dboard/manager.hpp | 82 ++++++++++++++ include/uhd/usrp/mboard/.gitignore | 2 + include/uhd/usrp/mboard/Makefile.am | 26 +++++ include/uhd/usrp/mboard/base.hpp | 45 ++++++++ include/uhd/usrp/mboard/test.hpp | 46 ++++++++ include/uhd/usrp/mboard/usrp2.hpp | 53 +++++++++ include/uhd/usrp/usrp.hpp | 52 +++++++++ include/uhd/utils.hpp | 131 ++++++++++++++++++++++ include/uhd/wax.hpp | 170 +++++++++++++++++++++++++++++ include/usrp_uhd.hpp | 24 ---- include/usrp_uhd/.gitignore | 2 - include/usrp_uhd/Makefile.am | 30 ----- include/usrp_uhd/device.hpp | 90 --------------- include/usrp_uhd/device_addr.hpp | 97 ---------------- include/usrp_uhd/gain_handler.hpp | 101 ----------------- include/usrp_uhd/props.hpp | 165 ---------------------------- include/usrp_uhd/quadradio/.gitignore | 2 - include/usrp_uhd/quadradio/Makefile.am | 20 ---- include/usrp_uhd/time_spec.hpp | 57 ---------- include/usrp_uhd/usrp/.gitignore | 2 - include/usrp_uhd/usrp/Makefile.am | 24 ---- include/usrp_uhd/usrp/dboard/.gitignore | 2 - include/usrp_uhd/usrp/dboard/Makefile.am | 27 ----- include/usrp_uhd/usrp/dboard/base.hpp | 111 ------------------- include/usrp_uhd/usrp/dboard/id.hpp | 34 ------ include/usrp_uhd/usrp/dboard/interface.hpp | 167 ---------------------------- include/usrp_uhd/usrp/dboard/manager.hpp | 82 -------------- include/usrp_uhd/usrp/mboard/.gitignore | 2 - include/usrp_uhd/usrp/mboard/Makefile.am | 26 ----- include/usrp_uhd/usrp/mboard/base.hpp | 45 -------- include/usrp_uhd/usrp/mboard/test.hpp | 46 -------- include/usrp_uhd/usrp/mboard/usrp2.hpp | 53 --------- include/usrp_uhd/usrp/usrp.hpp | 52 --------- include/usrp_uhd/utils.hpp | 131 ---------------------- include/usrp_uhd/wax.hpp | 170 ----------------------------- lib/Makefile.am | 10 +- lib/device.cpp | 10 +- lib/device_addr.cpp | 14 +-- lib/gain_handler.cpp | 6 +- lib/uhd.cpp | 20 ++++ lib/usrp/Makefile.am | 4 +- lib/usrp/dboard/base.cpp | 4 +- lib/usrp/dboard/dboards.hpp | 4 +- lib/usrp/dboard/id.cpp | 4 +- lib/usrp/dboard/interface.cpp | 4 +- lib/usrp/dboard/manager.cpp | 8 +- lib/usrp/mboard/base.cpp | 4 +- lib/usrp/mboard/test.cpp | 14 +-- lib/usrp/mboard/usrp2.cpp | 8 +- lib/usrp/usrp.cpp | 12 +- lib/usrp_uhd.cpp | 20 ---- lib/wax.cpp | 2 +- test/Makefile.am | 2 +- test/addr_test.cpp | 4 +- test/device_test.cpp | 4 +- test/gain_handler_test.cpp | 6 +- test/usrp_dboard_test.cpp | 4 +- test/wax_test.cpp | 2 +- uhd.pc.in | 11 ++ usrp_uhd.pc.in | 11 -- 84 files changed, 1680 insertions(+), 1680 deletions(-) create mode 100644 include/uhd.hpp create mode 100644 include/uhd/.gitignore create mode 100644 include/uhd/Makefile.am create mode 100644 include/uhd/device.hpp create mode 100644 include/uhd/device_addr.hpp create mode 100644 include/uhd/gain_handler.hpp create mode 100644 include/uhd/props.hpp create mode 100644 include/uhd/quadradio/.gitignore create mode 100644 include/uhd/quadradio/Makefile.am create mode 100644 include/uhd/time_spec.hpp create mode 100644 include/uhd/usrp/.gitignore create mode 100644 include/uhd/usrp/Makefile.am create mode 100644 include/uhd/usrp/dboard/.gitignore create mode 100644 include/uhd/usrp/dboard/Makefile.am create mode 100644 include/uhd/usrp/dboard/base.hpp create mode 100644 include/uhd/usrp/dboard/id.hpp create mode 100644 include/uhd/usrp/dboard/interface.hpp create mode 100644 include/uhd/usrp/dboard/manager.hpp create mode 100644 include/uhd/usrp/mboard/.gitignore create mode 100644 include/uhd/usrp/mboard/Makefile.am create mode 100644 include/uhd/usrp/mboard/base.hpp create mode 100644 include/uhd/usrp/mboard/test.hpp create mode 100644 include/uhd/usrp/mboard/usrp2.hpp create mode 100644 include/uhd/usrp/usrp.hpp create mode 100644 include/uhd/utils.hpp create mode 100644 include/uhd/wax.hpp delete mode 100644 include/usrp_uhd.hpp delete mode 100644 include/usrp_uhd/.gitignore delete mode 100644 include/usrp_uhd/Makefile.am delete mode 100644 include/usrp_uhd/device.hpp delete mode 100644 include/usrp_uhd/device_addr.hpp delete mode 100644 include/usrp_uhd/gain_handler.hpp delete mode 100644 include/usrp_uhd/props.hpp delete mode 100644 include/usrp_uhd/quadradio/.gitignore delete mode 100644 include/usrp_uhd/quadradio/Makefile.am delete mode 100644 include/usrp_uhd/time_spec.hpp delete mode 100644 include/usrp_uhd/usrp/.gitignore delete mode 100644 include/usrp_uhd/usrp/Makefile.am delete mode 100644 include/usrp_uhd/usrp/dboard/.gitignore delete mode 100644 include/usrp_uhd/usrp/dboard/Makefile.am delete mode 100644 include/usrp_uhd/usrp/dboard/base.hpp delete mode 100644 include/usrp_uhd/usrp/dboard/id.hpp delete mode 100644 include/usrp_uhd/usrp/dboard/interface.hpp delete mode 100644 include/usrp_uhd/usrp/dboard/manager.hpp delete mode 100644 include/usrp_uhd/usrp/mboard/.gitignore delete mode 100644 include/usrp_uhd/usrp/mboard/Makefile.am delete mode 100644 include/usrp_uhd/usrp/mboard/base.hpp delete mode 100644 include/usrp_uhd/usrp/mboard/test.hpp delete mode 100644 include/usrp_uhd/usrp/mboard/usrp2.hpp delete mode 100644 include/usrp_uhd/usrp/usrp.hpp delete mode 100644 include/usrp_uhd/utils.hpp delete mode 100644 include/usrp_uhd/wax.hpp create mode 100644 lib/uhd.cpp delete mode 100644 lib/usrp_uhd.cpp create mode 100644 uhd.pc.in delete mode 100644 usrp_uhd.pc.in diff --git a/.gitignore b/.gitignore index e9db284b3..5d81aa58a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -/usrp_uhd.pc +/uhd.pc /Makefile /Makefile.in /aclocal.m4 diff --git a/Makefile.am b/Makefile.am index a1f915f93..a76913311 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,13 +23,13 @@ SUBDIRS = include lib test apps ## Handle the pkgconfig file generation ######################################################################## pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = usrp_uhd.pc +pkgconfig_DATA = uhd.pc -EXTRA_DIST = $(srcdir)/usrp_uhd.pc.in -BUILT_SOURCES = usrp_uhd.pc +EXTRA_DIST = $(srcdir)/uhd.pc.in +BUILT_SOURCES = uhd.pc MOSTLYCLEANFILES = $(BUILT_SOURCES) -usrp_uhd.pc: $(srcdir)/usrp_uhd.pc.in Makefile +uhd.pc: $(srcdir)/uhd.pc.in Makefile $(SED) \ -e 's|@prefix[@]|$(prefix)|g' \ -e 's|@exec_prefix[@]|$(exec_prefix)|g' \ diff --git a/Makefile.common b/Makefile.common index 80ed49f2b..742a95b31 100644 --- a/Makefile.common +++ b/Makefile.common @@ -15,13 +15,13 @@ # along with this program. If not, see . # -USRP_UHD_LA = $(abs_top_builddir)/lib/libusrp_uhd.la +UHD_LA = $(abs_top_builddir)/lib/libuhd.la -USRP_UHD_USRP_LA = $(abs_top_builddir)/lib/usrp/lib.la +UHD_USRP_LA = $(abs_top_builddir)/lib/usrp/lib.la -USRP_UHD_USRP_DBOARD_LA = $(abs_top_builddir)/lib/usrp/dboard/lib.la +UHD_USRP_DBOARD_LA = $(abs_top_builddir)/lib/usrp/dboard/lib.la -USRP_UHD_USRP_MBOARD_LA = $(abs_top_builddir)/lib/usrp/mboard/lib.la +UHD_USRP_MBOARD_LA = $(abs_top_builddir)/lib/usrp/mboard/lib.la GENERAL_CPPFLAGS = \ -I$(top_srcdir)/include \ diff --git a/apps/Makefile.am b/apps/Makefile.am index c18b8c8f5..67ab6b0ed 100644 --- a/apps/Makefile.am +++ b/apps/Makefile.am @@ -23,7 +23,7 @@ AM_CPPFLAGS = $(GENERAL_CPPFLAGS) LDADD = \ $(GENERAL_LDDFLAGS) \ - $(USRP_UHD_LA) + $(UHD_LA) noinst_PROGRAMS = discover_usrps diff --git a/apps/discover_usrps.cpp b/apps/discover_usrps.cpp index a8d82e015..036d6378a 100644 --- a/apps/discover_usrps.cpp +++ b/apps/discover_usrps.cpp @@ -15,13 +15,13 @@ // along with this program. If not, see . // -#include +#include #include #include #include namespace po = boost::program_options; -using namespace usrp_uhd; +using namespace uhd; int main(int argc, char *argv[]){ po::options_description desc("Allowed options"); @@ -41,7 +41,7 @@ int main(int argc, char *argv[]){ } //extract the ip address (not optional for now) - usrp_uhd::device_addr_t device_addr(usrp_uhd::DEVICE_ADDR_TYPE_UDP); + uhd::device_addr_t device_addr(uhd::DEVICE_ADDR_TYPE_UDP); if (vm.count("ip-addr")) { device_addr.udp_args.addr = vm["ip-addr"].as(); } else { @@ -50,7 +50,7 @@ int main(int argc, char *argv[]){ } //discover the usrps - std::vector device_addrs = usrp_uhd::device::discover(device_addr); + std::vector device_addrs = uhd::device::discover(device_addr); for (size_t i = 0; i < device_addrs.size(); i++){ std::cout << "--------------------------------------------------" << std::endl; std::cout << "-- USRP Device " << i << std::endl; diff --git a/configure.ac b/configure.ac index 64c50c7da..58648ce2d 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ ################################################## AC_PREREQ(2.60) AC_INIT -AM_INIT_AUTOMAKE(usrp_uhd, 0) +AM_INIT_AUTOMAKE(uhd, 0) ################################################## ## Setup C++ and Libtool @@ -106,11 +106,11 @@ AC_CONFIG_FILES([ \ Makefile \ apps/Makefile \ include/Makefile \ - include/usrp_uhd/Makefile \ - include/usrp_uhd/usrp/Makefile \ - include/usrp_uhd/usrp/dboard/Makefile \ - include/usrp_uhd/usrp/mboard/Makefile \ - include/usrp_uhd/quadradio/Makefile \ + include/uhd/Makefile \ + include/uhd/usrp/Makefile \ + include/uhd/usrp/dboard/Makefile \ + include/uhd/usrp/mboard/Makefile \ + include/uhd/quadradio/Makefile \ lib/Makefile \ lib/usrp/Makefile \ lib/usrp/dboard/Makefile \ diff --git a/include/Makefile.am b/include/Makefile.am index 35f492461..d1011b41d 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -17,8 +17,8 @@ include $(top_srcdir)/Makefile.common -SUBDIRS = usrp_uhd +SUBDIRS = uhd this_includedir = $(includedir) this_include_HEADERS = \ - usrp_uhd.hpp + uhd.hpp diff --git a/include/uhd.hpp b/include/uhd.hpp new file mode 100644 index 000000000..ee8c13dfe --- /dev/null +++ b/include/uhd.hpp @@ -0,0 +1,24 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#ifndef INCLUDED_UHD_HPP +#define INCLUDED_UHD_HPP + +//include convenience headers +#include + +#endif /* INCLUDED_UHD_HPP */ diff --git a/include/uhd/.gitignore b/include/uhd/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/include/uhd/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/include/uhd/Makefile.am b/include/uhd/Makefile.am new file mode 100644 index 000000000..00691d920 --- /dev/null +++ b/include/uhd/Makefile.am @@ -0,0 +1,30 @@ +# +# Copyright 2010 Ettus Research LLC +# +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 . +# + +include $(top_srcdir)/Makefile.common + +SUBDIRS = usrp quadradio + +this_includedir = $(includedir)/uhd +this_include_HEADERS = \ + device.hpp \ + device_addr.hpp \ + gain_handler.hpp \ + props.hpp \ + time_spec.hpp \ + utils.hpp \ + wax.hpp diff --git a/include/uhd/device.hpp b/include/uhd/device.hpp new file mode 100644 index 000000000..63f897f97 --- /dev/null +++ b/include/uhd/device.hpp @@ -0,0 +1,90 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#ifndef INCLUDED_UHD_DEVICE_HPP +#define INCLUDED_UHD_DEVICE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace uhd{ + +/*! + * The usrp device interface represents the usrp hardware. + * The api allows for discovery, configuration, and streaming. + */ +class device : boost::noncopyable, public wax::obj{ + +public: + typedef boost::shared_ptr sptr; + + //argument types for send and recv raw methods + //the send args is a vector of the boost asio buffers + //the recv args is a callback that takes a boost asio buffer + typedef std::vector send_args_t; + typedef boost::function recv_args_t; + + //structors + device(void); + virtual ~device(void); + + /*! + * \brief Discover usrp devices attached to the host. + * + * The hint device address should be used to narrow down the search + * to particular transport types and/or transport arguments. + * + * \param hint a partially (or fully) filled in device address + * \return a vector of device addresses for all usrps on the system + */ + static std::vector discover(const device_addr_t & hint); + + /*! + * \brief Create a new usrp device from the device address hint. + * + * The make routine will call discover and pick one of the results. + * By default, the first result will be used to create a new device. + * Use the which parameter as an index into the list of results. + * + * \param hint a partially (or fully) filled in device address + * \param which which address to use when multiple are discovered + * \return a shared pointer to a new device instance + */ + static sptr make(const device_addr_t & hint, size_t which = 0); + + /*! + * Get the device address for this board. + */ + device_addr_t get_device_addr(void); + + //the io interface + virtual void send_raw(const send_args_t &) = 0; + virtual void recv_raw(const recv_args_t &) = 0; + + //connect dsps and subdevs + void connect(const wax::obj &src, const wax::obj &sink); +}; + +} //namespace uhd + +#endif /* INCLUDED_UHD_DEVICE_HPP */ diff --git a/include/uhd/device_addr.hpp b/include/uhd/device_addr.hpp new file mode 100644 index 000000000..84ae60881 --- /dev/null +++ b/include/uhd/device_addr.hpp @@ -0,0 +1,97 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#ifndef INCLUDED_UHD_DEVICE_ADDR_HPP +#define INCLUDED_UHD_DEVICE_ADDR_HPP + +#include +#include +#include +#include + +namespace uhd{ + + /*! + * Wrapper for an ethernet mac address. + * Provides conversion between string and binary formats. + */ + struct mac_addr_t{ + struct ether_addr mac_addr; + mac_addr_t(const std::string &mac_addr_str = "00:00:00:00:00:00"); + std::string to_string(void) const; + }; + + /*! + * Possible usrp device interface types. + */ + enum device_addr_type_t{ + DEVICE_ADDR_TYPE_AUTO, + DEVICE_ADDR_TYPE_VIRTUAL, + DEVICE_ADDR_TYPE_USB, + DEVICE_ADDR_TYPE_ETH, + DEVICE_ADDR_TYPE_UDP, + DEVICE_ADDR_TYPE_GPMC + }; + + /*! + * Structure to hold properties that identify a usrp device. + */ + struct device_addr_t{ + device_addr_type_t type; + struct{ + size_t num_rx_dsps; + size_t num_tx_dsps; + size_t num_dboards; + } virtual_args; + struct{ + uint16_t vendor_id; + uint16_t product_id; + } usb_args; + struct{ + std::string ifc; + std::string mac_addr; + } eth_args; + struct{ + std::string addr; + } udp_args; + struct{ + //TODO unknown for now + } gpmc_args; + + //the discovery args are filled in by the discovery routine + struct{ + uint16_t mboard_id; + } discovery_args; + + /*! + * \brief Convert a usrp device_addr_t into a string representation + */ + std::string to_string(void) const; + + /*! + * \brief Default constructor to initialize the device_addr_t struct + */ + device_addr_t(device_addr_type_t device_addr_type = DEVICE_ADDR_TYPE_AUTO); + }; + +} //namespace uhd + +//ability to use types with stream operators +std::ostream& operator<<(std::ostream &os, const uhd::device_addr_t &x); +std::ostream& operator<<(std::ostream &os, const uhd::mac_addr_t &x); + +#endif /* INCLUDED_UHD_DEVICE_ADDR_HPP */ diff --git a/include/uhd/gain_handler.hpp b/include/uhd/gain_handler.hpp new file mode 100644 index 000000000..06800315a --- /dev/null +++ b/include/uhd/gain_handler.hpp @@ -0,0 +1,101 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#include +#include +#include +#include +#include + +#ifndef INCLUDED_UHD_GAIN_HANDLER_HPP +#define INCLUDED_UHD_GAIN_HANDLER_HPP + +namespace uhd{ + +class gain_handler{ +public: + typedef boost::shared_ptr sptr; + + template gain_handler( + wax::obj *wax_obj_ptr, const T &gain_prop, + const T &gain_min_prop, const T &gain_max_prop, + const T &gain_step_prop, const T &gain_names_prop + ){ + _wax_obj_ptr = wax_obj_ptr; + _gain_prop = gain_prop; + _gain_min_prop = gain_min_prop; + _gain_max_prop = gain_max_prop; + _gain_step_prop = gain_step_prop; + _gain_names_prop = gain_names_prop; + _is_equal = boost::bind(&gain_handler::is_equal, _1, _2); + } + + ~gain_handler(void); + + /*! + * Intercept gets for overall gain, min, max, step. + * Ensures that the gain name is valid. + * \return true for handled, false to pass on + */ + bool intercept_get(const wax::obj &key, wax::obj &val); + + /*! + * Intercept sets for overall gain. + * Ensures that the gain name is valid. + * Ensures that the new gain is within range. + * \return true for handled, false to pass on + */ + bool intercept_set(const wax::obj &key, const wax::obj &val); + +private: + + wax::obj *_wax_obj_ptr; + wax::obj _gain_prop; + wax::obj _gain_min_prop; + wax::obj _gain_max_prop; + wax::obj _gain_step_prop; + wax::obj _gain_names_prop; + + /*! + * Verify that the key is valid: + * If its a named prop for gain, ensure that name is valid. + * If the name if not valid, throw a std::invalid_argument. + * The name can only be valid if its in the list of gain names. + */ + void _check_key(const wax::obj &key); + + /* + * Private interface to test if two wax types are equal: + * The constructor will bind an instance of this for a specific type. + * This bound equals functions allows the intercept methods to be non-templated. + */ + template static bool is_equal(const wax::obj &a, const wax::obj &b){ + try{ + return wax::cast(a) == wax::cast(b); + } + catch(const wax::bad_cast &){ + return false; + } + } + boost::function _is_equal; + +}; + +} //namespace uhd + +#endif /* INCLUDED_UHD_GAIN_HANDLER_HPP */ + diff --git a/include/uhd/props.hpp b/include/uhd/props.hpp new file mode 100644 index 000000000..5e49ab521 --- /dev/null +++ b/include/uhd/props.hpp @@ -0,0 +1,165 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#include +#include +#include +#include +#include + +#ifndef INCLUDED_UHD_PROPS_HPP +#define INCLUDED_UHD_PROPS_HPP + +namespace uhd{ + + //common typedefs for board properties + typedef float gain_t; + typedef double freq_t; + + //scalar types + typedef int int_scalar_t; + typedef float real_scalar_t; + typedef std::complex complex_scalar_t; + + //vector types + typedef std::vector int_vec_t; + typedef std::vector real_vec_t; + typedef std::vector complex_vec_t; + + //typedef for handling named properties + typedef std::vector prop_names_t; + typedef boost::tuple named_prop_t; + + /*! + * Utility function to separate a named property into its components. + * \param key a reference to the prop object + * \param name a reference to the name object + */ + inline named_prop_t extract_named_prop(const wax::obj &key, const std::string &name = ""){ + if (key.type() == typeid(named_prop_t)){ + return wax::cast(key); + } + return named_prop_t(key, name); + } + + /*! + * Possible device properties: + * In general, a device will have a single mboard. + * In certain mimo applications, multiple boards + * will be present in the interface for configuration. + */ + enum device_prop_t{ + DEVICE_PROP_NAME, //ro, std::string + DEVICE_PROP_MBOARD, //ro, wax::obj + DEVICE_PROP_MBOARD_NAMES //ro, prop_names_t + }; + + /*! + * Possible device mboard properties: + * The general mboard properties are listed below. + * Custom properties can be identified with a string + * and discovered though the others property. + */ + enum mboard_prop_t{ + MBOARD_PROP_NAME, //ro, std::string + MBOARD_PROP_OTHERS, //ro, prop_names_t + MBOARD_PROP_MTU, //ro, size_t + MBOARD_PROP_CLOCK_RATE, //ro, freq_t + MBOARD_PROP_RX_DSP, //ro, wax::obj + MBOARD_PROP_RX_DSP_NAMES, //ro, prop_names_t + MBOARD_PROP_TX_DSP, //ro, wax::obj + MBOARD_PROP_TX_DSP_NAMES, //ro, prop_names_t + MBOARD_PROP_RX_DBOARD, //ro, wax::obj + MBOARD_PROP_RX_DBOARD_NAMES, //ro, prop_names_t + MBOARD_PROP_TX_DBOARD, //ro, wax::obj + MBOARD_PROP_TX_DBOARD_NAMES, //ro, prop_names_t + MBOARD_PROP_PPS_SOURCE, //rw, std::string (sma, mimo) + MBOARD_PROP_PPS_SOURCE_NAMES, //ro, prop_names_t + MBOARD_PROP_PPS_POLARITY, //rw, int, +/- 1 + MBOARD_PROP_REF_SOURCE, //rw, std::string (int, sma, mimo) + MBOARD_PROP_REF_SOURCE_NAMES, //ro, prop_names_t + MBOARD_PROP_TIME_NOW, //wo, time_spec_t + MBOARD_PROP_TIME_NEXT_PPS //wo, time_spec_t + }; + + /*! + * Possible device dsp properties: + * A dsp can have a wide range of possible properties. + * A ddc would have a properties "decim", "freq", "taps"... + * Other properties could be gains, complex scalars, enables... + * For this reason the only required properties of a dsp is a name + * and a property to get list of other possible properties. + */ + enum dsp_prop_t{ + DSP_PROP_NAME, //ro, std::string + DSP_PROP_OTHERS //ro, prop_names_t + }; + + /*! + * Possible device dboard properties + */ + enum dboard_prop_t{ + DBOARD_PROP_NAME, //ro, std::string + DBOARD_PROP_SUBDEV, //ro, wax::obj + DBOARD_PROP_SUBDEV_NAMES, //ro, prop_names_t + DBOARD_PROP_CODEC //ro, wax::obj + }; + + /*! + * Possible device codec properties: + * A codec is expected to have a rate and gain elements. + * Other properties can be discovered through the others prop. + */ + enum codec_prop_t{ + CODEC_PROP_NAME, //ro, std::string + CODEC_PROP_OTHERS, //ro, prop_names_t + CODEC_PROP_GAIN, //rw, gain_t + CODEC_PROP_GAIN_MAX, //ro, gain_t + CODEC_PROP_GAIN_MIN, //ro, gain_t + CODEC_PROP_GAIN_STEP, //ro, gain_t + CODEC_PROP_GAIN_NAMES, //ro, prop_names_t + CODEC_PROP_CLOCK_RATE //ro, freq_t + }; + + /*! + * Possible device subdev properties + */ + enum subdev_prop_t{ + SUBDEV_PROP_NAME, //ro, std::string + SUBDEV_PROP_OTHERS, //ro, prop_names_t + SUBDEV_PROP_GAIN, //rw, gain_t + SUBDEV_PROP_GAIN_MAX, //ro, gain_t + SUBDEV_PROP_GAIN_MIN, //ro, gain_t + SUBDEV_PROP_GAIN_STEP, //ro, gain_t + SUBDEV_PROP_GAIN_NAMES, //ro, prop_names_t + SUBDEV_PROP_FREQ, //rw, freq_t + SUBDEV_PROP_FREQ_MAX, //ro, freq_t + SUBDEV_PROP_FREQ_MIN, //ro, freq_t + SUBDEV_PROP_ANTENNA, //rw, std::string + SUBDEV_PROP_ANTENNA_NAMES, //ro, prop_names_t + SUBDEV_PROP_ENABLED, //rw, bool + SUBDEV_PROP_QUADRATURE, //ro, bool + SUBDEV_PROP_IQ_SWAPPED, //ro, bool + SUBDEV_PROP_SPECTRUM_INVERTED, //ro, bool + SUBDEV_PROP_IS_TX, //ro, bool + SUBDEV_PROP_RSSI, //ro, gain_t + SUBDEV_PROP_BANDWIDTH //rw, freq_t + }; + +} //namespace uhd + +#endif /* INCLUDED_UHD_PROPS_HPP */ diff --git a/include/uhd/quadradio/.gitignore b/include/uhd/quadradio/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/include/uhd/quadradio/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/include/uhd/quadradio/Makefile.am b/include/uhd/quadradio/Makefile.am new file mode 100644 index 000000000..8acd4b6be --- /dev/null +++ b/include/uhd/quadradio/Makefile.am @@ -0,0 +1,20 @@ +# +# Copyright 2010 Ettus Research LLC +# +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 . +# + +include $(top_srcdir)/Makefile.common + +SUBDIRS = diff --git a/include/uhd/time_spec.hpp b/include/uhd/time_spec.hpp new file mode 100644 index 000000000..e5657e555 --- /dev/null +++ b/include/uhd/time_spec.hpp @@ -0,0 +1,57 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#include + +#ifndef INCLUDED_UHD_TIME_SPEC_HPP +#define INCLUDED_UHD_TIME_SPEC_HPP + +namespace uhd{ + + /*! + * A time_spec_t holds a seconds and ticks time value. + * The temporal width of a tick depends on the device's clock rate. + * The time_spec_t can be used when setting the time on devices + * and for controlling the start of streaming for applicable dsps. + */ + struct time_spec_t{ + uint32_t secs; + uint32_t ticks; + + /*! + * Create a time_spec_t that holds a wildcard time. + * This will have implementation-specific meaning. + */ + time_spec_t(void){ + secs = ~0; + ticks = ~0; + } + + /*! + * Create a time_spec_t from seconds and ticks. + * \param new_secs the new seconds + * \param new_ticks the new ticks (default = 0) + */ + time_spec_t(uint32_t new_secs, uint32_t new_ticks = 0){ + secs = new_secs; + ticks = new_ticks; + } + }; + +} //namespace uhd + +#endif /* INCLUDED_UHD_TIME_SPEC_HPP */ diff --git a/include/uhd/usrp/.gitignore b/include/uhd/usrp/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/include/uhd/usrp/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/include/uhd/usrp/Makefile.am b/include/uhd/usrp/Makefile.am new file mode 100644 index 000000000..72c37a414 --- /dev/null +++ b/include/uhd/usrp/Makefile.am @@ -0,0 +1,24 @@ +# +# Copyright 2010 Ettus Research LLC +# +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 . +# + +include $(top_srcdir)/Makefile.common + +SUBDIRS = mboard dboard + +this_includedir = $(includedir)/uhd/usrp +this_include_HEADERS = \ + usrp.hpp diff --git a/include/uhd/usrp/dboard/.gitignore b/include/uhd/usrp/dboard/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/include/uhd/usrp/dboard/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/include/uhd/usrp/dboard/Makefile.am b/include/uhd/usrp/dboard/Makefile.am new file mode 100644 index 000000000..83bbf8c67 --- /dev/null +++ b/include/uhd/usrp/dboard/Makefile.am @@ -0,0 +1,27 @@ +# +# Copyright 2010 Ettus Research LLC +# +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 . +# + +include $(top_srcdir)/Makefile.common + +SUBDIRS = + +this_includedir = $(includedir)/uhd/usrp/dboard +this_include_HEADERS = \ + base.hpp \ + id.hpp \ + interface.hpp \ + manager.hpp diff --git a/include/uhd/usrp/dboard/base.hpp b/include/uhd/usrp/dboard/base.hpp new file mode 100644 index 000000000..845e2f669 --- /dev/null +++ b/include/uhd/usrp/dboard/base.hpp @@ -0,0 +1,111 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#ifndef INCLUDED_UHD_USRP_DBOARD_BASE_HPP +#define INCLUDED_UHD_USRP_DBOARD_BASE_HPP + +#include +#include +#include +#include +#include + +namespace uhd{ namespace usrp{ namespace dboard{ + +/*! + * A daughter board base class for all dboards. + * Only other dboard base classes should inherit this. + */ +class base : boost::noncopyable{ +public: + typedef boost::shared_ptr sptr; + //the constructor args consist of a subdev name and an interface + //derived classes should pass the args into the base class ctor + //but should not have to deal with the internals of the args + typedef boost::tuple ctor_args_t; + + //structors + base(ctor_args_t const&); + virtual ~base(void); + + //interface + virtual void rx_get(const wax::obj &key, wax::obj &val) = 0; + virtual void rx_set(const wax::obj &key, const wax::obj &val) = 0; + virtual void tx_get(const wax::obj &key, wax::obj &val) = 0; + virtual void tx_set(const wax::obj &key, const wax::obj &val) = 0; + +protected: + std::string get_subdev_name(void); + interface::sptr get_interface(void); + +private: + std::string _subdev_name; + interface::sptr _dboard_interface; +}; + +/*! + * A xcvr daughter board implements rx and tx methods + * Sub classes for xcvr boards should inherit this. + */ +class xcvr_base : public base{ +public: + /*! + * Create a new xcvr dboard object, override in subclasses. + */ + xcvr_base(ctor_args_t const&); + virtual ~xcvr_base(void); +}; + +/*! + * A rx daughter board only implements rx methods. + * Sub classes for rx-only boards should inherit this. + */ +class rx_base : public base{ +public: + /*! + * Create a new rx dboard object, override in subclasses. + */ + rx_base(ctor_args_t const&); + + virtual ~rx_base(void); + + //override here so the derived classes cannot + void tx_get(const wax::obj &key, wax::obj &val); + void tx_set(const wax::obj &key, const wax::obj &val); +}; + +/*! + * A tx daughter board only implements tx methods. + * Sub classes for rx-only boards should inherit this. + */ +class tx_base : public base{ +public: + /*! + * Create a new rx dboard object, override in subclasses. + */ + tx_base(ctor_args_t const&); + + virtual ~tx_base(void); + + //override here so the derived classes cannot + void rx_get(const wax::obj &key, wax::obj &val); + void rx_set(const wax::obj &key, const wax::obj &val); +}; + +}}} //namespace + +#endif /* INCLUDED_UHD_USRP_DBOARD_BASE_HPP */ diff --git a/include/uhd/usrp/dboard/id.hpp b/include/uhd/usrp/dboard/id.hpp new file mode 100644 index 000000000..bedc01f48 --- /dev/null +++ b/include/uhd/usrp/dboard/id.hpp @@ -0,0 +1,34 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#include + +#ifndef INCLUDED_UHD_USRP_DBOARD_ID_HPP +#define INCLUDED_UHD_USRP_DBOARD_ID_HPP + +namespace uhd{ namespace usrp{ namespace dboard{ + +enum dboard_id_t{ + ID_BASIC_TX = 0x0000, + ID_BASIC_RX = 0x0001 +}; + +}}} //namespace + +std::ostream& operator<<(std::ostream &, const uhd::usrp::dboard::dboard_id_t &); + +#endif /* INCLUDED_UHD_USRP_DBOARD_ID_HPP */ diff --git a/include/uhd/usrp/dboard/interface.hpp b/include/uhd/usrp/dboard/interface.hpp new file mode 100644 index 000000000..c18247564 --- /dev/null +++ b/include/uhd/usrp/dboard/interface.hpp @@ -0,0 +1,167 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#ifndef INCLUDED_UHD_USRP_DBOARD_INTERFACE_HPP +#define INCLUDED_UHD_USRP_DBOARD_INTERFACE_HPP + +#include +#include + +namespace uhd{ namespace usrp{ namespace dboard{ + +/*! + * The daughter board interface to be subclassed. + * A dboard instance interfaces with the mboard though this api. + * This interface provides i2c, spi, gpio, atr, aux dac/adc access. + * Each mboard should have a specially tailored dboard interface. + */ +class interface{ +public: + typedef boost::shared_ptr sptr; + + //tells the host which device to use + enum spi_dev_t{ + SPI_TX_DEV, + SPI_RX_DEV + }; + + //args for writing spi data + enum spi_push_t{ + SPI_PUSH_RISE, + SPI_PUSH_FALL + }; + + //args for reading spi data + enum spi_latch_t{ + SPI_LATCH_RISE, + SPI_LATCH_FALL + }; + + //tell the host which gpio bank + enum gpio_bank_t{ + GPIO_TX_BANK, + GPIO_RX_BANK + }; + + //structors + interface(void); + virtual ~interface(void); + + /*! + * Write to an aux dac. + * \param which_dac the dac index 0, 1, 2, 3... + * \param value the value to write + */ + virtual void write_aux_dac(int which_dac, int value) = 0; + + /*! + * Read from an aux adc. + * \param which_adc the adc index 0, 1, 2, 3... + * \return the value that was read + */ + virtual int read_aux_adc(int which_adc) = 0; + + /*! + * Set daughterboard ATR register. + * The ATR register for a particular bank has 2 values: + * one value when transmitting, one when receiving. + * The mask controls which pins are controlled by ATR. + * + * \param bank GPIO_TX_BANK or GPIO_RX_BANK + * \param tx_value 16-bits, 0=FPGA input, 1=FPGA output + * \param rx_value 16-bits, 0=FPGA input, 1=FPGA output + * \param mask 16-bits, 0=ignore, 1=atr + */ + virtual void set_atr_reg(gpio_bank_t bank, uint16_t tx_value, uint16_t rx_value, uint16_t mask) = 0; + + /*! + * Set daughterboard GPIO data direction register. + * + * \param bank GPIO_TX_BANK or GPIO_RX_BANK + * \param value 16-bits, 0=FPGA input, 1=FPGA output + * \param mask 16-bits, 0=ignore, 1=set + */ + virtual void set_gpio_ddr(gpio_bank_t bank, uint16_t value, uint16_t mask) = 0; + + /*! + * Set daughterboard GPIO pin values. + * + * \param bank GPIO_TX_BANK or GPIO_RX_BANK + * \param value 16 bits, 0=low, 1=high + * \param mask 16 bits, 0=ignore, 1=set + */ + virtual void write_gpio(gpio_bank_t bank, uint16_t value, uint16_t mask) = 0; + + /*! + * Read daughterboard GPIO pin values + * + * \param bank GPIO_TX_BANK or GPIO_RX_BANK + * \return the value of the gpio bank + */ + virtual uint16_t read_gpio(gpio_bank_t bank) = 0; + + /*! + * \brief Write to I2C peripheral + * \param i2c_addr I2C bus address (7-bits) + * \param buf the data to write + */ + virtual void write_i2c(int i2c_addr, const std::string &buf) = 0; + + /*! + * \brief Read from I2C peripheral + * \param i2c_addr I2C bus address (7-bits) + * \param len number of bytes to read + * \return the data read if successful, else a zero length string. + */ + virtual std::string read_i2c(int i2c_addr, size_t len) = 0; + + /*! + * \brief Write data to SPI bus peripheral. + * + * \param dev which spi device + * \param push args for writing + * \param buf the data to write + */ + virtual void write_spi(spi_dev_t dev, spi_push_t push, const std::string &buf) = 0; + + /*! + * \brief Read data from SPI bus peripheral. + * + * \param dev which spi device + * \param push args for reading + * \param len number of bytes to read + * \return the data read if sucessful, else a zero length string. + */ + virtual std::string read_spi(spi_dev_t dev, spi_latch_t latch, size_t len) = 0; + + /*! + * \brief Get the rate of the rx dboard clock. + * \return the clock rate + */ + virtual double get_rx_clock_rate(void) = 0; + + /*! + * \brief Get the rate of the tx dboard clock. + * \return the clock rate + */ + virtual double get_tx_clock_rate(void) = 0; + +}; + +}}} //namespace + +#endif /* INCLUDED_UHD_USRP_DBOARD_INTERFACE_HPP */ diff --git a/include/uhd/usrp/dboard/manager.hpp b/include/uhd/usrp/dboard/manager.hpp new file mode 100644 index 000000000..5934efedc --- /dev/null +++ b/include/uhd/usrp/dboard/manager.hpp @@ -0,0 +1,82 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#ifndef INCLUDED_UHD_USRP_DBOARD_MANAGER_HPP +#define INCLUDED_UHD_USRP_DBOARD_MANAGER_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace uhd{ namespace usrp{ namespace dboard{ + +/*! + * A daughter board subdev manager class. + * Create subdev instances for each subdev on a dboard. + * Provide wax::obj access to the subdevs inside. + */ +class manager : boost::noncopyable{ + +public: + + //dboard constructor (each dboard should have a ::make with this signature) + typedef base::sptr(*dboard_ctor_t)(base::ctor_args_t const&); + + /*! + * Register subdevices for a given dboard id. + * + * \param dboard_id the dboard id (rx or tx) + * \param dboard_ctor the dboard constructor function pointer + * \param subdev_names the names of the subdevs on this dboard + */ + static void register_subdevs( + dboard_id_t dboard_id, + dboard_ctor_t dboard_ctor, + const prop_names_t &subdev_names + ); + +public: + typedef boost::shared_ptr sptr; + //structors + manager( + dboard_id_t rx_dboard_id, + dboard_id_t tx_dboard_id, + interface::sptr dboard_interface + ); + ~manager(void); + + //interface + prop_names_t get_rx_subdev_names(void); + prop_names_t get_tx_subdev_names(void); + wax::obj get_rx_subdev(const std::string &subdev_name); + wax::obj get_tx_subdev(const std::string &subdev_name); + +private: + //list of rx and tx dboards in this manager + //each dboard here is actually a subdevice proxy + //the subdevice proxy is internal to the cpp file + std::map _rx_dboards; + std::map _tx_dboards; +}; + +}}} //namespace + +#endif /* INCLUDED_UHD_USRP_DBOARD_MANAGER_HPP */ diff --git a/include/uhd/usrp/mboard/.gitignore b/include/uhd/usrp/mboard/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/include/uhd/usrp/mboard/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/include/uhd/usrp/mboard/Makefile.am b/include/uhd/usrp/mboard/Makefile.am new file mode 100644 index 000000000..6a85d354e --- /dev/null +++ b/include/uhd/usrp/mboard/Makefile.am @@ -0,0 +1,26 @@ +# +# Copyright 2010 Ettus Research LLC +# +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 . +# + +include $(top_srcdir)/Makefile.common + +SUBDIRS = + +this_includedir = $(includedir)/uhd/usrp/mboard +this_include_HEADERS = \ + base.hpp \ + test.hpp \ + usrp2.hpp diff --git a/include/uhd/usrp/mboard/base.hpp b/include/uhd/usrp/mboard/base.hpp new file mode 100644 index 000000000..a8de81a7e --- /dev/null +++ b/include/uhd/usrp/mboard/base.hpp @@ -0,0 +1,45 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#ifndef INCLUDED_UHD_USRP_MBOARD_BASE_HPP +#define INCLUDED_UHD_USRP_MBOARD_BASE_HPP + +#include +#include +#include + +namespace uhd{ namespace usrp{ namespace mboard{ + +/*! + * A base class for usrp mboard objects. + */ +class base : boost::noncopyable, public wax::obj{ +public: + typedef boost::shared_ptr sptr; + base(void); + ~base(void); + + //TODO other api calls + +private: + virtual void get(const wax::obj &, wax::obj &) = 0; + virtual void set(const wax::obj &, const wax::obj &) = 0; +}; + +}}} //namespace + +#endif /* INCLUDED_UHD_USRP_MBOARD_BASE_HPP */ diff --git a/include/uhd/usrp/mboard/test.hpp b/include/uhd/usrp/mboard/test.hpp new file mode 100644 index 000000000..be435930b --- /dev/null +++ b/include/uhd/usrp/mboard/test.hpp @@ -0,0 +1,46 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#ifndef INCLUDED_UHD_USRP_MBOARD_TEST_HPP +#define INCLUDED_UHD_USRP_MBOARD_TEST_HPP + +#include +#include +#include +#include + +namespace uhd{ namespace usrp{ namespace mboard{ + +/*! + * A test usrp mboard object. + * Exercises access routines for the test suite. + */ +class test : public base{ +public: + test(const device_addr_t &); + ~test(void); + +private: + void get(const wax::obj &, wax::obj &); + void set(const wax::obj &, const wax::obj &); + + std::map _dboard_managers; +}; + +}}} //namespace + +#endif /* INCLUDED_UHD_USRP_MBOARD_TEST_HPP */ diff --git a/include/uhd/usrp/mboard/usrp2.hpp b/include/uhd/usrp/mboard/usrp2.hpp new file mode 100644 index 000000000..8c2430dbd --- /dev/null +++ b/include/uhd/usrp/mboard/usrp2.hpp @@ -0,0 +1,53 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#ifndef INCLUDED_UHD_USRP_MBOARD_USRP2_HPP +#define INCLUDED_UHD_USRP_MBOARD_USRP2_HPP + +#include +#include +#include +#include + +namespace uhd{ namespace usrp{ namespace mboard{ + +/*! + * The usrp2 mboard class. + */ +class usrp2 : public base{ +public: + /*! + * Discover usrp2 devices over the ethernet. + * This static method will be called by the device::discover. + * \param hint a device addr with the usrp2 address filled in + * \return a vector of device addresses for all usrp2s found + */ + static std::vector discover(const device_addr_t &hint); + + usrp2(const device_addr_t &); + ~usrp2(void); + +private: + void get(const wax::obj &, wax::obj &); + void set(const wax::obj &, const wax::obj &); + + std::map _dboard_managers; +}; + +}}} //namespace + +#endif /* INCLUDED_UHD_USRP_MBOARD_USRP2_HPP */ diff --git a/include/uhd/usrp/usrp.hpp b/include/uhd/usrp/usrp.hpp new file mode 100644 index 000000000..eda8f5fc1 --- /dev/null +++ b/include/uhd/usrp/usrp.hpp @@ -0,0 +1,52 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#include +#include +#include + +#ifndef INCLUDED_UHD_USRP_USRP_HPP +#define INCLUDED_UHD_USRP_USRP_HPP + +namespace uhd{ namespace usrp{ + +/*! + * A usrp device provides a device-level interface to usrp mboards. + * In most cases, a usrp device will have only one mboard. + * In the usrp2 mimo case, this device will have two mboards, + * where one talks through the other's control port. + */ +class usrp : public device{ +public: + usrp(const device_addr_t & device_addr); + ~usrp(void); + + void send_raw(const send_args_t &); + void recv_raw(const recv_args_t &); + +private: + void get(const wax::obj &, wax::obj &); + void set(const wax::obj &, const wax::obj &); + + std::map _mboards; + boost::function _send_raw_cb; + boost::function _recv_raw_cb; +}; + +}} //namespace + +#endif /* INCLUDED_UHD_USRP_USRP_HPP */ diff --git a/include/uhd/utils.hpp b/include/uhd/utils.hpp new file mode 100644 index 000000000..b080516a5 --- /dev/null +++ b/include/uhd/utils.hpp @@ -0,0 +1,131 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef INCLUDED_UHD_UTILS_HPP +#define INCLUDED_UHD_UTILS_HPP + +namespace uhd{ + +template //TODO template this better +std::vector get_map_keys(const std::map &m){ + std::vector v; + std::pair p; + BOOST_FOREACH(p, m){ + v.push_back(p.first); + } + return v; +} + +template T signum(T n){ + if (n < 0) return -1; + if (n > 0) return 1; + return 0; +} + +inline void tune( + freq_t target_freq, + freq_t lo_offset, + wax::obj subdev_freq_proxy, + bool subdev_quadrature, + bool subdev_spectrum_inverted, + bool subdev_is_tx, + wax::obj dsp_freq_proxy, + freq_t dsp_sample_rate +){ + // Ask the d'board to tune as closely as it can to target_freq+lo_offset + subdev_freq_proxy = target_freq + lo_offset; + freq_t inter_freq = wax::cast(subdev_freq_proxy); + + // Calculate the DDC setting that will downconvert the baseband from the + // daughterboard to our target frequency. + freq_t delta_freq = target_freq - inter_freq; + int delta_sign = signum(delta_freq); + delta_freq *= delta_sign; + delta_freq = fmod(delta_freq, dsp_sample_rate); + bool inverted = delta_freq > dsp_sample_rate/2.0; + freq_t dxc_freq = inverted? (delta_freq - dsp_sample_rate) : (-delta_freq); + dxc_freq *= delta_sign; + + // If the spectrum is inverted, and the daughterboard doesn't do + // quadrature downconversion, we can fix the inversion by flipping the + // sign of the dxc_freq... (This only happens using the basic_rx board) + if (subdev_spectrum_inverted){ + inverted = not inverted; + } + if (inverted and not subdev_quadrature){ + dxc_freq = -dxc_freq; + inverted = not inverted; + } + if (subdev_is_tx){ + dxc_freq = -dxc_freq; // down conversion versus up conversion + } + + dsp_freq_proxy = dxc_freq; + //freq_t actual_dxc_freq = wax::cast(dsp_freq_proxy); + + //return some kind of tune result tuple/struct +} + +} //namespace uhd + +/*! + * Useful templated functions and classes that I like to pretend are part of stl + */ +namespace std{ + + class assert_error : public std::logic_error{ + public: + explicit assert_error(const string& what_arg) : logic_error(what_arg){ + /* NOP */ + } + }; + + #define ASSERT_THROW(_x) if (not (_x)) { \ + throw std::assert_error("Assertion Failed: " + std::string(#_x)); \ + } + + template + T reduce(InputIterator first, InputIterator last, Function fcn, T init = 0){ + T tmp = init; + for ( ; first != last; ++first ){ + tmp = fcn(tmp, *first); + } + return tmp; + } + + template + bool has(InputIterator first, InputIterator last, const T &elem){ + return last != std::find(first, last, elem); + } + + template + T sum(const T &a, const T &b){ + return a + b; + } + +}//namespace std + +#endif /* INCLUDED_UHD_UTILS_HPP */ diff --git a/include/uhd/wax.hpp b/include/uhd/wax.hpp new file mode 100644 index 000000000..29a96cdb6 --- /dev/null +++ b/include/uhd/wax.hpp @@ -0,0 +1,170 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#ifndef INCLUDED_WAX_HPP +#define INCLUDED_WAX_HPP + +#include +#include + +/*! + * WAX - it's a metaphor! + * + * The WAX framework allows object to have generic/anyobj properties. + * These properties can be addressed through generic/anyobj identifiers. + * A property of a WAX object may even be another WAX object. + * + * When a property is a WAX object, the returned value must be an obj pointer. + * A WAX object provides two objs of pointers: obj::ptr and obj::sptr. + * The choice of pointer vs smart pointer depends on the owner of the memory. + * + * Proprties may be referenced though the [] overloaded operator. + * The [] operator returns a special proxy that allows for assigment. + * Also, the [] operators may be chained as in the folowing examples: + * my_obj[prop1][prop2][prop3] = value + * value = my_obj[prop1][prop2][prop3] + * + * Any value returned from an access operation is of wax::obj. + * To use this value, it must be cast with wax::cast(value). + */ + +namespace wax{ + + /*! + * WAX object base class: + * + * A wax obj has two major purposes: + * 1) to act as a polymorphic container, just like boost any + * 2) to provide a nested set/get properties interface + * + * Internally, the polymorphic container is handled by a boost any. + * For properties, a subclass should override the set and get methods. + * For property nesting, wax obj subclasses return special links + * to other wax obj subclasses, and the api handles the magic. + */ + class obj{ + public: + + /*! + * Default constructor: + * The contents will be empty. + */ + obj(void); + + /*! + * Copy constructor: + * The contents will be cloned. + * \param o another wax::obj + */ + obj(const obj &o); + + /*! + * Templated any type constructor: + * The contents can be anything. + * Uses the boost::any to handle the magic. + * \param o an object of any type + */ + template obj(const T &o){ + _contents = o; + } + + /*! + * Destructor. + */ + virtual ~obj(void); + + /*! + * The chaining operator: + * This operator allows access objs with properties. + * A call to the [] operator will return a new proxy obj. + * The proxy object is an obj with special proxy contents. + * Assignment and casting can be used on this special object + * to access the property referenced by the obj key. + * \param key a key to identify a property within this obj + * \return a special wax obj that proxies the obj and key + */ + obj operator[](const obj &key); + + /*! + * The assignment operator: + * This operator allows for assignment of new contents. + * In the special case where this obj contains a proxy, + * the value will be set to the proxy's property reference. + * \param val the new value to assign to the wax obj + * \return a reference to this obj (*this) + */ + obj & operator=(const obj &val); + + /*! + * Get a link in the chain: + * When a wax obj returns another wax obj as part of a get call, + * the return value should be set to the result of this method. + * Doing so will ensure chain-ability of the returned object. + * \return an obj containing a valid link to a wax obj + */ + obj get_link(void) const; + + /*! + * Get the type of the contents of this obj. + * \return a reference to the type_info + */ + const std::type_info & type(void) const; + + private: + //private interface (override in subclasses) + virtual void get(const obj &, obj &); + virtual void set(const obj &, const obj &); + + /*! + * Resolve the contents of this obj. + * In the case where this obj is a proxy, + * the referenced property will be resolved. + * Otherwise, just get the private contents. + * \return a boost any type with contents + */ + boost::any resolve(void) const; + template friend T cast(const obj &); + + //private contents of this obj + boost::any _contents; + + }; + + /*! + * The wax::bad cast will be thrown when + * cast is called with the wrong typeid. + */ + typedef boost::bad_any_cast bad_cast; + + /*! + * Cast a wax::obj into the desired obj. + * Usage wax::cast(my_value). + * + * \param val the obj to cast + * \return an object of the desired type + * \throw wax::bad_cast when the cast fails + */ + template T cast(const obj &val){ + return boost::any_cast(val.resolve()); + } + +} //namespace wax + +//ability to use wax::obj with stream operators +std::ostream& operator<<(std::ostream &, const wax::obj &); + +#endif /* INCLUDED_WAX_HPP */ diff --git a/include/usrp_uhd.hpp b/include/usrp_uhd.hpp deleted file mode 100644 index 7f1be473c..000000000 --- a/include/usrp_uhd.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#ifndef INCLUDED_USRP_UHD_HPP -#define INCLUDED_USRP_UHD_HPP - -//include convenience headers -#include - -#endif /* INCLUDED_USRP_UHD_HPP */ diff --git a/include/usrp_uhd/.gitignore b/include/usrp_uhd/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/include/usrp_uhd/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/include/usrp_uhd/Makefile.am b/include/usrp_uhd/Makefile.am deleted file mode 100644 index 143fb5b7a..000000000 --- a/include/usrp_uhd/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -# -# Copyright 2010 Ettus Research LLC -# -# This program 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 of the License, or -# (at your option) any later version. -# -# This program 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 . -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = usrp quadradio - -this_includedir = $(includedir)/usrp_uhd -this_include_HEADERS = \ - device.hpp \ - device_addr.hpp \ - gain_handler.hpp \ - props.hpp \ - time_spec.hpp \ - utils.hpp \ - wax.hpp diff --git a/include/usrp_uhd/device.hpp b/include/usrp_uhd/device.hpp deleted file mode 100644 index e0356feb0..000000000 --- a/include/usrp_uhd/device.hpp +++ /dev/null @@ -1,90 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#ifndef INCLUDED_USRP_UHD_DEVICE_HPP -#define INCLUDED_USRP_UHD_DEVICE_HPP - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace usrp_uhd{ - -/*! - * The usrp device interface represents the usrp hardware. - * The api allows for discovery, configuration, and streaming. - */ -class device : boost::noncopyable, public wax::obj{ - -public: - typedef boost::shared_ptr sptr; - - //argument types for send and recv raw methods - //the send args is a vector of the boost asio buffers - //the recv args is a callback that takes a boost asio buffer - typedef std::vector send_args_t; - typedef boost::function recv_args_t; - - //structors - device(void); - virtual ~device(void); - - /*! - * \brief Discover usrp devices attached to the host. - * - * The hint device address should be used to narrow down the search - * to particular transport types and/or transport arguments. - * - * \param hint a partially (or fully) filled in device address - * \return a vector of device addresses for all usrps on the system - */ - static std::vector discover(const device_addr_t & hint); - - /*! - * \brief Create a new usrp device from the device address hint. - * - * The make routine will call discover and pick one of the results. - * By default, the first result will be used to create a new device. - * Use the which parameter as an index into the list of results. - * - * \param hint a partially (or fully) filled in device address - * \param which which address to use when multiple are discovered - * \return a shared pointer to a new device instance - */ - static sptr make(const device_addr_t & hint, size_t which = 0); - - /*! - * Get the device address for this board. - */ - device_addr_t get_device_addr(void); - - //the io interface - virtual void send_raw(const send_args_t &) = 0; - virtual void recv_raw(const recv_args_t &) = 0; - - //connect dsps and subdevs - void connect(const wax::obj &src, const wax::obj &sink); -}; - -} //namespace usrp_uhd - -#endif /* INCLUDED_USRP_UHD_DEVICE_HPP */ diff --git a/include/usrp_uhd/device_addr.hpp b/include/usrp_uhd/device_addr.hpp deleted file mode 100644 index 011e474df..000000000 --- a/include/usrp_uhd/device_addr.hpp +++ /dev/null @@ -1,97 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#ifndef INCLUDED_USRP_UHD_DEVICE_ADDR_HPP -#define INCLUDED_USRP_UHD_DEVICE_ADDR_HPP - -#include -#include -#include -#include - -namespace usrp_uhd{ - - /*! - * Wrapper for an ethernet mac address. - * Provides conversion between string and binary formats. - */ - struct mac_addr_t{ - struct ether_addr mac_addr; - mac_addr_t(const std::string &mac_addr_str = "00:00:00:00:00:00"); - std::string to_string(void) const; - }; - - /*! - * Possible usrp device interface types. - */ - enum device_addr_type_t{ - DEVICE_ADDR_TYPE_AUTO, - DEVICE_ADDR_TYPE_VIRTUAL, - DEVICE_ADDR_TYPE_USB, - DEVICE_ADDR_TYPE_ETH, - DEVICE_ADDR_TYPE_UDP, - DEVICE_ADDR_TYPE_GPMC - }; - - /*! - * Structure to hold properties that identify a usrp device. - */ - struct device_addr_t{ - device_addr_type_t type; - struct{ - size_t num_rx_dsps; - size_t num_tx_dsps; - size_t num_dboards; - } virtual_args; - struct{ - uint16_t vendor_id; - uint16_t product_id; - } usb_args; - struct{ - std::string ifc; - std::string mac_addr; - } eth_args; - struct{ - std::string addr; - } udp_args; - struct{ - //TODO unknown for now - } gpmc_args; - - //the discovery args are filled in by the discovery routine - struct{ - uint16_t mboard_id; - } discovery_args; - - /*! - * \brief Convert a usrp device_addr_t into a string representation - */ - std::string to_string(void) const; - - /*! - * \brief Default constructor to initialize the device_addr_t struct - */ - device_addr_t(device_addr_type_t device_addr_type = DEVICE_ADDR_TYPE_AUTO); - }; - -} //namespace usrp_uhd - -//ability to use types with stream operators -std::ostream& operator<<(std::ostream &os, const usrp_uhd::device_addr_t &x); -std::ostream& operator<<(std::ostream &os, const usrp_uhd::mac_addr_t &x); - -#endif /* INCLUDED_USRP_UHD_DEVICE_ADDR_HPP */ diff --git a/include/usrp_uhd/gain_handler.hpp b/include/usrp_uhd/gain_handler.hpp deleted file mode 100644 index 786db993b..000000000 --- a/include/usrp_uhd/gain_handler.hpp +++ /dev/null @@ -1,101 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#include -#include -#include -#include -#include - -#ifndef INCLUDED_USRP_UHD_GAIN_HANDLER_HPP -#define INCLUDED_USRP_UHD_GAIN_HANDLER_HPP - -namespace usrp_uhd{ - -class gain_handler{ -public: - typedef boost::shared_ptr sptr; - - template gain_handler( - wax::obj *wax_obj_ptr, const T &gain_prop, - const T &gain_min_prop, const T &gain_max_prop, - const T &gain_step_prop, const T &gain_names_prop - ){ - _wax_obj_ptr = wax_obj_ptr; - _gain_prop = gain_prop; - _gain_min_prop = gain_min_prop; - _gain_max_prop = gain_max_prop; - _gain_step_prop = gain_step_prop; - _gain_names_prop = gain_names_prop; - _is_equal = boost::bind(&gain_handler::is_equal, _1, _2); - } - - ~gain_handler(void); - - /*! - * Intercept gets for overall gain, min, max, step. - * Ensures that the gain name is valid. - * \return true for handled, false to pass on - */ - bool intercept_get(const wax::obj &key, wax::obj &val); - - /*! - * Intercept sets for overall gain. - * Ensures that the gain name is valid. - * Ensures that the new gain is within range. - * \return true for handled, false to pass on - */ - bool intercept_set(const wax::obj &key, const wax::obj &val); - -private: - - wax::obj *_wax_obj_ptr; - wax::obj _gain_prop; - wax::obj _gain_min_prop; - wax::obj _gain_max_prop; - wax::obj _gain_step_prop; - wax::obj _gain_names_prop; - - /*! - * Verify that the key is valid: - * If its a named prop for gain, ensure that name is valid. - * If the name if not valid, throw a std::invalid_argument. - * The name can only be valid if its in the list of gain names. - */ - void _check_key(const wax::obj &key); - - /* - * Private interface to test if two wax types are equal: - * The constructor will bind an instance of this for a specific type. - * This bound equals functions allows the intercept methods to be non-templated. - */ - template static bool is_equal(const wax::obj &a, const wax::obj &b){ - try{ - return wax::cast(a) == wax::cast(b); - } - catch(const wax::bad_cast &){ - return false; - } - } - boost::function _is_equal; - -}; - -} //namespace usrp_uhd - -#endif /* INCLUDED_USRP_UHD_GAIN_HANDLER_HPP */ - diff --git a/include/usrp_uhd/props.hpp b/include/usrp_uhd/props.hpp deleted file mode 100644 index de3280969..000000000 --- a/include/usrp_uhd/props.hpp +++ /dev/null @@ -1,165 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#include -#include -#include -#include -#include - -#ifndef INCLUDED_USRP_UHD_PROPS_HPP -#define INCLUDED_USRP_UHD_PROPS_HPP - -namespace usrp_uhd{ - - //common typedefs for board properties - typedef float gain_t; - typedef double freq_t; - - //scalar types - typedef int int_scalar_t; - typedef float real_scalar_t; - typedef std::complex complex_scalar_t; - - //vector types - typedef std::vector int_vec_t; - typedef std::vector real_vec_t; - typedef std::vector complex_vec_t; - - //typedef for handling named properties - typedef std::vector prop_names_t; - typedef boost::tuple named_prop_t; - - /*! - * Utility function to separate a named property into its components. - * \param key a reference to the prop object - * \param name a reference to the name object - */ - inline named_prop_t extract_named_prop(const wax::obj &key, const std::string &name = ""){ - if (key.type() == typeid(named_prop_t)){ - return wax::cast(key); - } - return named_prop_t(key, name); - } - - /*! - * Possible device properties: - * In general, a device will have a single mboard. - * In certain mimo applications, multiple boards - * will be present in the interface for configuration. - */ - enum device_prop_t{ - DEVICE_PROP_NAME, //ro, std::string - DEVICE_PROP_MBOARD, //ro, wax::obj - DEVICE_PROP_MBOARD_NAMES //ro, prop_names_t - }; - - /*! - * Possible device mboard properties: - * The general mboard properties are listed below. - * Custom properties can be identified with a string - * and discovered though the others property. - */ - enum mboard_prop_t{ - MBOARD_PROP_NAME, //ro, std::string - MBOARD_PROP_OTHERS, //ro, prop_names_t - MBOARD_PROP_MTU, //ro, size_t - MBOARD_PROP_CLOCK_RATE, //ro, freq_t - MBOARD_PROP_RX_DSP, //ro, wax::obj - MBOARD_PROP_RX_DSP_NAMES, //ro, prop_names_t - MBOARD_PROP_TX_DSP, //ro, wax::obj - MBOARD_PROP_TX_DSP_NAMES, //ro, prop_names_t - MBOARD_PROP_RX_DBOARD, //ro, wax::obj - MBOARD_PROP_RX_DBOARD_NAMES, //ro, prop_names_t - MBOARD_PROP_TX_DBOARD, //ro, wax::obj - MBOARD_PROP_TX_DBOARD_NAMES, //ro, prop_names_t - MBOARD_PROP_PPS_SOURCE, //rw, std::string (sma, mimo) - MBOARD_PROP_PPS_SOURCE_NAMES, //ro, prop_names_t - MBOARD_PROP_PPS_POLARITY, //rw, int, +/- 1 - MBOARD_PROP_REF_SOURCE, //rw, std::string (int, sma, mimo) - MBOARD_PROP_REF_SOURCE_NAMES, //ro, prop_names_t - MBOARD_PROP_TIME_NOW, //wo, time_spec_t - MBOARD_PROP_TIME_NEXT_PPS //wo, time_spec_t - }; - - /*! - * Possible device dsp properties: - * A dsp can have a wide range of possible properties. - * A ddc would have a properties "decim", "freq", "taps"... - * Other properties could be gains, complex scalars, enables... - * For this reason the only required properties of a dsp is a name - * and a property to get list of other possible properties. - */ - enum dsp_prop_t{ - DSP_PROP_NAME, //ro, std::string - DSP_PROP_OTHERS //ro, prop_names_t - }; - - /*! - * Possible device dboard properties - */ - enum dboard_prop_t{ - DBOARD_PROP_NAME, //ro, std::string - DBOARD_PROP_SUBDEV, //ro, wax::obj - DBOARD_PROP_SUBDEV_NAMES, //ro, prop_names_t - DBOARD_PROP_CODEC //ro, wax::obj - }; - - /*! - * Possible device codec properties: - * A codec is expected to have a rate and gain elements. - * Other properties can be discovered through the others prop. - */ - enum codec_prop_t{ - CODEC_PROP_NAME, //ro, std::string - CODEC_PROP_OTHERS, //ro, prop_names_t - CODEC_PROP_GAIN, //rw, gain_t - CODEC_PROP_GAIN_MAX, //ro, gain_t - CODEC_PROP_GAIN_MIN, //ro, gain_t - CODEC_PROP_GAIN_STEP, //ro, gain_t - CODEC_PROP_GAIN_NAMES, //ro, prop_names_t - CODEC_PROP_CLOCK_RATE //ro, freq_t - }; - - /*! - * Possible device subdev properties - */ - enum subdev_prop_t{ - SUBDEV_PROP_NAME, //ro, std::string - SUBDEV_PROP_OTHERS, //ro, prop_names_t - SUBDEV_PROP_GAIN, //rw, gain_t - SUBDEV_PROP_GAIN_MAX, //ro, gain_t - SUBDEV_PROP_GAIN_MIN, //ro, gain_t - SUBDEV_PROP_GAIN_STEP, //ro, gain_t - SUBDEV_PROP_GAIN_NAMES, //ro, prop_names_t - SUBDEV_PROP_FREQ, //rw, freq_t - SUBDEV_PROP_FREQ_MAX, //ro, freq_t - SUBDEV_PROP_FREQ_MIN, //ro, freq_t - SUBDEV_PROP_ANTENNA, //rw, std::string - SUBDEV_PROP_ANTENNA_NAMES, //ro, prop_names_t - SUBDEV_PROP_ENABLED, //rw, bool - SUBDEV_PROP_QUADRATURE, //ro, bool - SUBDEV_PROP_IQ_SWAPPED, //ro, bool - SUBDEV_PROP_SPECTRUM_INVERTED, //ro, bool - SUBDEV_PROP_IS_TX, //ro, bool - SUBDEV_PROP_RSSI, //ro, gain_t - SUBDEV_PROP_BANDWIDTH //rw, freq_t - }; - -} //namespace usrp_uhd - -#endif /* INCLUDED_USRP_UHD_PROPS_HPP */ diff --git a/include/usrp_uhd/quadradio/.gitignore b/include/usrp_uhd/quadradio/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/include/usrp_uhd/quadradio/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/include/usrp_uhd/quadradio/Makefile.am b/include/usrp_uhd/quadradio/Makefile.am deleted file mode 100644 index 8acd4b6be..000000000 --- a/include/usrp_uhd/quadradio/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -# -# Copyright 2010 Ettus Research LLC -# -# This program 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 of the License, or -# (at your option) any later version. -# -# This program 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 . -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = diff --git a/include/usrp_uhd/time_spec.hpp b/include/usrp_uhd/time_spec.hpp deleted file mode 100644 index 1a84aa7fb..000000000 --- a/include/usrp_uhd/time_spec.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#include - -#ifndef INCLUDED_USRP_UHD_TIME_SPEC_HPP -#define INCLUDED_USRP_UHD_TIME_SPEC_HPP - -namespace usrp_uhd{ - - /*! - * A time_spec_t holds a seconds and ticks time value. - * The temporal width of a tick depends on the device's clock rate. - * The time_spec_t can be used when setting the time on devices - * and for controlling the start of streaming for applicable dsps. - */ - struct time_spec_t{ - uint32_t secs; - uint32_t ticks; - - /*! - * Create a time_spec_t that holds a wildcard time. - * This will have implementation-specific meaning. - */ - time_spec_t(void){ - secs = ~0; - ticks = ~0; - } - - /*! - * Create a time_spec_t from seconds and ticks. - * \param new_secs the new seconds - * \param new_ticks the new ticks (default = 0) - */ - time_spec_t(uint32_t new_secs, uint32_t new_ticks = 0){ - secs = new_secs; - ticks = new_ticks; - } - }; - -} //namespace usrp_uhd - -#endif /* INCLUDED_USRP_UHD_TIME_SPEC_HPP */ diff --git a/include/usrp_uhd/usrp/.gitignore b/include/usrp_uhd/usrp/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/include/usrp_uhd/usrp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/include/usrp_uhd/usrp/Makefile.am b/include/usrp_uhd/usrp/Makefile.am deleted file mode 100644 index a96cd67d2..000000000 --- a/include/usrp_uhd/usrp/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright 2010 Ettus Research LLC -# -# This program 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 of the License, or -# (at your option) any later version. -# -# This program 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 . -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = mboard dboard - -this_includedir = $(includedir)/usrp_uhd/usrp -this_include_HEADERS = \ - usrp.hpp diff --git a/include/usrp_uhd/usrp/dboard/.gitignore b/include/usrp_uhd/usrp/dboard/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/include/usrp_uhd/usrp/dboard/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/include/usrp_uhd/usrp/dboard/Makefile.am b/include/usrp_uhd/usrp/dboard/Makefile.am deleted file mode 100644 index a07ec3160..000000000 --- a/include/usrp_uhd/usrp/dboard/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright 2010 Ettus Research LLC -# -# This program 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 of the License, or -# (at your option) any later version. -# -# This program 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 . -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = - -this_includedir = $(includedir)/usrp_uhd/usrp/dboard -this_include_HEADERS = \ - base.hpp \ - id.hpp \ - interface.hpp \ - manager.hpp diff --git a/include/usrp_uhd/usrp/dboard/base.hpp b/include/usrp_uhd/usrp/dboard/base.hpp deleted file mode 100644 index 50896b9a8..000000000 --- a/include/usrp_uhd/usrp/dboard/base.hpp +++ /dev/null @@ -1,111 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#ifndef INCLUDED_USRP_UHD_USRP_DBOARD_BASE_HPP -#define INCLUDED_USRP_UHD_USRP_DBOARD_BASE_HPP - -#include -#include -#include -#include -#include - -namespace usrp_uhd{ namespace usrp{ namespace dboard{ - -/*! - * A daughter board base class for all dboards. - * Only other dboard base classes should inherit this. - */ -class base : boost::noncopyable{ -public: - typedef boost::shared_ptr sptr; - //the constructor args consist of a subdev name and an interface - //derived classes should pass the args into the base class ctor - //but should not have to deal with the internals of the args - typedef boost::tuple ctor_args_t; - - //structors - base(ctor_args_t const&); - virtual ~base(void); - - //interface - virtual void rx_get(const wax::obj &key, wax::obj &val) = 0; - virtual void rx_set(const wax::obj &key, const wax::obj &val) = 0; - virtual void tx_get(const wax::obj &key, wax::obj &val) = 0; - virtual void tx_set(const wax::obj &key, const wax::obj &val) = 0; - -protected: - std::string get_subdev_name(void); - interface::sptr get_interface(void); - -private: - std::string _subdev_name; - interface::sptr _dboard_interface; -}; - -/*! - * A xcvr daughter board implements rx and tx methods - * Sub classes for xcvr boards should inherit this. - */ -class xcvr_base : public base{ -public: - /*! - * Create a new xcvr dboard object, override in subclasses. - */ - xcvr_base(ctor_args_t const&); - virtual ~xcvr_base(void); -}; - -/*! - * A rx daughter board only implements rx methods. - * Sub classes for rx-only boards should inherit this. - */ -class rx_base : public base{ -public: - /*! - * Create a new rx dboard object, override in subclasses. - */ - rx_base(ctor_args_t const&); - - virtual ~rx_base(void); - - //override here so the derived classes cannot - void tx_get(const wax::obj &key, wax::obj &val); - void tx_set(const wax::obj &key, const wax::obj &val); -}; - -/*! - * A tx daughter board only implements tx methods. - * Sub classes for rx-only boards should inherit this. - */ -class tx_base : public base{ -public: - /*! - * Create a new rx dboard object, override in subclasses. - */ - tx_base(ctor_args_t const&); - - virtual ~tx_base(void); - - //override here so the derived classes cannot - void rx_get(const wax::obj &key, wax::obj &val); - void rx_set(const wax::obj &key, const wax::obj &val); -}; - -}}} //namespace - -#endif /* INCLUDED_USRP_UHD_USRP_DBOARD_BASE_HPP */ diff --git a/include/usrp_uhd/usrp/dboard/id.hpp b/include/usrp_uhd/usrp/dboard/id.hpp deleted file mode 100644 index 8369841bf..000000000 --- a/include/usrp_uhd/usrp/dboard/id.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#include - -#ifndef INCLUDED_USRP_UHD_USRP_DBOARD_ID_HPP -#define INCLUDED_USRP_UHD_USRP_DBOARD_ID_HPP - -namespace usrp_uhd{ namespace usrp{ namespace dboard{ - -enum dboard_id_t{ - ID_BASIC_TX = 0x0000, - ID_BASIC_RX = 0x0001 -}; - -}}} //namespace - -std::ostream& operator<<(std::ostream &, const usrp_uhd::usrp::dboard::dboard_id_t &); - -#endif /* INCLUDED_USRP_UHD_USRP_DBOARD_ID_HPP */ diff --git a/include/usrp_uhd/usrp/dboard/interface.hpp b/include/usrp_uhd/usrp/dboard/interface.hpp deleted file mode 100644 index 15621d0fc..000000000 --- a/include/usrp_uhd/usrp/dboard/interface.hpp +++ /dev/null @@ -1,167 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#ifndef INCLUDED_USRP_UHD_USRP_DBOARD_INTERFACE_HPP -#define INCLUDED_USRP_UHD_USRP_DBOARD_INTERFACE_HPP - -#include -#include - -namespace usrp_uhd{ namespace usrp{ namespace dboard{ - -/*! - * The daughter board interface to be subclassed. - * A dboard instance interfaces with the mboard though this api. - * This interface provides i2c, spi, gpio, atr, aux dac/adc access. - * Each mboard should have a specially tailored dboard interface. - */ -class interface{ -public: - typedef boost::shared_ptr sptr; - - //tells the host which device to use - enum spi_dev_t{ - SPI_TX_DEV, - SPI_RX_DEV - }; - - //args for writing spi data - enum spi_push_t{ - SPI_PUSH_RISE, - SPI_PUSH_FALL - }; - - //args for reading spi data - enum spi_latch_t{ - SPI_LATCH_RISE, - SPI_LATCH_FALL - }; - - //tell the host which gpio bank - enum gpio_bank_t{ - GPIO_TX_BANK, - GPIO_RX_BANK - }; - - //structors - interface(void); - virtual ~interface(void); - - /*! - * Write to an aux dac. - * \param which_dac the dac index 0, 1, 2, 3... - * \param value the value to write - */ - virtual void write_aux_dac(int which_dac, int value) = 0; - - /*! - * Read from an aux adc. - * \param which_adc the adc index 0, 1, 2, 3... - * \return the value that was read - */ - virtual int read_aux_adc(int which_adc) = 0; - - /*! - * Set daughterboard ATR register. - * The ATR register for a particular bank has 2 values: - * one value when transmitting, one when receiving. - * The mask controls which pins are controlled by ATR. - * - * \param bank GPIO_TX_BANK or GPIO_RX_BANK - * \param tx_value 16-bits, 0=FPGA input, 1=FPGA output - * \param rx_value 16-bits, 0=FPGA input, 1=FPGA output - * \param mask 16-bits, 0=ignore, 1=atr - */ - virtual void set_atr_reg(gpio_bank_t bank, uint16_t tx_value, uint16_t rx_value, uint16_t mask) = 0; - - /*! - * Set daughterboard GPIO data direction register. - * - * \param bank GPIO_TX_BANK or GPIO_RX_BANK - * \param value 16-bits, 0=FPGA input, 1=FPGA output - * \param mask 16-bits, 0=ignore, 1=set - */ - virtual void set_gpio_ddr(gpio_bank_t bank, uint16_t value, uint16_t mask) = 0; - - /*! - * Set daughterboard GPIO pin values. - * - * \param bank GPIO_TX_BANK or GPIO_RX_BANK - * \param value 16 bits, 0=low, 1=high - * \param mask 16 bits, 0=ignore, 1=set - */ - virtual void write_gpio(gpio_bank_t bank, uint16_t value, uint16_t mask) = 0; - - /*! - * Read daughterboard GPIO pin values - * - * \param bank GPIO_TX_BANK or GPIO_RX_BANK - * \return the value of the gpio bank - */ - virtual uint16_t read_gpio(gpio_bank_t bank) = 0; - - /*! - * \brief Write to I2C peripheral - * \param i2c_addr I2C bus address (7-bits) - * \param buf the data to write - */ - virtual void write_i2c(int i2c_addr, const std::string &buf) = 0; - - /*! - * \brief Read from I2C peripheral - * \param i2c_addr I2C bus address (7-bits) - * \param len number of bytes to read - * \return the data read if successful, else a zero length string. - */ - virtual std::string read_i2c(int i2c_addr, size_t len) = 0; - - /*! - * \brief Write data to SPI bus peripheral. - * - * \param dev which spi device - * \param push args for writing - * \param buf the data to write - */ - virtual void write_spi(spi_dev_t dev, spi_push_t push, const std::string &buf) = 0; - - /*! - * \brief Read data from SPI bus peripheral. - * - * \param dev which spi device - * \param push args for reading - * \param len number of bytes to read - * \return the data read if sucessful, else a zero length string. - */ - virtual std::string read_spi(spi_dev_t dev, spi_latch_t latch, size_t len) = 0; - - /*! - * \brief Get the rate of the rx dboard clock. - * \return the clock rate - */ - virtual double get_rx_clock_rate(void) = 0; - - /*! - * \brief Get the rate of the tx dboard clock. - * \return the clock rate - */ - virtual double get_tx_clock_rate(void) = 0; - -}; - -}}} //namespace - -#endif /* INCLUDED_USRP_UHD_USRP_DBOARD_INTERFACE_HPP */ diff --git a/include/usrp_uhd/usrp/dboard/manager.hpp b/include/usrp_uhd/usrp/dboard/manager.hpp deleted file mode 100644 index 8cc5658d9..000000000 --- a/include/usrp_uhd/usrp/dboard/manager.hpp +++ /dev/null @@ -1,82 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#ifndef INCLUDED_USRP_UHD_USRP_DBOARD_MANAGER_HPP -#define INCLUDED_USRP_UHD_USRP_DBOARD_MANAGER_HPP - -#include -#include -#include -#include -#include -#include -#include - -namespace usrp_uhd{ namespace usrp{ namespace dboard{ - -/*! - * A daughter board subdev manager class. - * Create subdev instances for each subdev on a dboard. - * Provide wax::obj access to the subdevs inside. - */ -class manager : boost::noncopyable{ - -public: - - //dboard constructor (each dboard should have a ::make with this signature) - typedef base::sptr(*dboard_ctor_t)(base::ctor_args_t const&); - - /*! - * Register subdevices for a given dboard id. - * - * \param dboard_id the dboard id (rx or tx) - * \param dboard_ctor the dboard constructor function pointer - * \param subdev_names the names of the subdevs on this dboard - */ - static void register_subdevs( - dboard_id_t dboard_id, - dboard_ctor_t dboard_ctor, - const prop_names_t &subdev_names - ); - -public: - typedef boost::shared_ptr sptr; - //structors - manager( - dboard_id_t rx_dboard_id, - dboard_id_t tx_dboard_id, - interface::sptr dboard_interface - ); - ~manager(void); - - //interface - prop_names_t get_rx_subdev_names(void); - prop_names_t get_tx_subdev_names(void); - wax::obj get_rx_subdev(const std::string &subdev_name); - wax::obj get_tx_subdev(const std::string &subdev_name); - -private: - //list of rx and tx dboards in this manager - //each dboard here is actually a subdevice proxy - //the subdevice proxy is internal to the cpp file - std::map _rx_dboards; - std::map _tx_dboards; -}; - -}}} //namespace - -#endif /* INCLUDED_USRP_UHD_USRP_DBOARD_MANAGER_HPP */ diff --git a/include/usrp_uhd/usrp/mboard/.gitignore b/include/usrp_uhd/usrp/mboard/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/include/usrp_uhd/usrp/mboard/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/include/usrp_uhd/usrp/mboard/Makefile.am b/include/usrp_uhd/usrp/mboard/Makefile.am deleted file mode 100644 index bcc6b832c..000000000 --- a/include/usrp_uhd/usrp/mboard/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -# -# Copyright 2010 Ettus Research LLC -# -# This program 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 of the License, or -# (at your option) any later version. -# -# This program 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 . -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = - -this_includedir = $(includedir)/usrp_uhd/usrp/mboard -this_include_HEADERS = \ - base.hpp \ - test.hpp \ - usrp2.hpp diff --git a/include/usrp_uhd/usrp/mboard/base.hpp b/include/usrp_uhd/usrp/mboard/base.hpp deleted file mode 100644 index 65810f329..000000000 --- a/include/usrp_uhd/usrp/mboard/base.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#ifndef INCLUDED_USRP_UHD_USRP_MBOARD_BASE_HPP -#define INCLUDED_USRP_UHD_USRP_MBOARD_BASE_HPP - -#include -#include -#include - -namespace usrp_uhd{ namespace usrp{ namespace mboard{ - -/*! - * A base class for usrp mboard objects. - */ -class base : boost::noncopyable, public wax::obj{ -public: - typedef boost::shared_ptr sptr; - base(void); - ~base(void); - - //TODO other api calls - -private: - virtual void get(const wax::obj &, wax::obj &) = 0; - virtual void set(const wax::obj &, const wax::obj &) = 0; -}; - -}}} //namespace - -#endif /* INCLUDED_USRP_UHD_USRP_MBOARD_BASE_HPP */ diff --git a/include/usrp_uhd/usrp/mboard/test.hpp b/include/usrp_uhd/usrp/mboard/test.hpp deleted file mode 100644 index fc1ea6e70..000000000 --- a/include/usrp_uhd/usrp/mboard/test.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#ifndef INCLUDED_USRP_UHD_USRP_MBOARD_TEST_HPP -#define INCLUDED_USRP_UHD_USRP_MBOARD_TEST_HPP - -#include -#include -#include -#include - -namespace usrp_uhd{ namespace usrp{ namespace mboard{ - -/*! - * A test usrp mboard object. - * Exercises access routines for the test suite. - */ -class test : public base{ -public: - test(const device_addr_t &); - ~test(void); - -private: - void get(const wax::obj &, wax::obj &); - void set(const wax::obj &, const wax::obj &); - - std::map _dboard_managers; -}; - -}}} //namespace - -#endif /* INCLUDED_USRP_UHD_USRP_MBOARD_TEST_HPP */ diff --git a/include/usrp_uhd/usrp/mboard/usrp2.hpp b/include/usrp_uhd/usrp/mboard/usrp2.hpp deleted file mode 100644 index a8e950d93..000000000 --- a/include/usrp_uhd/usrp/mboard/usrp2.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#ifndef INCLUDED_USRP_UHD_USRP_MBOARD_USRP2_HPP -#define INCLUDED_USRP_UHD_USRP_MBOARD_USRP2_HPP - -#include -#include -#include -#include - -namespace usrp_uhd{ namespace usrp{ namespace mboard{ - -/*! - * The usrp2 mboard class. - */ -class usrp2 : public base{ -public: - /*! - * Discover usrp2 devices over the ethernet. - * This static method will be called by the device::discover. - * \param hint a device addr with the usrp2 address filled in - * \return a vector of device addresses for all usrp2s found - */ - static std::vector discover(const device_addr_t &hint); - - usrp2(const device_addr_t &); - ~usrp2(void); - -private: - void get(const wax::obj &, wax::obj &); - void set(const wax::obj &, const wax::obj &); - - std::map _dboard_managers; -}; - -}}} //namespace - -#endif /* INCLUDED_USRP_UHD_USRP_MBOARD_USRP2_HPP */ diff --git a/include/usrp_uhd/usrp/usrp.hpp b/include/usrp_uhd/usrp/usrp.hpp deleted file mode 100644 index a8a052b52..000000000 --- a/include/usrp_uhd/usrp/usrp.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#include -#include -#include - -#ifndef INCLUDED_USRP_UHD_USRP_USRP_HPP -#define INCLUDED_USRP_UHD_USRP_USRP_HPP - -namespace usrp_uhd{ namespace usrp{ - -/*! - * A usrp device provides a device-level interface to usrp mboards. - * In most cases, a usrp device will have only one mboard. - * In the usrp2 mimo case, this device will have two mboards, - * where one talks through the other's control port. - */ -class usrp : public device{ -public: - usrp(const device_addr_t & device_addr); - ~usrp(void); - - void send_raw(const send_args_t &); - void recv_raw(const recv_args_t &); - -private: - void get(const wax::obj &, wax::obj &); - void set(const wax::obj &, const wax::obj &); - - std::map _mboards; - boost::function _send_raw_cb; - boost::function _recv_raw_cb; -}; - -}} //namespace - -#endif /* INCLUDED_USRP_UHD_USRP_USRP_HPP */ diff --git a/include/usrp_uhd/utils.hpp b/include/usrp_uhd/utils.hpp deleted file mode 100644 index a8f1c132d..000000000 --- a/include/usrp_uhd/utils.hpp +++ /dev/null @@ -1,131 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef INCLUDED_USRP_UHD_UTILS_HPP -#define INCLUDED_USRP_UHD_UTILS_HPP - -namespace usrp_uhd{ - -template //TODO template this better -std::vector get_map_keys(const std::map &m){ - std::vector v; - std::pair p; - BOOST_FOREACH(p, m){ - v.push_back(p.first); - } - return v; -} - -template T signum(T n){ - if (n < 0) return -1; - if (n > 0) return 1; - return 0; -} - -inline void tune( - freq_t target_freq, - freq_t lo_offset, - wax::obj subdev_freq_proxy, - bool subdev_quadrature, - bool subdev_spectrum_inverted, - bool subdev_is_tx, - wax::obj dsp_freq_proxy, - freq_t dsp_sample_rate -){ - // Ask the d'board to tune as closely as it can to target_freq+lo_offset - subdev_freq_proxy = target_freq + lo_offset; - freq_t inter_freq = wax::cast(subdev_freq_proxy); - - // Calculate the DDC setting that will downconvert the baseband from the - // daughterboard to our target frequency. - freq_t delta_freq = target_freq - inter_freq; - int delta_sign = signum(delta_freq); - delta_freq *= delta_sign; - delta_freq = fmod(delta_freq, dsp_sample_rate); - bool inverted = delta_freq > dsp_sample_rate/2.0; - freq_t dxc_freq = inverted? (delta_freq - dsp_sample_rate) : (-delta_freq); - dxc_freq *= delta_sign; - - // If the spectrum is inverted, and the daughterboard doesn't do - // quadrature downconversion, we can fix the inversion by flipping the - // sign of the dxc_freq... (This only happens using the basic_rx board) - if (subdev_spectrum_inverted){ - inverted = not inverted; - } - if (inverted and not subdev_quadrature){ - dxc_freq = -dxc_freq; - inverted = not inverted; - } - if (subdev_is_tx){ - dxc_freq = -dxc_freq; // down conversion versus up conversion - } - - dsp_freq_proxy = dxc_freq; - //freq_t actual_dxc_freq = wax::cast(dsp_freq_proxy); - - //return some kind of tune result tuple/struct -} - -} //namespace usrp_uhd - -/*! - * Useful templated functions and classes that I like to pretend are part of stl - */ -namespace std{ - - class assert_error : public std::logic_error{ - public: - explicit assert_error(const string& what_arg) : logic_error(what_arg){ - /* NOP */ - } - }; - - #define ASSERT_THROW(_x) if (not (_x)) { \ - throw std::assert_error("Assertion Failed: " + std::string(#_x)); \ - } - - template - T reduce(InputIterator first, InputIterator last, Function fcn, T init = 0){ - T tmp = init; - for ( ; first != last; ++first ){ - tmp = fcn(tmp, *first); - } - return tmp; - } - - template - bool has(InputIterator first, InputIterator last, const T &elem){ - return last != std::find(first, last, elem); - } - - template - T sum(const T &a, const T &b){ - return a + b; - } - -}//namespace std - -#endif /* INCLUDED_USRP_UHD_UTILS_HPP */ diff --git a/include/usrp_uhd/wax.hpp b/include/usrp_uhd/wax.hpp deleted file mode 100644 index 29a96cdb6..000000000 --- a/include/usrp_uhd/wax.hpp +++ /dev/null @@ -1,170 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#ifndef INCLUDED_WAX_HPP -#define INCLUDED_WAX_HPP - -#include -#include - -/*! - * WAX - it's a metaphor! - * - * The WAX framework allows object to have generic/anyobj properties. - * These properties can be addressed through generic/anyobj identifiers. - * A property of a WAX object may even be another WAX object. - * - * When a property is a WAX object, the returned value must be an obj pointer. - * A WAX object provides two objs of pointers: obj::ptr and obj::sptr. - * The choice of pointer vs smart pointer depends on the owner of the memory. - * - * Proprties may be referenced though the [] overloaded operator. - * The [] operator returns a special proxy that allows for assigment. - * Also, the [] operators may be chained as in the folowing examples: - * my_obj[prop1][prop2][prop3] = value - * value = my_obj[prop1][prop2][prop3] - * - * Any value returned from an access operation is of wax::obj. - * To use this value, it must be cast with wax::cast(value). - */ - -namespace wax{ - - /*! - * WAX object base class: - * - * A wax obj has two major purposes: - * 1) to act as a polymorphic container, just like boost any - * 2) to provide a nested set/get properties interface - * - * Internally, the polymorphic container is handled by a boost any. - * For properties, a subclass should override the set and get methods. - * For property nesting, wax obj subclasses return special links - * to other wax obj subclasses, and the api handles the magic. - */ - class obj{ - public: - - /*! - * Default constructor: - * The contents will be empty. - */ - obj(void); - - /*! - * Copy constructor: - * The contents will be cloned. - * \param o another wax::obj - */ - obj(const obj &o); - - /*! - * Templated any type constructor: - * The contents can be anything. - * Uses the boost::any to handle the magic. - * \param o an object of any type - */ - template obj(const T &o){ - _contents = o; - } - - /*! - * Destructor. - */ - virtual ~obj(void); - - /*! - * The chaining operator: - * This operator allows access objs with properties. - * A call to the [] operator will return a new proxy obj. - * The proxy object is an obj with special proxy contents. - * Assignment and casting can be used on this special object - * to access the property referenced by the obj key. - * \param key a key to identify a property within this obj - * \return a special wax obj that proxies the obj and key - */ - obj operator[](const obj &key); - - /*! - * The assignment operator: - * This operator allows for assignment of new contents. - * In the special case where this obj contains a proxy, - * the value will be set to the proxy's property reference. - * \param val the new value to assign to the wax obj - * \return a reference to this obj (*this) - */ - obj & operator=(const obj &val); - - /*! - * Get a link in the chain: - * When a wax obj returns another wax obj as part of a get call, - * the return value should be set to the result of this method. - * Doing so will ensure chain-ability of the returned object. - * \return an obj containing a valid link to a wax obj - */ - obj get_link(void) const; - - /*! - * Get the type of the contents of this obj. - * \return a reference to the type_info - */ - const std::type_info & type(void) const; - - private: - //private interface (override in subclasses) - virtual void get(const obj &, obj &); - virtual void set(const obj &, const obj &); - - /*! - * Resolve the contents of this obj. - * In the case where this obj is a proxy, - * the referenced property will be resolved. - * Otherwise, just get the private contents. - * \return a boost any type with contents - */ - boost::any resolve(void) const; - template friend T cast(const obj &); - - //private contents of this obj - boost::any _contents; - - }; - - /*! - * The wax::bad cast will be thrown when - * cast is called with the wrong typeid. - */ - typedef boost::bad_any_cast bad_cast; - - /*! - * Cast a wax::obj into the desired obj. - * Usage wax::cast(my_value). - * - * \param val the obj to cast - * \return an object of the desired type - * \throw wax::bad_cast when the cast fails - */ - template T cast(const obj &val){ - return boost::any_cast(val.resolve()); - } - -} //namespace wax - -//ability to use wax::obj with stream operators -std::ostream& operator<<(std::ostream &, const wax::obj &); - -#endif /* INCLUDED_WAX_HPP */ diff --git a/lib/Makefile.am b/lib/Makefile.am index 272d2c296..8ddc0e4be 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -21,17 +21,17 @@ SUBDIRS = usrp quadradio AM_CPPFLAGS = $(GENERAL_CPPFLAGS) -lib_LTLIBRARIES = libusrp_uhd.la +lib_LTLIBRARIES = libuhd.la -libusrp_uhd_la_SOURCES = \ +libuhd_la_SOURCES = \ device.cpp \ device_addr.cpp \ gain_handler.cpp \ - usrp_uhd.cpp \ + uhd.cpp \ wax.cpp -libusrp_uhd_la_LIBADD = \ +libuhd_la_LIBADD = \ $(GENERAL_LDDFLAGS) \ - $(USRP_UHD_USRP_LA) + $(UHD_USRP_LA) noinst_HEADERS = diff --git a/lib/device.cpp b/lib/device.cpp index 5718c71e7..4b51a70d4 100644 --- a/lib/device.cpp +++ b/lib/device.cpp @@ -15,13 +15,13 @@ // along with this program. If not, see . // -#include -#include -#include +#include +#include +#include #include #include -using namespace usrp_uhd; +using namespace uhd; std::vector device::discover(const device_addr_t & hint = device_addr_t()){ std::vector device_addrs; @@ -58,7 +58,7 @@ device::sptr device::make(const device_addr_t & hint, size_t which){ //create the new device with the discovered address //TODO only a usrp device will be made (until others are supported) if (true){ - return sptr(new usrp_uhd::usrp::usrp(device_addrs.at(which))); + return sptr(new uhd::usrp::usrp(device_addrs.at(which))); } throw std::runtime_error("cant make a device"); } diff --git a/lib/device_addr.cpp b/lib/device_addr.cpp index e11d51580..ee6dbbbc8 100644 --- a/lib/device_addr.cpp +++ b/lib/device_addr.cpp @@ -15,7 +15,7 @@ // along with this program. If not, see . // -#include +#include #include #include #include @@ -23,7 +23,7 @@ #include //----------------------- u2 mac addr wrapper ------------------------// -usrp_uhd::mac_addr_t::mac_addr_t(const std::string &mac_addr_str_){ +uhd::mac_addr_t::mac_addr_t(const std::string &mac_addr_str_){ std::string mac_addr_str = (mac_addr_str_ == "")? "ff:ff:ff:ff:ff:ff" : mac_addr_str_; //ether_aton_r(str.c_str(), &mac_addr); @@ -55,7 +55,7 @@ usrp_uhd::mac_addr_t::mac_addr_t(const std::string &mac_addr_str_){ memcpy(&mac_addr, p, sizeof(mac_addr)); } -std::string usrp_uhd::mac_addr_t::to_string(void) const{ +std::string uhd::mac_addr_t::to_string(void) const{ //ether_ntoa_r(&mac_addr, addr_buf); const uint8_t *p = reinterpret_cast(&mac_addr); return str( @@ -65,13 +65,13 @@ std::string usrp_uhd::mac_addr_t::to_string(void) const{ ); } -std::ostream& operator<<(std::ostream &os, const usrp_uhd::mac_addr_t &x){ +std::ostream& operator<<(std::ostream &os, const uhd::mac_addr_t &x){ os << x.to_string(); return os; } //----------------------- usrp device_addr_t wrapper -------------------------// -usrp_uhd::device_addr_t::device_addr_t(device_addr_type_t device_addr_type){ +uhd::device_addr_t::device_addr_t(device_addr_type_t device_addr_type){ type = device_addr_type; virtual_args.num_rx_dsps = 0; virtual_args.num_tx_dsps = 0; @@ -84,7 +84,7 @@ usrp_uhd::device_addr_t::device_addr_t(device_addr_type_t device_addr_type){ discovery_args.mboard_id = ~0; } -std::string usrp_uhd::device_addr_t::to_string(void) const{ +std::string uhd::device_addr_t::to_string(void) const{ std::ostringstream out; out << "USRP Type: "; switch(type){ @@ -121,7 +121,7 @@ std::string usrp_uhd::device_addr_t::to_string(void) const{ return out.str(); } -std::ostream& operator<<(std::ostream &os, const usrp_uhd::device_addr_t &x) +std::ostream& operator<<(std::ostream &os, const uhd::device_addr_t &x) { os << x.to_string(); return os; diff --git a/lib/gain_handler.cpp b/lib/gain_handler.cpp index 8713ad766..85cacd2a5 100644 --- a/lib/gain_handler.cpp +++ b/lib/gain_handler.cpp @@ -15,14 +15,14 @@ // along with this program. If not, see . // -#include -#include +#include +#include #include #include #include #include -using namespace usrp_uhd; +using namespace uhd; /*********************************************************************** * Helper functions and macros diff --git a/lib/uhd.cpp b/lib/uhd.cpp new file mode 100644 index 000000000..5e250c76f --- /dev/null +++ b/lib/uhd.cpp @@ -0,0 +1,20 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program 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 of the License, or +// (at your option) any later version. +// +// This program 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 . +// + +#include + +//nothing here, just includes the header so the compiler can check diff --git a/lib/usrp/Makefile.am b/lib/usrp/Makefile.am index bc279402c..ec4300159 100644 --- a/lib/usrp/Makefile.am +++ b/lib/usrp/Makefile.am @@ -28,5 +28,5 @@ lib_la_SOURCES = \ lib_la_LIBADD = \ $(GENERAL_LDDFLAGS) \ - $(USRP_UHD_USRP_DBOARD_LA) \ - $(USRP_UHD_USRP_MBOARD_LA) + $(UHD_USRP_DBOARD_LA) \ + $(UHD_USRP_MBOARD_LA) diff --git a/lib/usrp/dboard/base.cpp b/lib/usrp/dboard/base.cpp index 18489f3b2..de8db323a 100644 --- a/lib/usrp/dboard/base.cpp +++ b/lib/usrp/dboard/base.cpp @@ -15,10 +15,10 @@ // along with this program. If not, see . // -#include +#include #include -using namespace usrp_uhd::usrp::dboard; +using namespace uhd::usrp::dboard; /*********************************************************************** * base dboard base class diff --git a/lib/usrp/dboard/dboards.hpp b/lib/usrp/dboard/dboards.hpp index 218849eb6..0e740856f 100644 --- a/lib/usrp/dboard/dboards.hpp +++ b/lib/usrp/dboard/dboards.hpp @@ -18,9 +18,9 @@ #ifndef INCLUDED_LOCAL_DBOARDS_HPP #define INCLUDED_LOCAL_DBOARDS_HPP -#include +#include -using namespace usrp_uhd::usrp::dboard; +using namespace uhd::usrp::dboard; /*********************************************************************** * The basic boards: diff --git a/lib/usrp/dboard/id.cpp b/lib/usrp/dboard/id.cpp index 6f545d4e4..b55028a11 100644 --- a/lib/usrp/dboard/id.cpp +++ b/lib/usrp/dboard/id.cpp @@ -15,12 +15,12 @@ // along with this program. If not, see . // -#include +#include #include #include #include -using namespace usrp_uhd::usrp::dboard; +using namespace uhd::usrp::dboard; std::ostream& operator<<(std::ostream &os, const dboard_id_t &id){ //map the dboard ids to string representations diff --git a/lib/usrp/dboard/interface.cpp b/lib/usrp/dboard/interface.cpp index dff90ffa4..837c76d0a 100644 --- a/lib/usrp/dboard/interface.cpp +++ b/lib/usrp/dboard/interface.cpp @@ -15,9 +15,9 @@ // along with this program. If not, see . // -#include +#include -using namespace usrp_uhd::usrp::dboard; +using namespace uhd::usrp::dboard; interface::interface(void){ /* NOP */ diff --git a/lib/usrp/dboard/manager.cpp b/lib/usrp/dboard/manager.cpp index 759cb20b8..5005301ba 100644 --- a/lib/usrp/dboard/manager.cpp +++ b/lib/usrp/dboard/manager.cpp @@ -15,15 +15,15 @@ // along with this program. If not, see . // -#include -#include +#include +#include #include #include #include #include "dboards.hpp" -using namespace usrp_uhd; -using namespace usrp_uhd::usrp::dboard; +using namespace uhd; +using namespace uhd::usrp::dboard; using namespace boost::assign; /*********************************************************************** diff --git a/lib/usrp/mboard/base.cpp b/lib/usrp/mboard/base.cpp index 3baf4c0a4..f4f0324f3 100644 --- a/lib/usrp/mboard/base.cpp +++ b/lib/usrp/mboard/base.cpp @@ -15,10 +15,10 @@ // along with this program. If not, see . // -#include +#include #include -using namespace usrp_uhd::usrp::mboard; +using namespace uhd::usrp::mboard; base::base(void){ /* NOP */ diff --git a/lib/usrp/mboard/test.cpp b/lib/usrp/mboard/test.cpp index b54d66408..9ad11c046 100644 --- a/lib/usrp/mboard/test.cpp +++ b/lib/usrp/mboard/test.cpp @@ -15,21 +15,21 @@ // along with this program. If not, see . // -#include -#include -#include +#include +#include +#include #include #include #include -using namespace usrp_uhd; -using namespace usrp_uhd::usrp; -using namespace usrp_uhd::usrp::mboard; +using namespace uhd; +using namespace uhd::usrp; +using namespace uhd::usrp::mboard; /*********************************************************************** * dummy interface for dboards **********************************************************************/ -class dummy_interface : public usrp_uhd::usrp::dboard::interface{ +class dummy_interface : public uhd::usrp::dboard::interface{ public: dummy_interface(void){} ~dummy_interface(void){} diff --git a/lib/usrp/mboard/usrp2.cpp b/lib/usrp/mboard/usrp2.cpp index 7064f1460..ffbfe69fc 100644 --- a/lib/usrp/mboard/usrp2.cpp +++ b/lib/usrp/mboard/usrp2.cpp @@ -15,9 +15,9 @@ // along with this program. If not, see . // -#include +#include #include "usrp2_fw_common.h" -#include +#include #include #include #include @@ -25,8 +25,8 @@ #include #include -using namespace usrp_uhd; -using namespace usrp_uhd::usrp::mboard; +using namespace uhd; +using namespace uhd::usrp::mboard; using boost::asio::ip::udp; /*********************************************************************** diff --git a/lib/usrp/usrp.cpp b/lib/usrp/usrp.cpp index e3016be5f..59dd49dd1 100644 --- a/lib/usrp/usrp.cpp +++ b/lib/usrp/usrp.cpp @@ -15,24 +15,24 @@ // along with this program. If not, see . // -#include -#include -#include +#include +#include +#include #include #include #include -using namespace usrp_uhd::usrp; +using namespace uhd::usrp; /*********************************************************************** * default callbacks for the send and recv * these should be replaced with callbacks from the mboard object **********************************************************************/ -static void send_raw_default(const usrp_uhd::device::send_args_t &){ +static void send_raw_default(const uhd::device::send_args_t &){ throw std::runtime_error("No callback registered for send raw"); } -static void recv_raw_default(const usrp_uhd::device::recv_args_t &){ +static void recv_raw_default(const uhd::device::recv_args_t &){ throw std::runtime_error("No callback registered for recv raw"); } diff --git a/lib/usrp_uhd.cpp b/lib/usrp_uhd.cpp deleted file mode 100644 index 7a9748954..000000000 --- a/lib/usrp_uhd.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program 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 . -// - -#include - -//nothing here, just includes the header so the compiler can check diff --git a/lib/wax.cpp b/lib/wax.cpp index ce9705b1e..24f89288c 100644 --- a/lib/wax.cpp +++ b/lib/wax.cpp @@ -15,7 +15,7 @@ // along with this program. If not, see . // -#include +#include #include #include diff --git a/test/Makefile.am b/test/Makefile.am index 83214efec..a010c15cb 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -26,7 +26,7 @@ AM_CPPFLAGS = $(GENERAL_CPPFLAGS) LDADD = \ $(GENERAL_LDDFLAGS) \ $(BOOST_UNIT_TEST_FRAMEWORK_LIB) \ - $(USRP_UHD_LA) + $(UHD_LA) noinst_PROGRAMS = main_test diff --git a/test/addr_test.cpp b/test/addr_test.cpp index c5823cc65..148aee015 100644 --- a/test/addr_test.cpp +++ b/test/addr_test.cpp @@ -16,12 +16,12 @@ // #include -#include +#include BOOST_AUTO_TEST_CASE(test_mac_addr){ std::cout << "Testing mac addr..." << std::endl; const std::string mac_addr_str("00:01:23:45:67:89"); - usrp_uhd::mac_addr_t mac_addr(mac_addr_str); + uhd::mac_addr_t mac_addr(mac_addr_str); std::cout << "Input: " << mac_addr_str << std::endl; std::cout << "Output: " << mac_addr << std::endl; BOOST_CHECK_EQUAL(mac_addr_str, mac_addr.to_string()); diff --git a/test/device_test.cpp b/test/device_test.cpp index 328ea9c0c..a868cf9f6 100644 --- a/test/device_test.cpp +++ b/test/device_test.cpp @@ -16,9 +16,9 @@ // #include -#include +#include -using namespace usrp_uhd; +using namespace uhd; BOOST_AUTO_TEST_CASE(test_device){ device_addr_t device_addr(DEVICE_ADDR_TYPE_VIRTUAL); diff --git a/test/gain_handler_test.cpp b/test/gain_handler_test.cpp index 074a67ec8..30e88c445 100644 --- a/test/gain_handler_test.cpp +++ b/test/gain_handler_test.cpp @@ -16,11 +16,11 @@ // #include -#include -#include +#include +#include #include -using namespace usrp_uhd; +using namespace uhd; enum prop_t{ PROP_GAIN, diff --git a/test/usrp_dboard_test.cpp b/test/usrp_dboard_test.cpp index 5bd086dc1..a66dfd190 100644 --- a/test/usrp_dboard_test.cpp +++ b/test/usrp_dboard_test.cpp @@ -16,9 +16,9 @@ // #include -#include +#include -using namespace usrp_uhd::usrp::dboard; +using namespace uhd::usrp::dboard; /*********************************************************************** * dummy interface for dboards diff --git a/test/wax_test.cpp b/test/wax_test.cpp index de66a9f64..f51860c13 100644 --- a/test/wax_test.cpp +++ b/test/wax_test.cpp @@ -16,7 +16,7 @@ // #include -#include +#include enum opt_a_t{OPTION_A_0, OPTION_A_1}; enum opt_b_t{OPTION_B_0, OPTION_B_1}; diff --git a/uhd.pc.in b/uhd.pc.in new file mode 100644 index 000000000..58516c025 --- /dev/null +++ b/uhd.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: uhd +Description: Universal Software Radio Peripheral - Unified Hardware Driver +Requires: +Version: @VERSION@ +Libs: -L${libdir} -luhd +Cflags: -I${includedir} diff --git a/usrp_uhd.pc.in b/usrp_uhd.pc.in deleted file mode 100644 index 18194a741..000000000 --- a/usrp_uhd.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: usrp_uhd -Description: Universal Software Radio Peripheral - Unified Hardware Driver -Requires: -Version: @VERSION@ -Libs: -L${libdir} -lusrp_uhd -Cflags: -I${includedir} -- cgit v1.2.3