aboutsummaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-08-15 10:55:18 -0700
committerJosh Blum <josh@joshknows.com>2010-08-15 10:55:18 -0700
commit45c952399b92d5dc618c469cf48c9980ee6f0e80 (patch)
tree077870c0975c97cabd5d8c76e19965aeade2cdc6 /host/include
parent9cb9e7d52255d3e14e57867eee76b555f705954c (diff)
parent98ba0cc067489d417342314a7e7408d2dbbc8250 (diff)
downloaduhd-45c952399b92d5dc618c469cf48c9980ee6f0e80.tar.gz
uhd-45c952399b92d5dc618c469cf48c9980ee6f0e80.tar.bz2
uhd-45c952399b92d5dc618c469cf48c9980ee6f0e80.zip
Merge branch 'next' into usrp1
Diffstat (limited to 'host/include')
-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/utils/algorithm.hpp21
-rw-r--r--host/include/uhd/utils/props.hpp33
4 files changed, 67 insertions, 18 deletions
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/utils/algorithm.hpp b/host/include/uhd/utils/algorithm.hpp
index 1b5eacfa9..53c571e4e 100644
--- a/host/include/uhd/utils/algorithm.hpp
+++ b/host/include/uhd/utils/algorithm.hpp
@@ -22,6 +22,9 @@
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/size.hpp>
+#include <boost/algorithm/string.hpp>
+#include <vector>
+#include <string>
/*! \file algorithm.hpp
* Useful templated functions and classes that I like to pretend are part of stl.
@@ -30,6 +33,24 @@
namespace std{
/*!
+ * Split a string at the separation characters.
+ * \param string the string to split
+ * \param sep the separator characters
+ * \return a range of strings
+ */
+ inline std::vector<std::string> split_string(
+ const std::string &string, const std::string &sep = "\t "
+ ){
+ std::vector<std::string> strings;
+ if (not string.empty()) boost::split(
+ // do not split an empty string:
+ // let me tell you about the time when boost::split segfaulted...
+ strings, string, boost::is_any_of(sep)
+ );
+ return strings;
+ }
+
+ /*!
* A wrapper around std::copy that takes ranges instead of iterators.
*
* Copy the elements of the source range into the destination range.
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.
*/