summaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/usrp/CMakeLists.txt2
-rw-r--r--host/include/uhd/usrp/dboard_iface.hpp29
-rw-r--r--host/include/uhd/usrp/dboard_manager.hpp2
-rw-r--r--host/include/uhd/usrp/dsp_utils.hpp99
-rw-r--r--host/include/uhd/usrp/misc_utils.hpp68
-rw-r--r--host/include/uhd/utils/props.hpp33
6 files changed, 215 insertions, 18 deletions
diff --git a/host/include/uhd/usrp/CMakeLists.txt b/host/include/uhd/usrp/CMakeLists.txt
index 76ee24e5f..130956f8a 100644
--- a/host/include/uhd/usrp/CMakeLists.txt
+++ b/host/include/uhd/usrp/CMakeLists.txt
@@ -33,6 +33,8 @@ INSTALL(FILES
dboard_manager.hpp
### utilities ###
+ dsp_utils.hpp
+ misc_utils.hpp
subdev_spec.hpp
tune_helper.hpp
diff --git a/host/include/uhd/usrp/dboard_iface.hpp b/host/include/uhd/usrp/dboard_iface.hpp
index fc7ea3052..e776ecc42 100644
--- a/host/include/uhd/usrp/dboard_iface.hpp
+++ b/host/include/uhd/usrp/dboard_iface.hpp
@@ -65,11 +65,34 @@ 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 the motherboard name of the form: usrp1, usrp2...
- * \return string representing the motherboard name
+ * Get special properties information for this dboard slot.
+ * This call helps the dboard code to handle implementation
+ * differences between different motherboards and dboard slots.
+ * \return the special properties struct
*/
- virtual std::string get_mboard_name(void) = 0;
+ virtual special_props_t get_special_props(void) = 0;
/*!
* Write to an aux dac.
diff --git a/host/include/uhd/usrp/dboard_manager.hpp b/host/include/uhd/usrp/dboard_manager.hpp
index e5831d4cf..c68f069f0 100644
--- a/host/include/uhd/usrp/dboard_manager.hpp
+++ b/host/include/uhd/usrp/dboard_manager.hpp
@@ -51,7 +51,7 @@ public:
const dboard_id_t &dboard_id,
dboard_ctor_t dboard_ctor,
const std::string &name,
- const prop_names_t &subdev_names = prop_names_t(1, "")
+ const prop_names_t &subdev_names = prop_names_t(1, "0")
);
/*!
diff --git a/host/include/uhd/usrp/dsp_utils.hpp b/host/include/uhd/usrp/dsp_utils.hpp
new file mode 100644
index 000000000..8ec04dd2f
--- /dev/null
+++ b/host/include/uhd/usrp/dsp_utils.hpp
@@ -0,0 +1,99 @@
+//
+// 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
+ * \param num_samps_continuous number of samples to request in continuous mode
+ * \return the 32-bit stream command word
+ */
+ UHD_API boost::uint32_t calc_stream_cmd_word(
+ const stream_cmd_t &stream_cmd, size_t num_samps_continuous
+ );
+
+} //namespace dsp_type1
+
+}} //namespace
+
+#endif /* INCLUDED_UHD_USRP_DSP_UTILS_HPP */
diff --git a/host/include/uhd/usrp/misc_utils.hpp b/host/include/uhd/usrp/misc_utils.hpp
new file mode 100644
index 000000000..2af9f5b40
--- /dev/null
+++ b/host/include/uhd/usrp/misc_utils.hpp
@@ -0,0 +1,68 @@
+//
+// 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/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 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(
+ 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/utils/props.hpp b/host/include/uhd/utils/props.hpp
index f376d2612..fbca03019 100644
--- a/host/include/uhd/utils/props.hpp
+++ b/host/include/uhd/utils/props.hpp
@@ -21,7 +21,6 @@
#include <uhd/config.hpp>
#include <uhd/wax.hpp>
#include <uhd/utils/exception.hpp>
-#include <boost/tuple/tuple.hpp>
#include <stdexcept>
#include <vector>
#include <string>
@@ -36,8 +35,25 @@ namespace uhd{
* Allows properties to be sub-sectioned by name.
*/
struct UHD_API named_prop_t{
- wax::obj key;
- std::string name;
+ const wax::obj key;
+ const std::string name;
+
+ //! Convert the key to the specified type
+ template<typename T> inline T as(void){
+ return key.as<T>();
+ }
+
+ /*!
+ * Utility function to convert generic key into a named prop.
+ * If the key was already a named prop, the prop will be split.
+ * Otherwise, the key will be the key, and the name will be used.
+ * \param key a reference to the prop object
+ * \param name a reference to the name object
+ * \return a named property struct with key and name
+ */
+ static named_prop_t extract(
+ const wax::obj &key, const std::string &name = ""
+ );
/*!
* Create a new named prop from key and name.
@@ -48,17 +64,6 @@ namespace uhd{
};
/*!
- * 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
- * \return a tuple that can be used with boost::tie
- */
- UHD_API boost::tuple<wax::obj, std::string> extract_named_prop(
- const wax::obj &key,
- const std::string &name = ""
- );
-
- /*!
* Throw when getting a not-implemented or write-only property.
* Throw-site information will be included with this error.
*/