diff options
Diffstat (limited to 'host/include')
22 files changed, 367 insertions, 571 deletions
diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt index 74dc4a7d6..49562a7a0 100644 --- a/host/include/uhd/CMakeLists.txt +++ b/host/include/uhd/CMakeLists.txt @@ -26,6 +26,8 @@ INSTALL(FILES convert.hpp device.hpp exception.hpp + property_tree.ipp + property_tree.hpp version.hpp wax.hpp DESTINATION ${INCLUDE_DIR}/uhd diff --git a/host/include/uhd/property_tree.hpp b/host/include/uhd/property_tree.hpp new file mode 100644 index 000000000..cd8cba7e5 --- /dev/null +++ b/host/include/uhd/property_tree.hpp @@ -0,0 +1,143 @@ +// +// Copyright 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 +// 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_UHD_PROPERTY_TREE_HPP +#define INCLUDED_UHD_PROPERTY_TREE_HPP + +#include <uhd/config.hpp> +#include <boost/utility.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/function.hpp> +#include <boost/filesystem/path.hpp> +#include <vector> + +namespace uhd{ + +/*! + * A templated property interface for holding a value + * and registering callbacks when that value changes. + */ +template <typename T> class property : boost::noncopyable{ +public: + typedef boost::function<void(const T &)> subscriber_type; + typedef boost::function<T(void)> publisher_type; + typedef boost::function<T(const T &)> coercer_type; + + /*! + * Register a coercer into the property. + * A coercer is a special subscribes that coerces the value. + * Only one coercer may be registered per property. + * Registering a coercer replaces the previous coercer. + * \param coercer the coercer callback function + * \return a reference to this property for chaining + */ + virtual property<T> &coerce(const coercer_type &coercer) = 0; + + /*! + * Register a publisher into the property. + * A publisher is a special callback the provides the value. + * Publishers are useful for creating read-only properties. + * Only one publisher may be registered per property. + * Registering a publisher replaces the previous publisher. + * \param publisher the publisher callback function + * \return a reference to this property for chaining + */ + virtual property<T> &publish(const publisher_type &publisher) = 0; + + /*! + * Register a subscriber into the property. + * All subscribers are called when the value changes. + * Once a subscriber is registered, it cannot be unregistered. + * \param subscriber the subscriber callback function + * \return a reference to this property for chaining + */ + virtual property<T> &subscribe(const subscriber_type &subscriber) = 0; + + /*! + * Update calls all subscribers w/ the current value. + * \return a reference to this property for chaining + */ + virtual property<T> &update(void) = 0; + + /*! + * Set the new value and call all subscribers. + * The coercer (when provided) is called initially, + * and the coerced value is used to set the subscribers. + * \param value the new value to set on this property + * \return a reference to this property for chaining + */ + virtual property<T> &set(const T &value) = 0; + + /*! + * Get the current value of this property. + * The publisher (when provided) yields the value, + * otherwise an internal shadow is used for the value. + * \return the current value in the property + */ + virtual T get(void) const = 0; + + /*! + * A property is empty if it has never been set. + * A property with a publisher is never empty. + * \return true if the property is empty + */ + virtual bool empty(void) const = 0; +}; + +/*! + * The property tree provides a file system structure for accessing properties. + */ +class UHD_API property_tree : boost::noncopyable{ +public: + typedef boost::shared_ptr<property_tree> sptr; + typedef boost::filesystem::path path_type; + + //! Create a new + empty property tree + static sptr make(void); + + //! Get a subtree with a new root starting at path + virtual sptr subtree(const path_type &path) const = 0; + + //! Remove a property or directory (recursive) + virtual void remove(const path_type &path) = 0; + + //! True if the path exists in the tree + virtual bool exists(const path_type &path) const = 0; + + //! Get an iterable to all things in the given path + virtual std::vector<std::string> list(const path_type &path) const = 0; + + //! Create a new property entry in the tree + template <typename T> property<T> &create(const path_type &path); + + //! Get access to a property in the tree + template <typename T> property<T> &access(const path_type &path); + +private: + //! Internal create property with wild-card type + virtual void _create(const path_type &path, const boost::shared_ptr<void> &prop) = 0; + + //! Internal access property with wild-card type + virtual boost::shared_ptr<void> &_access(const path_type &path) const = 0; + +}; + +} //namespace uhd + +#include <uhd/property_tree.ipp> + +#endif /* INCLUDED_UHD_PROPERTY_TREE_HPP */ diff --git a/host/include/uhd/property_tree.ipp b/host/include/uhd/property_tree.ipp new file mode 100644 index 000000000..868cba475 --- /dev/null +++ b/host/include/uhd/property_tree.ipp @@ -0,0 +1,95 @@ +// +// Copyright 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 +// 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_UHD_PROPERTY_TREE_IPP +#define INCLUDED_UHD_PROPERTY_TREE_IPP + +#include <uhd/exception.hpp> +#include <boost/foreach.hpp> +#include <vector> + +/*********************************************************************** + * Implement templated property impl + **********************************************************************/ +namespace uhd{ namespace /*anon*/{ + +template <typename T> class property_impl : public property<T>{ +public: + + property<T> &coerce(const typename property<T>::coercer_type &coercer){ + _coercer = coercer; + return *this; + } + + property<T> &publish(const typename property<T>::publisher_type &publisher){ + _publisher = publisher; + return *this; + } + + property<T> &subscribe(const typename property<T>::subscriber_type &subscriber){ + _subscribers.push_back(subscriber); + return *this; + } + + property<T> &update(void){ + this->set(this->get()); + return *this; + } + + property<T> &set(const T &value){ + _value = boost::shared_ptr<T>(new T(_coercer.empty()? value : _coercer(value))); + BOOST_FOREACH(typename property<T>::subscriber_type &subscriber, _subscribers){ + subscriber(*_value); //let errors propagate + } + return *this; + } + + T get(void) const{ + if (empty()) throw uhd::runtime_error("Cannot get() on an empty property"); + return _publisher.empty()? *_value : _publisher(); + } + + bool empty(void) const{ + return _publisher.empty() and _value.get() == NULL; + } + +private: + std::vector<typename property<T>::subscriber_type> _subscribers; + typename property<T>::publisher_type _publisher; + typename property<T>::coercer_type _coercer; + boost::shared_ptr<T> _value; +}; + +}} //namespace uhd::/*anon*/ + +/*********************************************************************** + * Implement templated methods for the property tree + **********************************************************************/ +namespace uhd{ + + template <typename T> property<T> &property_tree::create(const path_type &path){ + this->_create(path, typename boost::shared_ptr<property<T> >(new property_impl<T>())); + return this->access<T>(path); + } + + template <typename T> property<T> &property_tree::access(const path_type &path){ + return *boost::static_pointer_cast<property<T> >(this->_access(path)); + } + +} //namespace uhd + +#endif /* INCLUDED_UHD_PROPERTY_TREE_IPP */ diff --git a/host/include/uhd/types/serial.hpp b/host/include/uhd/types/serial.hpp index 8281fd3ec..8a5ed1c32 100644 --- a/host/include/uhd/types/serial.hpp +++ b/host/include/uhd/types/serial.hpp @@ -19,6 +19,7 @@ #define INCLUDED_UHD_TYPES_SERIAL_HPP #include <uhd/config.hpp> +#include <boost/shared_ptr.hpp> #include <boost/cstdint.hpp> #include <vector> @@ -43,6 +44,8 @@ namespace uhd{ */ class UHD_API i2c_iface{ public: + typedef boost::shared_ptr<i2c_iface> sptr; + /*! * Write bytes over the i2c. * \param addr the address @@ -123,6 +126,8 @@ namespace uhd{ */ class UHD_API spi_iface{ public: + typedef boost::shared_ptr<spi_iface> sptr; + /*! * Perform a spi transaction. * \param which_slave the slave device number @@ -170,6 +175,28 @@ namespace uhd{ ); }; + /*! + * UART interface to write and read bytes. + */ + class UHD_API uart_iface{ + public: + typedef boost::shared_ptr<uart_iface> sptr; + + /*! + * Write to a serial port. + * \param dev which UART to write to + * \param buf the data to write + */ + virtual void write_uart(boost::uint8_t dev, const std::string &buf) = 0; + + /*! + * Read from a serial port. + * \param dev which UART to read from + * \return the data read from the serial port + */ + virtual std::string read_uart(boost::uint8_t dev) = 0; + }; + } //namespace uhd #endif /* INCLUDED_UHD_TYPES_SERIAL_HPP */ diff --git a/host/include/uhd/usrp/CMakeLists.txt b/host/include/uhd/usrp/CMakeLists.txt index e441433fd..ba38a67ea 100644 --- a/host/include/uhd/usrp/CMakeLists.txt +++ b/host/include/uhd/usrp/CMakeLists.txt @@ -17,13 +17,6 @@ INSTALL(FILES - #### props headers ### - codec_props.hpp - dboard_props.hpp - device_props.hpp - dsp_props.hpp - mboard_props.hpp - subdev_props.hpp #### dboard headers ### dboard_base.hpp @@ -33,12 +26,9 @@ INSTALL(FILES dboard_manager.hpp ### utilities ### - dsp_utils.hpp gps_ctrl.hpp mboard_eeprom.hpp - misc_utils.hpp subdev_spec.hpp - tune_helper.hpp ### interfaces ### single_usrp.hpp diff --git a/host/include/uhd/usrp/codec_props.hpp b/host/include/uhd/usrp/codec_props.hpp deleted file mode 100644 index b0a79e3f6..000000000 --- a/host/include/uhd/usrp/codec_props.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// -// 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 -// 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_UHD_USRP_CODEC_PROPS_HPP -#define INCLUDED_UHD_USRP_CODEC_PROPS_HPP - -#include <uhd/utils/props.hpp> - -namespace uhd{ namespace usrp{ - - /*! - * 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_I, //rw, double - CODEC_PROP_GAIN_Q , //rw, double - CODEC_PROP_GAIN_RANGE, //ro, gain_range_t - CODEC_PROP_GAIN_NAMES //ro, prop_names_t - }; - - -}} //namespace - -#endif /* INCLUDED_UHD_USRP_CODEC_PROPS_HPP */ diff --git a/host/include/uhd/usrp/dboard_base.hpp b/host/include/uhd/usrp/dboard_base.hpp index 9b75d791f..7e9557a95 100644 --- a/host/include/uhd/usrp/dboard_base.hpp +++ b/host/include/uhd/usrp/dboard_base.hpp @@ -28,6 +28,43 @@ namespace uhd{ namespace usrp{ + /*! + * Possible subdev connection types: + * + * A complex subdevice is physically connected to both channels, + * which may be connected in one of two ways: IQ or QI (swapped). + * + * A real subdevice is only physically connected one channel, + * either only the I channel or only the Q channel. + */ + enum subdev_conn_t{ + SUBDEV_CONN_COMPLEX_IQ = 'C', + SUBDEV_CONN_COMPLEX_QI = 'c', + SUBDEV_CONN_REAL_I = 'R', + SUBDEV_CONN_REAL_Q = 'r' + }; + + /*! + * Possible device subdev properties + */ + enum subdev_prop_t{ + SUBDEV_PROP_NAME, //ro, std::string + SUBDEV_PROP_OTHERS, //ro, prop_names_t + SUBDEV_PROP_SENSOR, //ro, sensor_value_t + SUBDEV_PROP_SENSOR_NAMES, //ro, prop_names_t + SUBDEV_PROP_GAIN, //rw, double + SUBDEV_PROP_GAIN_RANGE, //ro, gain_range_t + SUBDEV_PROP_GAIN_NAMES, //ro, prop_names_t + SUBDEV_PROP_FREQ, //rw, double + SUBDEV_PROP_FREQ_RANGE, //ro, freq_range_t + SUBDEV_PROP_ANTENNA, //rw, std::string + SUBDEV_PROP_ANTENNA_NAMES, //ro, prop_names_t + SUBDEV_PROP_CONNECTION, //ro, subdev_conn_t + SUBDEV_PROP_ENABLED, //rw, bool + SUBDEV_PROP_USE_LO_OFFSET, //ro, bool + SUBDEV_PROP_BANDWIDTH //rw, double + }; + /*! * A daughter board dboard_base class for all dboards. * Only other dboard dboard_base classes should inherit this. diff --git a/host/include/uhd/usrp/dboard_eeprom.hpp b/host/include/uhd/usrp/dboard_eeprom.hpp index 394d71dd6..f0190e233 100644 --- a/host/include/uhd/usrp/dboard_eeprom.hpp +++ b/host/include/uhd/usrp/dboard_eeprom.hpp @@ -50,7 +50,7 @@ struct UHD_API dboard_eeprom_t{ * \param iface the serial interface with i2c * \param addr the i2c address for the eeprom */ - void store(i2c_iface &iface, boost::uint8_t addr); + void store(i2c_iface &iface, boost::uint8_t addr) const; }; diff --git a/host/include/uhd/usrp/dboard_manager.hpp b/host/include/uhd/usrp/dboard_manager.hpp index 3c41c65a8..091769a5c 100644 --- a/host/include/uhd/usrp/dboard_manager.hpp +++ b/host/include/uhd/usrp/dboard_manager.hpp @@ -19,6 +19,7 @@ #define INCLUDED_UHD_USRP_DBOARD_MANAGER_HPP #include <uhd/config.hpp> +#include <uhd/property_tree.hpp> #include <uhd/utils/props.hpp> #include <uhd/usrp/dboard_base.hpp> #include <uhd/usrp/dboard_id.hpp> @@ -36,6 +37,11 @@ class UHD_API dboard_manager : boost::noncopyable{ public: typedef boost::shared_ptr<dboard_manager> sptr; + //! It does what it says... + static void populate_prop_tree_from_subdev( + property_tree::sptr subtree, wax::obj subdev + ); + //dboard constructor (each dboard should have a ::make with this signature) typedef dboard_base::sptr(*dboard_ctor_t)(dboard_base::ctor_args_t); diff --git a/host/include/uhd/usrp/dboard_props.hpp b/host/include/uhd/usrp/dboard_props.hpp deleted file mode 100644 index 29211ec8c..000000000 --- a/host/include/uhd/usrp/dboard_props.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// -// 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 -// 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_UHD_USRP_DBOARD_PROPS_HPP -#define INCLUDED_UHD_USRP_DBOARD_PROPS_HPP - -#include <uhd/utils/props.hpp> - -namespace uhd{ namespace usrp{ - - /*! - * Possible device dboard properties: - * A dboard has an id, one or more subdevices, and a codec. - * A dboard is considered to be unidirectional (RX or TX). - */ - 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_DBOARD_EEPROM, //rw, dboard_eeprom_t - DBOARD_PROP_GBOARD_EEPROM, //rw, dboard_eeprom_t - DBOARD_PROP_DBOARD_IFACE, //ro, dboard_iface::sptr - DBOARD_PROP_CODEC, //ro, wax::obj - DBOARD_PROP_GAIN_GROUP //ro, gain_group - }; - -}} //namespace - -#endif /* INCLUDED_UHD_USRP_DBOARD_PROPS_HPP */ diff --git a/host/include/uhd/usrp/device_props.hpp b/host/include/uhd/usrp/device_props.hpp deleted file mode 100644 index 3c8f7e225..000000000 --- a/host/include/uhd/usrp/device_props.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// -// 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 -// 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_UHD_USRP_DEVICE_PROPS_HPP -#define INCLUDED_UHD_USRP_DEVICE_PROPS_HPP - -#include <uhd/utils/props.hpp> - -namespace uhd{ namespace usrp{ - - /*! - * 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 - }; - -}} //namespace - -#endif /* INCLUDED_UHD_USRP_DEVICE_PROPS_HPP */ diff --git a/host/include/uhd/usrp/dsp_props.hpp b/host/include/uhd/usrp/dsp_props.hpp deleted file mode 100644 index e68e11deb..000000000 --- a/host/include/uhd/usrp/dsp_props.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// -// 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 -// 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_UHD_USRP_DSP_PROPS_HPP -#define INCLUDED_UHD_USRP_DSP_PROPS_HPP - -#include <uhd/utils/props.hpp> - -namespace uhd{ namespace usrp{ - - /*! - * Possible device dsp properties: - * A dsp is a black box fpga component found between - * the over-the-wire data and the codec pins. - * - * The host rate can be modified to control resampling. - * Resampling can take the form of decimation, interpolation, - * or more complex fractional resampling techniques. - * As usual, read back the host rate after setting it - * to get the actual rate that was set (implementation dependent). - * - * A dsp can also shift the digital stream in frequency. - * Set the shift property and read it back to get actual shift. - */ - enum dsp_prop_t{ - DSP_PROP_NAME, //ro, std::string - DSP_PROP_OTHERS, //ro, prop_names_t - DSP_PROP_STREAM_CMD, //wo, stream_cmd_t - DSP_PROP_FREQ_SHIFT, //rw, double Hz - DSP_PROP_CODEC_RATE, //ro, double Sps - DSP_PROP_HOST_RATE //rw, double Sps - }; - -}} //namespace - -#endif /* INCLUDED_UHD_USRP_DSP_PROPS_HPP */ diff --git a/host/include/uhd/usrp/dsp_utils.hpp b/host/include/uhd/usrp/dsp_utils.hpp deleted file mode 100644 index 5b81ce322..000000000 --- a/host/include/uhd/usrp/dsp_utils.hpp +++ /dev/null @@ -1,96 +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_UHD_USRP_DSP_UTILS_HPP -#define INCLUDED_UHD_USRP_DSP_UTILS_HPP - -#include <uhd/config.hpp> -#include <uhd/types/stream_cmd.hpp> -#include <uhd/usrp/subdev_props.hpp> -#include <boost/cstdint.hpp> - -namespace uhd{ namespace usrp{ - -namespace dsp_type1{ - - /*! - * Calculate the rx mux word from properties. - * \param subdev_conn the subdev connection type - * \return the 32-bit rx mux control word - */ - UHD_API boost::uint32_t calc_rx_mux_word(subdev_conn_t subdev_conn); - - /*! - * Calculate the tx mux word from properties. - * \param subdev_conn the subdev connection type - * \return the 32-bit tx mux control word - */ - UHD_API boost::uint32_t calc_tx_mux_word(subdev_conn_t subdev_conn); - - /*! - * Calculate the cordic word from the frequency and clock rate. - * The frequency will be set to the actual (possible) frequency. - * - * \param freq the requested frequency in Hz - * \param codec_rate the dsp codec rate in Hz - * \return the 32-bit cordic control word - */ - UHD_API boost::uint32_t calc_cordic_word_and_update( - double &freq, double codec_rate - ); - - /*! - * Calculate the CIC filter word from the rate. - * Check if requested decim/interp rate is: - * multiple of 4, enable two halfband filters - * multiple of 2, enable one halfband filter - * handle remainder in CIC - * - * \param rate the requested rate in Sps - * \return the 32-bit cic filter control word - */ - UHD_API boost::uint32_t calc_cic_filter_word(unsigned rate); - - /*! - * Calculate the IQ scale factor word from I and Q components. - * \param i the I component of the scalar - * \param q the Q component of the scalar - * \return the 32-bit scale factor control word - */ - UHD_API boost::uint32_t calc_iq_scale_word( - boost::int16_t i, boost::int16_t q - ); - - /*! - * Calculate the IQ scale factor word from the rate. - * \param rate the requested rate in Sps - * \return the 32-bit scale factor control word - */ - UHD_API boost::uint32_t calc_iq_scale_word(unsigned rate); - - /*! - * Calculate the stream command word from the stream command struct. - * \param stream_cmd the requested stream command with mode, flags, timestamp - * \return the 32-bit stream command word - */ - UHD_API boost::uint32_t calc_stream_cmd_word(const stream_cmd_t &stream_cmd); - -} //namespace dsp_type1 - -}} //namespace - -#endif /* INCLUDED_UHD_USRP_DSP_UTILS_HPP */ diff --git a/host/include/uhd/usrp/mboard_eeprom.hpp b/host/include/uhd/usrp/mboard_eeprom.hpp index 52363b95c..ea66bb2e0 100644 --- a/host/include/uhd/usrp/mboard_eeprom.hpp +++ b/host/include/uhd/usrp/mboard_eeprom.hpp @@ -56,7 +56,7 @@ namespace uhd{ namespace usrp{ * \param iface the interface to i2c * \param map the map type enum */ - void commit(i2c_iface &iface, map_type map); + void commit(i2c_iface &iface, map_type map) const; }; diff --git a/host/include/uhd/usrp/mboard_iface.hpp b/host/include/uhd/usrp/mboard_iface.hpp index 784fbc7c5..bbee8f2de 100644 --- a/host/include/uhd/usrp/mboard_iface.hpp +++ b/host/include/uhd/usrp/mboard_iface.hpp @@ -33,7 +33,7 @@ namespace uhd{ namespace usrp{ * Provides a set of functions to implementation layer. * Including spi, peek, poke, control... */ -class mboard_iface : public uhd::i2c_iface, public uhd::spi_iface { +class mboard_iface : public uhd::i2c_iface, public uhd::spi_iface, public uhd::uart_iface { public: typedef boost::shared_ptr<mboard_iface> sptr; /*! @@ -64,20 +64,6 @@ public: */ virtual boost::uint16_t peek16(boost::uint32_t addr) = 0; - /*! - * Write to a serial port. - * \param dev which UART to write to - * \param buf the data to write - */ - virtual void write_uart(boost::uint8_t dev, const std::string &buf) = 0; - - /*! - * Read from a serial port. - * \param dev which UART to read from - * \return the data read from the serial port - */ - virtual std::string read_uart(boost::uint8_t dev) = 0; - }; }} diff --git a/host/include/uhd/usrp/mboard_props.hpp b/host/include/uhd/usrp/mboard_props.hpp deleted file mode 100644 index a2580954e..000000000 --- a/host/include/uhd/usrp/mboard_props.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// -// 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 -// 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_UHD_USRP_MBOARD_PROPS_HPP -#define INCLUDED_UHD_USRP_MBOARD_PROPS_HPP - -#include <uhd/utils/props.hpp> - -namespace uhd{ namespace usrp{ - - /*! - * 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_SENSOR, //ro, sensor_value_t - MBOARD_PROP_SENSOR_NAMES, //ro, prop_names_t - MBOARD_PROP_CLOCK_RATE, //rw, double - 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_RX_SUBDEV_SPEC, //rw, subdev_spec_t - MBOARD_PROP_TX_SUBDEV_SPEC, //rw, subdev_spec_t - MBOARD_PROP_CLOCK_CONFIG, //rw, clock_config_t - MBOARD_PROP_TIME_NOW, //rw, time_spec_t - MBOARD_PROP_TIME_PPS, //wo, time_spec_t - MBOARD_PROP_EEPROM_MAP, //wr, mboard_eeprom_t - MBOARD_PROP_IFACE, //ro, mboard_iface::sptr - }; - -}} //namespace - -#endif /* INCLUDED_UHD_USRP_MBOARD_PROPS_HPP */ diff --git a/host/include/uhd/usrp/misc_utils.hpp b/host/include/uhd/usrp/misc_utils.hpp deleted file mode 100644 index 37860a1a5..000000000 --- a/host/include/uhd/usrp/misc_utils.hpp +++ /dev/null @@ -1,71 +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_UHD_USRP_MISC_UTILS_HPP -#define INCLUDED_UHD_USRP_MISC_UTILS_HPP - -#include <uhd/config.hpp> -#include <uhd/wax.hpp> -#include <uhd/usrp/dboard_id.hpp> -#include <uhd/usrp/subdev_spec.hpp> -#include <uhd/utils/gain_group.hpp> - -namespace uhd{ namespace usrp{ - - /*! - * Different policies for gain group prioritization. - */ - enum gain_group_policy_t{ - GAIN_GROUP_POLICY_RX = 'R', - GAIN_GROUP_POLICY_TX = 'T' - }; - - /*! - * Create a gain group that represents the subdevice and its codec. - * \param dboard_id the dboard id for this subdevice - * \param subdev the object with subdevice properties - * \param codec the object with codec properties - * \param gain_group_policy the policy to use - */ - UHD_API gain_group::sptr make_gain_group( - const dboard_id_t &dboard_id, - wax::obj subdev, wax::obj codec, - gain_group_policy_t gain_group_policy - ); - - /*! - * Verify the rx subdevice specification. - * If the subdev spec if empty, automatically fill it. - * \param subdev_spec the subdev spec to verify/fill - * \param mboard the motherboard properties object - * \throw exception when the subdev spec is invalid - */ - UHD_API void verify_rx_subdev_spec(subdev_spec_t &subdev_spec, wax::obj mboard); - - /*! - * Verify the tx subdevice specification. - * If the subdev spec if empty, automatically fill it. - * \param subdev_spec the subdev spec to verify/fill - * \param mboard the motherboard properties object - * \throw exception when the subdev spec is invalid - */ - UHD_API void verify_tx_subdev_spec(subdev_spec_t &subdev_spec, wax::obj mboard); - -}} //namespace - -#endif /* INCLUDED_UHD_USRP_MISC_UTILS_HPP */ - diff --git a/host/include/uhd/usrp/subdev_props.hpp b/host/include/uhd/usrp/subdev_props.hpp deleted file mode 100644 index 40b339703..000000000 --- a/host/include/uhd/usrp/subdev_props.hpp +++ /dev/null @@ -1,64 +0,0 @@ -// -// 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 -// 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_UHD_USRP_SUBDEV_PROPS_HPP -#define INCLUDED_UHD_USRP_SUBDEV_PROPS_HPP - -#include <uhd/utils/props.hpp> - -namespace uhd{ namespace usrp{ - - /*! - * Possible subdev connection types: - * - * A complex subdevice is physically connected to both channels, - * which may be connected in one of two ways: IQ or QI (swapped). - * - * A real subdevice is only physically connected one channel, - * either only the I channel or only the Q channel. - */ - enum subdev_conn_t{ - SUBDEV_CONN_COMPLEX_IQ = 'C', - SUBDEV_CONN_COMPLEX_QI = 'c', - SUBDEV_CONN_REAL_I = 'R', - SUBDEV_CONN_REAL_Q = 'r' - }; - - /*! - * Possible device subdev properties - */ - enum subdev_prop_t{ - SUBDEV_PROP_NAME, //ro, std::string - SUBDEV_PROP_OTHERS, //ro, prop_names_t - SUBDEV_PROP_SENSOR, //ro, sensor_value_t - SUBDEV_PROP_SENSOR_NAMES, //ro, prop_names_t - SUBDEV_PROP_GAIN, //rw, double - SUBDEV_PROP_GAIN_RANGE, //ro, gain_range_t - SUBDEV_PROP_GAIN_NAMES, //ro, prop_names_t - SUBDEV_PROP_FREQ, //rw, double - SUBDEV_PROP_FREQ_RANGE, //ro, freq_range_t - SUBDEV_PROP_ANTENNA, //rw, std::string - SUBDEV_PROP_ANTENNA_NAMES, //ro, prop_names_t - SUBDEV_PROP_CONNECTION, //ro, subdev_conn_t - SUBDEV_PROP_ENABLED, //rw, bool - SUBDEV_PROP_USE_LO_OFFSET, //ro, bool - SUBDEV_PROP_BANDWIDTH //rw, double - }; - -}} //namespace - -#endif /* INCLUDED_UHD_USRP_SUBDEV_PROPS_HPP */ diff --git a/host/include/uhd/usrp/subdev_spec.hpp b/host/include/uhd/usrp/subdev_spec.hpp index b189724c9..62c1fc177 100644 --- a/host/include/uhd/usrp/subdev_spec.hpp +++ b/host/include/uhd/usrp/subdev_spec.hpp @@ -62,11 +62,6 @@ namespace uhd{ namespace usrp{ * The markup-string is a whitespace separated list of dboard:subdev pairs. * The first pair represents the subdevice for channel zero, * the second pair represents the subdevice for channel one, and so on. - * - * Special handling for empty conditions: - * - An empty subdevice specification means: select the first subdevice found in the configuration - * - An empty daughterboard name means: select the only daughterboard slot or error if multiple exist - * - An empty subdevice name means: select the only subdevice on that board or error if multiple exist */ class UHD_API subdev_spec_t : public std::vector<subdev_spec_pair_t>{ public: diff --git a/host/include/uhd/usrp/tune_helper.hpp b/host/include/uhd/usrp/tune_helper.hpp deleted file mode 100644 index 0d468a4e2..000000000 --- a/host/include/uhd/usrp/tune_helper.hpp +++ /dev/null @@ -1,78 +0,0 @@ -// -// 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 -// 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_UHD_USRP_TUNE_HELPER_HPP -#define INCLUDED_UHD_USRP_TUNE_HELPER_HPP - -#include <uhd/config.hpp> -#include <uhd/wax.hpp> -#include <uhd/types/tune_request.hpp> -#include <uhd/types/tune_result.hpp> - -namespace uhd{ namespace usrp{ - - /*! - * Tune a rx chain to the desired frequency: - * The IF of the subdevice is set as close as possible to - * the given target frequency + the LO offset (when applicable). - * The ddc cordic is setup to bring the IF down to baseband. - * \param subdev the dboard subdevice object with properties - * \param ddc the mboard dsp object with properties - * \param tune_request tune request instructions - * \return a tune result struct - */ - UHD_API tune_result_t tune_rx_subdev_and_dsp( - wax::obj subdev, wax::obj ddc, const tune_request_t &tune_request - ); - - /*! - * Calculate the overall frequency from the combination of dboard IF and DDC shift. - * \param subdev the dboard subdevice object with properties - * \param ddc the mboard dsp object with properties - * \return the overall tune frequency of the system in Hz - */ - UHD_API double derive_freq_from_rx_subdev_and_dsp( - wax::obj subdev, wax::obj ddc - ); - - /*! - * Tune a tx chain to the desired frequency: - * The IF of the subdevice is set as close as possible to - * the given target frequency + the LO offset (when applicable). - * The duc cordic is setup to bring the baseband up to IF. - * \param subdev the dboard subdevice object with properties - * \param duc the mboard dsp object with properties - * \param tune_request tune request instructions - * \return a tune result struct - */ - UHD_API tune_result_t tune_tx_subdev_and_dsp( - wax::obj subdev, wax::obj duc, const tune_request_t &tune_request - ); - - /*! - * Calculate the overall frequency from the combination of dboard IF and DUC shift. - * \param subdev the dboard subdevice object with properties - * \param duc the mboard dsp object with properties - * \return the overall tune frequency of the system in Hz - */ - UHD_API double derive_freq_from_tx_subdev_and_dsp( - wax::obj subdev, wax::obj duc - ); - -}} - -#endif /* INCLUDED_UHD_USRP_TUNE_HELPER_HPP */ diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt index 88a0e612b..0bf98fb67 100644 --- a/host/include/uhd/utils/CMakeLists.txt +++ b/host/include/uhd/utils/CMakeLists.txt @@ -30,6 +30,7 @@ INSTALL(FILES safe_call.hpp safe_main.hpp static.hpp + tasks.hpp thread_priority.hpp DESTINATION ${INCLUDE_DIR}/uhd/utils COMPONENT headers diff --git a/host/include/uhd/utils/tasks.hpp b/host/include/uhd/utils/tasks.hpp new file mode 100644 index 000000000..38b2bddf0 --- /dev/null +++ b/host/include/uhd/utils/tasks.hpp @@ -0,0 +1,53 @@ +// +// Copyright 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 +// 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_UHD_UTILS_TASKS_HPP +#define INCLUDED_UHD_UTILS_TASKS_HPP + +#include <uhd/config.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/function.hpp> +#include <boost/utility.hpp> + +namespace uhd{ + + class task : boost::noncopyable{ + public: + typedef boost::shared_ptr<task> sptr; + typedef boost::function<void(void)> task_fcn_type; + + /*! + * Create a new task object with function callback. + * The task function callback will be run in a loop. + * until the thread is interrupted by the deconstructor. + * + * A task should return in a reasonable amount of time + * or may block forever under the following conditions: + * - The blocking call is interruptible. + * - The task polls the interrupt condition. + * + * \param task_fcn the task callback function + * \return a new task object + */ + static sptr make(const task_fcn_type &task_fcn); + + }; + +} //namespace uhd + +#endif /* INCLUDED_UHD_UTILS_TASKS_HPP */ + |