diff options
| author | Josh Blum <josh@joshknows.com> | 2010-02-09 16:28:16 -0800 | 
|---|---|---|
| committer | Josh Blum <josh@joshknows.com> | 2010-02-09 16:28:16 -0800 | 
| commit | c5480830c6e8e8e862523b3ebf3117fda8a100df (patch) | |
| tree | 65aac999502e58efe5cdfad71bef7ddc3d201444 /include/usrp_uhd | |
| parent | dfd7f99eecefc19effd97034048641de9d6b7e94 (diff) | |
| download | uhd-c5480830c6e8e8e862523b3ebf3117fda8a100df.tar.gz uhd-c5480830c6e8e8e862523b3ebf3117fda8a100df.tar.bz2 uhd-c5480830c6e8e8e862523b3ebf3117fda8a100df.zip | |
renamed usrp_uhd to uhd
Diffstat (limited to 'include/usrp_uhd')
25 files changed, 0 insertions, 1538 deletions
| 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 <http://www.gnu.org/licenses/>. -# - -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 <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_USRP_UHD_DEVICE_HPP -#define INCLUDED_USRP_UHD_DEVICE_HPP - -#include <usrp_uhd/device_addr.hpp> -#include <usrp_uhd/props.hpp> -#include <usrp_uhd/wax.hpp> -#include <boost/utility.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/function.hpp> -#include <boost/asio/buffer.hpp> -#include <vector> - -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<device> 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<boost::asio::const_buffer>                   send_args_t; -    typedef boost::function<bool(const boost::asio::const_buffer &)> 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<device_addr_t> 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 <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_USRP_UHD_DEVICE_ADDR_HPP -#define INCLUDED_USRP_UHD_DEVICE_ADDR_HPP - -#include <string> -#include <iostream> -#include <netinet/ether.h> -#include <stdint.h> - -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 <http://www.gnu.org/licenses/>. -// - -#include <boost/shared_ptr.hpp> -#include <usrp_uhd/wax.hpp> -#include <usrp_uhd/props.hpp> -#include <boost/function.hpp> -#include <boost/bind.hpp> - -#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<gain_handler> sptr; - -    template <class T> 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<T>, _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 <class T> static bool is_equal(const wax::obj &a, const wax::obj &b){ -        try{ -            return wax::cast<T>(a) == wax::cast<T>(b); -        } -        catch(const wax::bad_cast &){ -            return false; -        } -    } -    boost::function<bool(const wax::obj &, const wax::obj &)> _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 <http://www.gnu.org/licenses/>. -// - -#include <boost/tuple/tuple.hpp> -#include <usrp_uhd/time_spec.hpp> -#include <usrp_uhd/wax.hpp> -#include <complex> -#include <vector> - -#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<real_scalar_t> complex_scalar_t; - -    //vector types -    typedef std::vector<int_scalar_t> int_vec_t; -    typedef std::vector<real_scalar_t> real_vec_t; -    typedef std::vector<complex_scalar_t> complex_vec_t; - -    //typedef for handling named properties -    typedef std::vector<std::string> prop_names_t; -    typedef boost::tuple<wax::obj, std::string> 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<named_prop_t>(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 <http://www.gnu.org/licenses/>. -# - -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 <http://www.gnu.org/licenses/>. -// - -#include <stdint.h> - -#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 <http://www.gnu.org/licenses/>. -# - -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 <http://www.gnu.org/licenses/>. -# - -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 <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_USRP_UHD_USRP_DBOARD_BASE_HPP -#define INCLUDED_USRP_UHD_USRP_DBOARD_BASE_HPP - -#include <usrp_uhd/wax.hpp> -#include <boost/utility.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/tuple/tuple.hpp> -#include <usrp_uhd/usrp/dboard/interface.hpp> - -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<base> 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<std::string, interface::sptr> 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 <http://www.gnu.org/licenses/>. -// - -#include <iostream> - -#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 <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_USRP_UHD_USRP_DBOARD_INTERFACE_HPP -#define INCLUDED_USRP_UHD_USRP_DBOARD_INTERFACE_HPP - -#include <boost/shared_ptr.hpp> -#include <stdint.h> - -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<interface> 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 <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_USRP_UHD_USRP_DBOARD_MANAGER_HPP -#define INCLUDED_USRP_UHD_USRP_DBOARD_MANAGER_HPP - -#include <map> -#include <usrp_uhd/wax.hpp> -#include <usrp_uhd/props.hpp> -#include <boost/utility.hpp> -#include <boost/shared_ptr.hpp> -#include <usrp_uhd/usrp/dboard/base.hpp> -#include <usrp_uhd/usrp/dboard/id.hpp> - -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<manager> 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<std::string, wax::obj> _rx_dboards; -    std::map<std::string, wax::obj> _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 <http://www.gnu.org/licenses/>. -# - -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 <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_USRP_UHD_USRP_MBOARD_BASE_HPP -#define INCLUDED_USRP_UHD_USRP_MBOARD_BASE_HPP - -#include <usrp_uhd/wax.hpp> -#include <boost/utility.hpp> -#include <boost/shared_ptr.hpp> - -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<base> 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 <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_USRP_UHD_USRP_MBOARD_TEST_HPP -#define INCLUDED_USRP_UHD_USRP_MBOARD_TEST_HPP - -#include <usrp_uhd/usrp/mboard/base.hpp> -#include <usrp_uhd/device_addr.hpp> -#include <usrp_uhd/usrp/dboard/manager.hpp> -#include <map> - -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<std::string, dboard::manager::sptr> _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 <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_USRP_UHD_USRP_MBOARD_USRP2_HPP -#define INCLUDED_USRP_UHD_USRP_MBOARD_USRP2_HPP - -#include <usrp_uhd/usrp/mboard/base.hpp> -#include <usrp_uhd/device_addr.hpp> -#include <usrp_uhd/usrp/dboard/manager.hpp> -#include <map> - -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<device_addr_t> 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<std::string, dboard::manager::sptr> _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 <http://www.gnu.org/licenses/>. -// - -#include <usrp_uhd/device.hpp> -#include <usrp_uhd/usrp/mboard/base.hpp> -#include <map> - -#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<std::string, mboard::base::sptr> _mboards; -    boost::function<void(const device::send_args_t &)> _send_raw_cb; -    boost::function<void(const device::recv_args_t &)> _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 <http://www.gnu.org/licenses/>. -// - -#include <usrp_uhd/wax.hpp> -#include <boost/foreach.hpp> -#include <boost/format.hpp> -#include <boost/function.hpp> -#include <stdexcept> -#include <algorithm> -#include <vector> -#include <map> - -#ifndef INCLUDED_USRP_UHD_UTILS_HPP -#define INCLUDED_USRP_UHD_UTILS_HPP - -namespace usrp_uhd{ - -template <class Key, class T> //TODO template this better -std::vector<Key> get_map_keys(const std::map<Key, T> &m){ -    std::vector<Key> v; -    std::pair<Key, T> p; -    BOOST_FOREACH(p, m){ -        v.push_back(p.first); -    } -    return v; -} - -template<typename T> 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<freq_t>(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<freq_t>(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<class T, class InputIterator, class Function> -    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<class T, class InputIterator> -    bool has(InputIterator first, InputIterator last, const T &elem){ -        return last != std::find(first, last, elem); -    } - -    template<class T> -    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 <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_WAX_HPP -#define INCLUDED_WAX_HPP - -#include <boost/any.hpp> -#include <iostream> - -/*! - * 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<new_obj>(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<class T> 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<class T> 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<new_obj>(my_value). -     * -     * \param val the obj to cast -     * \return an object of the desired type -     * \throw wax::bad_cast when the cast fails -     */ -    template<class T> T cast(const obj &val){ -        return boost::any_cast<T>(val.resolve()); -    } - -} //namespace wax - -//ability to use wax::obj with stream operators -std::ostream& operator<<(std::ostream &, const wax::obj &); - -#endif /* INCLUDED_WAX_HPP */ | 
