diff options
author | Philip Balister <philip@opensdr.com> | 2011-02-01 05:42:36 -0800 |
---|---|---|
committer | Philip Balister <philip@opensdr.com> | 2011-02-01 05:42:36 -0800 |
commit | 781cddee31078e461202c2cf16f3de2f1f236a27 (patch) | |
tree | dcd8e1ff8e696dc00b91b425928a3367f05c9a25 /host/include | |
parent | cd45fb6be615a6f133e2c62a46f7c5eba76f72c1 (diff) | |
parent | 52e9c8f8027d0bbe1e6b0f57e30f985613e48be2 (diff) | |
download | uhd-781cddee31078e461202c2cf16f3de2f1f236a27.tar.gz uhd-781cddee31078e461202c2cf16f3de2f1f236a27.tar.bz2 uhd-781cddee31078e461202c2cf16f3de2f1f236a27.zip |
Merge branch 'usrp_e100_devel' of ettus.sourcerepo.com:ettus/uhdpriv into usrp_e100_devel
Conflicts:
host/lib/usrp/usrp_e100/clock_ctrl.cpp
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/transport/bounded_buffer.ipp | 13 | ||||
-rw-r--r-- | host/include/uhd/types/io_type.hpp | 6 | ||||
-rw-r--r-- | host/include/uhd/usrp/dboard_iface.hpp | 43 | ||||
-rw-r--r-- | host/include/uhd/usrp/mboard_props.hpp | 1 | ||||
-rw-r--r-- | host/include/uhd/usrp/multi_usrp.hpp | 143 | ||||
-rw-r--r-- | host/include/uhd/usrp/single_usrp.hpp | 435 |
6 files changed, 134 insertions, 507 deletions
diff --git a/host/include/uhd/transport/bounded_buffer.ipp b/host/include/uhd/transport/bounded_buffer.ipp index f7915d866..4fbe3f085 100644 --- a/host/include/uhd/transport/bounded_buffer.ipp +++ b/host/include/uhd/transport/bounded_buffer.ipp @@ -22,6 +22,7 @@ #include <boost/function.hpp> #include <boost/circular_buffer.hpp> #include <boost/thread/condition.hpp> +#include <boost/thread/locks.hpp> #include <boost/date_time/posix_time/posix_time_types.hpp> namespace uhd{ namespace transport{ namespace{ /*anon*/ @@ -36,7 +37,7 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/ } UHD_INLINE bool push_with_pop_on_full(const elem_type &elem){ - boost::unique_lock<boost::mutex> lock(_mutex); + boost::mutex::scoped_lock lock(_mutex); if(_buffer.full()){ _buffer.pop_back(); _buffer.push_front(elem); @@ -53,7 +54,7 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/ } UHD_INLINE void push_with_wait(const elem_type &elem){ - boost::unique_lock<boost::mutex> lock(_mutex); + boost::mutex::scoped_lock lock(_mutex); _full_cond.wait(lock, _not_full_fcn); _buffer.push_front(elem); lock.unlock(); @@ -61,7 +62,7 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/ } UHD_INLINE bool push_with_timed_wait(const elem_type &elem, double timeout){ - boost::unique_lock<boost::mutex> lock(_mutex); + boost::mutex::scoped_lock lock(_mutex); if (not _full_cond.timed_wait( lock, to_time_dur(timeout), _not_full_fcn )) return false; @@ -72,7 +73,7 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/ } UHD_INLINE void pop_with_wait(elem_type &elem){ - boost::unique_lock<boost::mutex> lock(_mutex); + boost::mutex::scoped_lock lock(_mutex); _empty_cond.wait(lock, _not_empty_fcn); elem = this->pop_back(); lock.unlock(); @@ -80,7 +81,7 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/ } UHD_INLINE bool pop_with_timed_wait(elem_type &elem, double timeout){ - boost::unique_lock<boost::mutex> lock(_mutex); + boost::mutex::scoped_lock lock(_mutex); if (not _empty_cond.timed_wait( lock, to_time_dur(timeout), _not_empty_fcn )) return false; @@ -91,7 +92,7 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/ } UHD_INLINE void clear(void){ - boost::unique_lock<boost::mutex> lock(_mutex); + boost::mutex::scoped_lock lock(_mutex); while (not_empty()) this->pop_back(); lock.unlock(); _full_cond.notify_one(); diff --git a/host/include/uhd/types/io_type.hpp b/host/include/uhd/types/io_type.hpp index 5176374d6..ec1b9c056 100644 --- a/host/include/uhd/types/io_type.hpp +++ b/host/include/uhd/types/io_type.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 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 @@ -33,9 +33,13 @@ namespace uhd{ * Built in IO types known to the system. */ enum tid_t{ + //! Custom type (technically unsupported by implementation) CUSTOM_TYPE = '?', + //! Complex floating point (32-bit floats) range [-1.0, +1.0] COMPLEX_FLOAT32 = 'f', + //! Complex signed integer (16-bit integers) range [-32768, +32767] COMPLEX_INT16 = 's', + //! Complex signed integer (8-bit integers) range [-128, 127] COMPLEX_INT8 = 'b' }; diff --git a/host/include/uhd/usrp/dboard_iface.hpp b/host/include/uhd/usrp/dboard_iface.hpp index cfb727017..c5898365d 100644 --- a/host/include/uhd/usrp/dboard_iface.hpp +++ b/host/include/uhd/usrp/dboard_iface.hpp @@ -28,6 +28,27 @@ namespace uhd{ namespace usrp{ +//! Special properties that differentiate this daughterboard slot +struct UHD_API dboard_iface_special_props_t{ + /*! + * Soft clock divider: + * When a motherboard cannot provided a divided dboard clock, + * it may provided a "soft" divided clock over an FPGA GPIO. + * The implementation must know the type of clock provided. + */ + bool soft_clock_divider; + + /*! + * Mangle i2c addresses: + * When i2c is shared across multiple daugterboard slots, + * the i2c addresses will be mangled on the secondary slot + * to avoid conflicts between slots in the i2c address space. + * The mangling is daguhterboard specific so the implementation + * needs to know whether it should use mangled addresses or not. + */ + bool mangle_i2c_addrs; +}; + /*! * The daughter board dboard interface to be subclassed. * A dboard instance interfaces with the mboard though this api. @@ -37,6 +58,7 @@ namespace uhd{ namespace usrp{ class UHD_API dboard_iface{ public: typedef boost::shared_ptr<dboard_iface> sptr; + typedef dboard_iface_special_props_t special_props_t; //! tells the host which unit to use enum unit_t{ @@ -66,27 +88,6 @@ public: AUX_ADC_B = 'b' }; - //! Special properties that differentiate this daughterboard slot - struct special_props_t{ - /*! - * Soft clock divider: - * When a motherboard cannot provided a divided dboard clock, - * it may provided a "soft" divided clock over an FPGA GPIO. - * The implementation must know the type of clock provided. - */ - bool soft_clock_divider; - - /*! - * Mangle i2c addresses: - * When i2c is shared across multiple daugterboard slots, - * the i2c addresses will be mangled on the secondary slot - * to avoid conflicts between slots in the i2c address space. - * The mangling is daguhterboard specific so the implementation - * needs to know whether it should use mangled addresses or not. - */ - bool mangle_i2c_addrs; - }; - /*! * Get special properties information for this dboard slot. * This call helps the dboard code to handle implementation diff --git a/host/include/uhd/usrp/mboard_props.hpp b/host/include/uhd/usrp/mboard_props.hpp index c82bfc21a..d04ad012c 100644 --- a/host/include/uhd/usrp/mboard_props.hpp +++ b/host/include/uhd/usrp/mboard_props.hpp @@ -31,6 +31,7 @@ namespace uhd{ namespace usrp{ enum mboard_prop_t{ MBOARD_PROP_NAME = 'n', //ro, std::string MBOARD_PROP_OTHERS = 'o', //ro, prop_names_t + MBOARD_PROP_CLOCK_RATE = 'c', //rw, double MBOARD_PROP_RX_DSP = 'd', //ro, wax::obj MBOARD_PROP_RX_DSP_NAMES = 'D', //ro, prop_names_t MBOARD_PROP_TX_DSP = 'u', //ro, wax::obj diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index b603d4324..c77b5d6d2 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -34,19 +34,30 @@ namespace uhd{ namespace usrp{ /*! - * The multi-USRP device class: - * A multi-USRP facilitates ease-of-use for multiple USRP scenarios. - * The wrapper provides convenience functions to control the group - * of underlying devices as if they consisted of a single device. + * The Multi-USRP device class: * - * A few notes about a multi-USRP configuration: + * This class facilitates ease-of-use for most use-case scenarios. + * The wrapper provides convenience functions to tune the devices, + * set the dboard gains, antennas, filters, and other properties. + * This class can be used to interface with a single USRP with + * one or more channels, or multiple USRPs in a homogeneous setup. + * All members take an optional parameter for board number or channel number. + * In the single device, single channel case, these parameters can be unspecified. + * + * When using a single device with multiple channels: + * - Channel mapping is determined by the subdevice specifications + * - All channels share a common RX sample rate + * - All channels share a common TX sample rate + * + * When using multiple devices in a configuration: + * - Channel mapping is determined by the device address arguments * - All boards share a common RX sample rate * - All boards share a common TX sample rate * - All boards share a common RX subdevice specification size * - All boards share a common TX subdevice specification size * - All boards must have synchronized times (see the set_time_*() calls) * - * Example to setup channel mapping: + * Example to setup channel mapping for multiple devices: * <pre> * * //create a multi_usrp with two boards in the configuration @@ -95,6 +106,26 @@ public: /******************************************************************* * Mboard methods ******************************************************************/ + + /*! + * Set the master clock rate. + * This controls the rate of the clock that feeds the FPGA DSP. + * On some devices, this re-tunes the clock to the specified rate. + * If the specified rate is not available, this method will throw. + * On other devices, this method notifies the software of the rate, + * but requires the the user has made the necessary hardware change. + * \param rate the new master clock rate in Hz + * \param mboard the motherboard index 0 to M-1 + */ + virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0; + + /*! + * Get the master clock rate. + * \param mboard the motherboard index 0 to M-1 + * \return the master clock rate in Hz. + */ + virtual double get_master_clock_rate(size_t mboard = 0) = 0; + /*! * Get a printable summary for this USRP configuration. * \return a printable string @@ -106,7 +137,7 @@ public: * \param mboard which motherboard to query * \return a string representing the name */ - virtual std::string get_mboard_name(size_t mboard) = 0; + virtual std::string get_mboard_name(size_t mboard = 0) = 0; /*! * Get the current time in the usrp time registers. @@ -121,6 +152,19 @@ public: virtual time_spec_t get_time_last_pps(void) = 0; /*! + * Sets the time registers on the usrp immediately. + * + * If only one MIMO master is present in your configuration, set_time_now is + * safe to use because the slave's time automatically follows the master's time. + * Otherwise, this call cannot set the time synchronously across multiple devices. + * Please use the set_time_next_pps or set_time_unknown_pps calls with a PPS signal. + * + * \param time_spec the time to latch into the usrp device + * \param mboard the motherboard index 0 to M-1 + */ + virtual void set_time_now(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0; + + /*! * Set the time registers on the usrp at the next pps tick. * The values will not be latched in until the pulse occurs. * It is recommended that the user sleep(1) after calling to ensure @@ -162,6 +206,11 @@ public: * Issue a stream command to the usrp device. * This tells the usrp to send samples into the host. * See the documentation for stream_cmd_t for more info. + * + * With multiple devices, the first stream command in a chain of commands + * should have a time spec in the near future and stream_now = false; + * to ensure that the packets can be aligned by their time specs. + * * \param stream_cmd the stream command to issue */ virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd) = 0; @@ -173,7 +222,7 @@ public: * \param clock_config the clock configuration to set * \param mboard which motherboard to set the config */ - virtual void set_clock_config(const clock_config_t &clock_config, size_t mboard) = 0; + virtual void set_clock_config(const clock_config_t &clock_config, size_t mboard = ALL_MBOARDS) = 0; /*! * Get the number of USRP motherboards in this configuration. @@ -191,14 +240,14 @@ public: * \param spec the new subdevice specification * \param mboard the motherboard index 0 to M-1 */ - virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard) = 0; + virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0; /*! * Get the RX subdevice specification. * \param mboard the motherboard index 0 to M-1 * \return the subdevice specification in use */ - virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard) = 0; + virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0; /*! * Get the number of RX channels in this configuration. @@ -212,7 +261,7 @@ public: * \param chan the channel index 0 to N-1 * \return the subdevice name */ - virtual std::string get_rx_subdev_name(size_t chan) = 0; + virtual std::string get_rx_subdev_name(size_t chan = 0) = 0; /*! * Set the RX sample rate across all channels. @@ -241,14 +290,14 @@ public: * \param chan the channel index 0 to N-1 * \return the frequency in Hz */ - virtual double get_rx_freq(size_t chan) = 0; + virtual double get_rx_freq(size_t chan = 0) = 0; /*! * Get the RX center frequency range. * \param chan the channel index 0 to N-1 * \return a frequency range object */ - virtual freq_range_t get_rx_freq_range(size_t chan) = 0; + virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0; /*! * Set the RX gain value for the specified gain element. @@ -257,10 +306,10 @@ public: * \param name the name of the gain element * \param chan the channel index 0 to N-1 */ - virtual void set_rx_gain(double gain, const std::string &name, size_t chan) = 0; + virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0; //! A convenience wrapper for setting overall RX gain - void set_rx_gain(double gain, size_t chan){ + void set_rx_gain(double gain, size_t chan = 0){ return this->set_rx_gain(gain, ALL_GAINS, chan); } @@ -271,10 +320,10 @@ public: * \param chan the channel index 0 to N-1 * \return the gain in dB */ - virtual double get_rx_gain(const std::string &name, size_t chan) = 0; + virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0; //! A convenience wrapper for getting overall RX gain - double get_rx_gain(size_t chan){ + double get_rx_gain(size_t chan = 0){ return this->get_rx_gain(ALL_GAINS, chan); } @@ -285,10 +334,10 @@ public: * \param chan the channel index 0 to N-1 * \return a gain range object */ - virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan) = 0; + virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan = 0) = 0; //! A convenience wrapper for getting overall RX gain range - gain_range_t get_rx_gain_range(size_t chan){ + gain_range_t get_rx_gain_range(size_t chan = 0){ return this->get_rx_gain_range(ALL_GAINS, chan); } @@ -298,49 +347,49 @@ public: * \param chan the channel index 0 to N-1 * \return a vector of gain element names */ - virtual std::vector<std::string> get_rx_gain_names(size_t chan) = 0; + virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0; /*! * Select the RX antenna on the subdevice. * \param ant the antenna name * \param chan the channel index 0 to N-1 */ - virtual void set_rx_antenna(const std::string &ant, size_t chan) = 0; + virtual void set_rx_antenna(const std::string &ant, size_t chan = 0) = 0; /*! * Get the selected RX antenna on the subdevice. * \param chan the channel index 0 to N-1 * \return the antenna name */ - virtual std::string get_rx_antenna(size_t chan) = 0; + virtual std::string get_rx_antenna(size_t chan = 0) = 0; /*! * Get a list of possible RX antennas on the subdevice. * \param chan the channel index 0 to N-1 * \return a vector of antenna names */ - virtual std::vector<std::string> get_rx_antennas(size_t chan) = 0; + virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0; /*! * Get the locked status of the LO on the subdevice. * \param chan the channel index 0 to N-1 * \return true for locked */ - virtual bool get_rx_lo_locked(size_t chan) = 0; + virtual bool get_rx_lo_locked(size_t chan = 0) = 0; /*! * Set the RX bandwidth on the subdevice. * \param bandwidth the bandwidth in Hz * \param chan the channel index 0 to N-1 */ - virtual void set_rx_bandwidth(double bandwidth, size_t chan) = 0; + virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0; /*! * Get the RX bandwidth on the subdevice. * \param chan the channel index 0 to N-1 * \return the bandwidth in Hz */ - virtual double get_rx_bandwidth(size_t chan) = 0; + virtual double get_rx_bandwidth(size_t chan = 0) = 0; /*! * Read the RSSI value on the RX subdevice. @@ -348,7 +397,7 @@ public: * \return the rssi in dB * \throw exception if RSSI readback not supported */ - virtual double read_rssi(size_t chan) = 0; + virtual double read_rssi(size_t chan = 0) = 0; /*! * Get the dboard interface object for the RX subdevice. @@ -357,7 +406,7 @@ public: * \param chan the channel index 0 to N-1 * \return the dboard interface sptr */ - virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan) = 0; + virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0; /******************************************************************* * TX methods @@ -370,14 +419,14 @@ public: * \param spec the new subdevice specification * \param mboard the motherboard index 0 to M-1 */ - virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard) = 0; + virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0; /*! * Get the TX subdevice specification. * \param mboard the motherboard index 0 to M-1 * \return the subdevice specification in use */ - virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard) = 0; + virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0; /*! * Get the number of TX channels in this configuration. @@ -391,7 +440,7 @@ public: * \param chan the channel index 0 to N-1 * \return the subdevice name */ - virtual std::string get_tx_subdev_name(size_t chan) = 0; + virtual std::string get_tx_subdev_name(size_t chan = 0) = 0; /*! * Set the TX sample rate across all channels. @@ -420,14 +469,14 @@ public: * \param chan the channel index 0 to N-1 * \return the frequency in Hz */ - virtual double get_tx_freq(size_t chan) = 0; + virtual double get_tx_freq(size_t chan = 0) = 0; /*! * Get the TX center frequency range. * \param chan the channel index 0 to N-1 * \return a frequency range object */ - virtual freq_range_t get_tx_freq_range(size_t chan) = 0; + virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0; /*! * Set the TX gain value for the specified gain element. @@ -436,10 +485,10 @@ public: * \param name the name of the gain element * \param chan the channel index 0 to N-1 */ - virtual void set_tx_gain(double gain, const std::string &name, size_t chan) = 0; + virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0; //! A convenience wrapper for setting overall TX gain - void set_tx_gain(double gain, size_t chan){ + void set_tx_gain(double gain, size_t chan = 0){ return this->set_tx_gain(gain, ALL_GAINS, chan); } @@ -450,10 +499,10 @@ public: * \param chan the channel index 0 to N-1 * \return the gain in dB */ - virtual double get_tx_gain(const std::string &name, size_t chan) = 0; + virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0; //! A convenience wrapper for getting overall TX gain - double get_tx_gain(size_t chan){ + double get_tx_gain(size_t chan = 0){ return this->get_tx_gain(ALL_GAINS, chan); } @@ -464,10 +513,10 @@ public: * \param chan the channel index 0 to N-1 * \return a gain range object */ - virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan) = 0; + virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan = 0) = 0; //! A convenience wrapper for getting overall TX gain range - gain_range_t get_tx_gain_range(size_t chan){ + gain_range_t get_tx_gain_range(size_t chan = 0){ return this->get_tx_gain_range(ALL_GAINS, chan); } @@ -477,49 +526,49 @@ public: * \param chan the channel index 0 to N-1 * \return a vector of gain element names */ - virtual std::vector<std::string> get_tx_gain_names(size_t chan) = 0; + virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0; /*! * Select the TX antenna on the subdevice. * \param ant the antenna name * \param chan the channel index 0 to N-1 */ - virtual void set_tx_antenna(const std::string &ant, size_t chan) = 0; + virtual void set_tx_antenna(const std::string &ant, size_t chan = 0) = 0; /*! * Get the selected TX antenna on the subdevice. * \param chan the channel index 0 to N-1 * \return the antenna name */ - virtual std::string get_tx_antenna(size_t chan) = 0; + virtual std::string get_tx_antenna(size_t chan = 0) = 0; /*! * Get a list of possible TX antennas on the subdevice. * \param chan the channel index 0 to N-1 * \return a vector of antenna names */ - virtual std::vector<std::string> get_tx_antennas(size_t chan) = 0; + virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0; /*! * Get the locked status of the LO on the subdevice. * \param chan the channel index 0 to N-1 * \return true for locked */ - virtual bool get_tx_lo_locked(size_t chan) = 0; + virtual bool get_tx_lo_locked(size_t chan = 0) = 0; /*! * Set the TX bandwidth on the subdevice. * \param bandwidth the bandwidth in Hz * \param chan the channel index 0 to N-1 */ - virtual void set_tx_bandwidth(double bandwidth, size_t chan) = 0; + virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0; /*! * Get the TX bandwidth on the subdevice. * \param chan the channel index 0 to N-1 * \return the bandwidth in Hz */ - virtual double get_tx_bandwidth(size_t chan) = 0; + virtual double get_tx_bandwidth(size_t chan = 0) = 0; /*! * Get the dboard interface object for the TX subdevice. @@ -528,7 +577,7 @@ public: * \param chan the channel index 0 to N-1 * \return the dboard interface sptr */ - virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan) = 0; + virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0; }; }} diff --git a/host/include/uhd/usrp/single_usrp.hpp b/host/include/uhd/usrp/single_usrp.hpp index d80999300..0520db162 100644 --- a/host/include/uhd/usrp/single_usrp.hpp +++ b/host/include/uhd/usrp/single_usrp.hpp @@ -18,441 +18,12 @@ #ifndef INCLUDED_UHD_USRP_SINGLE_USRP_HPP #define INCLUDED_UHD_USRP_SINGLE_USRP_HPP -#include <uhd/config.hpp> -#include <uhd/device.hpp> -#include <uhd/types/ranges.hpp> -#include <uhd/types/stream_cmd.hpp> -#include <uhd/types/clock_config.hpp> -#include <uhd/types/tune_request.hpp> -#include <uhd/types/tune_result.hpp> -#include <uhd/usrp/subdev_spec.hpp> -#include <uhd/usrp/dboard_iface.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/utility.hpp> -#include <vector> +#include <uhd/usrp/multi_usrp.hpp> namespace uhd{ namespace usrp{ -/*! - * The single-USRP device class: - * A single-USRP facilitates ease-of-use for most use-case scenarios. - * The wrapper provides convenience functions to tune the devices - * as well as to set the dboard gains, antennas, and other properties. - * This wrapper supports multi-channel configurations per motherboard. - */ -class UHD_API single_usrp : boost::noncopyable{ -public: - typedef boost::shared_ptr<single_usrp> sptr; - - //! A wildcard gain element name - static const std::string ALL_GAINS; - - /*! - * Make a new single usrp from the device address. - * \param dev_addr the device address - * \return a new single usrp object - */ - static sptr make(const device_addr_t &dev_addr); - - /*! - * Get the underlying device object. - * This is needed to get access to the streaming API and properties. - * \return the device object within this single usrp - */ - virtual device::sptr get_device(void) = 0; - - /******************************************************************* - * Mboard methods - ******************************************************************/ - /*! - * Get a printable summary for this USRP configuration. - * \return a printable string - */ - virtual std::string get_pp_string(void) = 0; - - /*! - * Get canonical name for this USRP motherboard. - * \return a string representing the name - */ - virtual std::string get_mboard_name(void) = 0; - - /*! - * Get the current time in the usrp time registers. - * \return a timespec representing current usrp time - */ - virtual time_spec_t get_time_now(void) = 0; - - /*! - * Get the time when the last pps pulse occured. - * \return a timespec representing the last pps - */ - virtual time_spec_t get_time_last_pps(void) = 0; - - /*! - * Sets the time registers on the usrp immediately. - * \param time_spec the time to latch into the usrp device - */ - virtual void set_time_now(const time_spec_t &time_spec) = 0; - - /*! - * Set the time registers on the usrp at the next pps tick. - * The values will not be latched in until the pulse occurs. - * It is recommended that the user sleep(1) after calling to ensure - * that the time registers will be in a known state prior to use. - * - * Note: Because this call sets the time on the "next" pps, - * the seconds in the time spec should be current seconds + 1. - * - * \param time_spec the time to latch into the usrp device - */ - virtual void set_time_next_pps(const time_spec_t &time_spec) = 0; - - /*! - * Issue a stream command to the usrp device. - * This tells the usrp to send samples into the host. - * See the documentation for stream_cmd_t for more info. - * \param stream_cmd the stream command to issue - */ - virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd) = 0; - - /*! - * Set the clock configuration for the usrp device. - * This tells the usrp how to get a 10Mhz reference and PPS clock. - * See the documentation for clock_config_t for more info. - * \param clock_config the clock configuration to set - */ - virtual void set_clock_config(const clock_config_t &clock_config) = 0; - - /******************************************************************* - * RX methods - ******************************************************************/ - /*! - * Set the RX subdevice specification: - * The subdev spec maps a physical part of a daughter-board to a channel number. - * Set the subdev spec before calling into any methods with a channel number. - * \param spec the new subdevice specification - */ - virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec) = 0; - - /*! - * Get the RX subdevice specification. - * \return the subdevice specification in use - */ - virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(void) = 0; - - /*! - * Get the name of the RX subdevice. - * \param chan the channel index 0 to N-1 - * \return the subdevice name - */ - virtual std::string get_rx_subdev_name(size_t chan = 0) = 0; - - /*! - * Set the RX sample rate across all channels. - * \param rate the rate in Sps - */ - virtual void set_rx_rate(double rate) = 0; - - /*! - * Gets the RX sample rate for all channels. - * \return the rate in Sps - */ - virtual double get_rx_rate(void) = 0; - - /*! - * Set the RX center frequency. - * \param tune_request tune request instructions - * \param chan the channel index 0 to N-1 - * \return a tune result object - */ - virtual tune_result_t set_rx_freq( - const tune_request_t &tune_request, size_t chan = 0 - ) = 0; - - /*! - * Get the RX center frequency. - * \param chan the channel index 0 to N-1 - * \return the frequency in Hz - */ - virtual double get_rx_freq(size_t chan = 0) = 0; - - /*! - * Get the RX center frequency range. - * \param chan the channel index 0 to N-1 - * \return a frequency range object - */ - virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0; - - /*! - * Set the RX gain value for the specified gain element. - * For an empty name, distribute across all gain elements. - * \param gain the gain in dB - * \param name the name of the gain element - * \param chan the channel index 0 to N-1 - */ - virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0; - - //! A convenience wrapper for setting overall RX gain - void set_rx_gain(double gain, size_t chan = 0){ - return this->set_rx_gain(gain, ALL_GAINS, chan); - } - - /*! - * Get the RX gain value for the specified gain element. - * For an empty name, sum across all gain elements. - * \param name the name of the gain element - * \param chan the channel index 0 to N-1 - * \return the gain in dB - */ - virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0; - - //! A convenience wrapper for getting overall RX gain - double get_rx_gain(size_t chan = 0){ - return this->get_rx_gain(ALL_GAINS, chan); - } - - /*! - * Get the RX gain range for the specified gain element. - * For an empty name, calculate the overall gain range. - * \param name the name of the gain element - * \param chan the channel index 0 to N-1 - * \return a gain range object - */ - virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan = 0) = 0; - - //! A convenience wrapper for getting overall RX gain range - gain_range_t get_rx_gain_range(size_t chan = 0){ - return this->get_rx_gain_range(ALL_GAINS, chan); - } - - /*! - * Get the names of the gain elements in the RX chain. - * Gain elements are ordered from antenna to FPGA. - * \param chan the channel index 0 to N-1 - * \return a vector of gain element names - */ - virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0; - - /*! - * Select the RX antenna on the subdevice. - * \param ant the antenna name - * \param chan the channel index 0 to N-1 - */ - virtual void set_rx_antenna(const std::string &ant, size_t chan = 0) = 0; - - /*! - * Get the selected RX antenna on the subdevice. - * \param chan the channel index 0 to N-1 - * \return the antenna name - */ - virtual std::string get_rx_antenna(size_t chan = 0) = 0; - - /*! - * Get a list of possible RX antennas on the subdevice. - * \param chan the channel index 0 to N-1 - * \return a vector of antenna names - */ - virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0; - - /*! - * Get the locked status of the LO on the subdevice. - * \param chan the channel index 0 to N-1 - * \return true for locked - */ - virtual bool get_rx_lo_locked(size_t chan = 0) = 0; - - /*! - * Set the RX bandwidth on the subdevice. - * \param bandwidth the bandwidth in Hz - * \param chan the channel index 0 to N-1 - */ - virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0; - - /*! - * Get the RX bandwidth on the subdevice. - * \param chan the channel index 0 to N-1 - * \return the bandwidth in Hz - */ - virtual double get_rx_bandwidth(size_t chan = 0) = 0; - - /*! - * Read the RSSI value on the RX subdevice. - * \param chan the channel index 0 to N-1 - * \return the rssi in dB - * \throw exception if RSSI readback not supported - */ - virtual double read_rssi(size_t chan = 0) = 0; - - /*! - * Get the dboard interface object for the RX subdevice. - * The dboard interface gives access to GPIOs, SPI, I2C, low-speed ADC and DAC. - * Use at your own risk! - * \param chan the channel index 0 to N-1 - * \return the dboard interface sptr - */ - virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0; - - /******************************************************************* - * TX methods - ******************************************************************/ - /*! - * Set the TX subdevice specification: - * The subdev spec maps a physical part of a daughter-board to a channel number. - * Set the subdev spec before calling into any methods with a channel number. - * \param spec the new subdevice specification - */ - virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec) = 0; - - /*! - * Get the TX subdevice specification. - * \return the subdevice specification in use - */ - virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(void) = 0; - - /*! - * Get the name of the TX subdevice. - * \param chan the channel index 0 to N-1 - * \return the subdevice name - */ - virtual std::string get_tx_subdev_name(size_t chan = 0) = 0; - - /*! - * Set the TX sample rate across all channels. - * \param rate the rate in Sps - */ - virtual void set_tx_rate(double rate) = 0; - - /*! - * Gets the TX sample rate for all channels. - * \return the rate in Sps - */ - virtual double get_tx_rate(void) = 0; - - /*! - * Set the TX center frequency. - * \param tune_request tune request instructions - * \param chan the channel index 0 to N-1 - * \return a tune result object - */ - virtual tune_result_t set_tx_freq( - const tune_request_t &tune_request, size_t chan = 0 - ) = 0; - - /*! - * Get the TX center frequency. - * \param chan the channel index 0 to N-1 - * \return the frequency in Hz - */ - virtual double get_tx_freq(size_t chan = 0) = 0; - - /*! - * Get the TX center frequency range. - * \param chan the channel index 0 to N-1 - * \return a frequency range object - */ - virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0; - - /*! - * Set the TX gain value for the specified gain element. - * For an empty name, distribute across all gain elements. - * \param gain the gain in dB - * \param name the name of the gain element - * \param chan the channel index 0 to N-1 - */ - virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0; - - //! A convenience wrapper for setting overall TX gain - void set_tx_gain(double gain, size_t chan = 0){ - return this->set_tx_gain(gain, ALL_GAINS, chan); - } - - /*! - * Get the TX gain value for the specified gain element. - * For an empty name, sum across all gain elements. - * \param name the name of the gain element - * \param chan the channel index 0 to N-1 - * \return the gain in dB - */ - virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0; - - //! A convenience wrapper for getting overall TX gain - double get_tx_gain(size_t chan = 0){ - return this->get_tx_gain(ALL_GAINS, chan); - } - - /*! - * Get the TX gain range for the specified gain element. - * For an empty name, calculate the overall gain range. - * \param name the name of the gain element - * \param chan the channel index 0 to N-1 - * \return a gain range object - */ - virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan = 0) = 0; - - //! A convenience wrapper for getting overall TX gain range - gain_range_t get_tx_gain_range(size_t chan = 0){ - return this->get_tx_gain_range(ALL_GAINS, chan); - } - - /*! - * Get the names of the gain elements in the TX chain. - * Gain elements are ordered from antenna to FPGA. - * \param chan the channel index 0 to N-1 - * \return a vector of gain element names - */ - virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0; - - /*! - * Select the TX antenna on the subdevice. - * \param ant the antenna name - * \param chan the channel index 0 to N-1 - */ - virtual void set_tx_antenna(const std::string &ant, size_t chan = 0) = 0; - - /*! - * Get the selected TX antenna on the subdevice. - * \param chan the channel index 0 to N-1 - * \return the antenna name - */ - virtual std::string get_tx_antenna(size_t chan = 0) = 0; - - /*! - * Get a list of possible TX antennas on the subdevice. - * \param chan the channel index 0 to N-1 - * \return a vector of antenna names - */ - virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0; - - /*! - * Get the locked status of the LO on the subdevice. - * \param chan the channel index 0 to N-1 - * \return true for locked - */ - virtual bool get_tx_lo_locked(size_t chan = 0) = 0; - - /*! - * Set the TX bandwidth on the subdevice. - * \param bandwidth the bandwidth in Hz - * \param chan the channel index 0 to N-1 - */ - virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0; - - /*! - * Get the TX bandwidth on the subdevice. - * \param chan the channel index 0 to N-1 - * \return the bandwidth in Hz - */ - virtual double get_tx_bandwidth(size_t chan = 0) = 0; - - /*! - * Get the dboard interface object for the TX subdevice. - * The dboard interface gives access to GPIOs, SPI, I2C, low-speed ADC and DAC. - * Use at your own risk! - * \param chan the channel index 0 to N-1 - * \return the dboard interface sptr - */ - virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0; -}; + //! Multi-USRP is a superset of Single-USRP + typedef multi_usrp single_usrp; }} |