summaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-03-21 00:58:34 -0700
committerJosh Blum <josh@joshknows.com>2010-03-21 00:58:34 -0700
commitd1ecc555e53770f1a5608000352f56f48c36c310 (patch)
treeccccaac506fa6fe0812fce202121a4ad85d3f752 /host/include
parent26ada5ee709fc4d7e195d19720b467c14368bc05 (diff)
downloaduhd-d1ecc555e53770f1a5608000352f56f48c36c310.tar.gz
uhd-d1ecc555e53770f1a5608000352f56f48c36c310.tar.bz2
uhd-d1ecc555e53770f1a5608000352f56f48c36c310.zip
Moved typedefs from props.hpp into new file types.hpp.
Created structs to replace range tuples, and clock config struct. Merged clock config props into one property using config struct. Added templated dict construction to use the assign::map_list_of. Added gcc flag to set visibility to hidden and use the api macro.
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/CMakeLists.txt1
-rw-r--r--host/include/uhd/dict.hpp13
-rw-r--r--host/include/uhd/props.hpp33
-rw-r--r--host/include/uhd/simple_device.hpp26
-rw-r--r--host/include/uhd/types.hpp83
-rw-r--r--host/include/uhd/utils.hpp5
6 files changed, 111 insertions, 50 deletions
diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt
index 17c260c24..3d00462cf 100644
--- a/host/include/uhd/CMakeLists.txt
+++ b/host/include/uhd/CMakeLists.txt
@@ -29,6 +29,7 @@ INSTALL(FILES
props.hpp
simple_device.hpp
time_spec.hpp
+ types.hpp
utils.hpp
wax.hpp
DESTINATION ${HEADER_DIR}/uhd
diff --git a/host/include/uhd/dict.hpp b/host/include/uhd/dict.hpp
index 8f7cd5a0f..f08493952 100644
--- a/host/include/uhd/dict.hpp
+++ b/host/include/uhd/dict.hpp
@@ -40,6 +40,19 @@ namespace uhd{
}
/*!
+ * Input iterator constructor:
+ * Makes boost::assign::map_list_of work.
+ * \param first the begin iterator
+ * \param last the end iterator
+ */
+ template <class InputIterator>
+ dict(InputIterator first, InputIterator last){
+ for(InputIterator it = first; it != last; it++){
+ _map.push_back(*it);
+ }
+ }
+
+ /*!
* Destroy this dict.
*/
~dict(void){
diff --git a/host/include/uhd/props.hpp b/host/include/uhd/props.hpp
index 7229d4a12..41e0eff63 100644
--- a/host/include/uhd/props.hpp
+++ b/host/include/uhd/props.hpp
@@ -18,34 +18,14 @@
#ifndef INCLUDED_UHD_PROPS_HPP
#define INCLUDED_UHD_PROPS_HPP
-#include <boost/tuple/tuple.hpp>
-#include <uhd/time_spec.hpp>
+#include <uhd/config.hpp>
#include <uhd/wax.hpp>
-#include <complex>
+#include <boost/tuple/tuple.hpp>
#include <vector>
+#include <string>
namespace uhd{
- //common typedefs for board properties
- typedef float gain_t;
- typedef double freq_t;
-
- //gain range tuple (min, max, step)
- typedef boost::tuple<gain_t, gain_t, gain_t> gain_range_t;
-
- //freq range tuple (min, max)
- typedef boost::tuple<freq_t, freq_t> freq_range_t;
-
- //scalar types (have not used yet, dont uncomment until needed)
- //typedef int int_scalar_t;
- //typedef float real_scalar_t;
- //typedef std::complex<real_scalar_t> complex_scalar_t;
-
- //vector types (have not used yet, dont uncomment until needed)
- //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;
@@ -55,7 +35,8 @@ namespace uhd{
* \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 = ""){
+ inline UHD_API named_prop_t //must be exported as part of the api to work (TODO move guts to cpp file)
+ extract_named_prop(const wax::obj &key, const std::string &name = ""){
if (key.type() == typeid(named_prop_t)){
return key.as<named_prop_t>();
}
@@ -94,10 +75,8 @@ namespace uhd{
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_CLOCK_CONFIG, //rw, clock_config_t
MBOARD_PROP_PPS_SOURCE_NAMES, //ro, prop_names_t
- MBOARD_PROP_PPS_POLARITY, //rw, std::string (pos, neg)
- 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
diff --git a/host/include/uhd/simple_device.hpp b/host/include/uhd/simple_device.hpp
index b5d0fe311..ad25eccdc 100644
--- a/host/include/uhd/simple_device.hpp
+++ b/host/include/uhd/simple_device.hpp
@@ -20,6 +20,7 @@
#include <uhd/config.hpp>
#include <uhd/device.hpp>
+#include <uhd/types.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
#include <vector>
@@ -27,23 +28,6 @@
namespace uhd{
/*!
- * The tune result struct holds result of a 2-phase tuning:
- * The struct hold the result of tuning the dboard as
- * the target and actual intermediate frequency.
- * The struct hold the result of tuning the DDC/DUC as
- * the target and actual digital converter frequency.
- * It also tell us weather or not the spectrum is inverted.
- */
-struct UHD_API tune_result_t{
- double target_inter_freq;
- double actual_inter_freq;
- double target_dxc_freq;
- double actual_dxc_freq;
- bool spectrum_inverted;
- tune_result_t(void);
-};
-
-/*!
* The simple UHD device class:
* A simple device facilitates ease-of-use for most use-case scenarios.
* The wrapper provides convenience functions to tune the devices
@@ -72,11 +56,11 @@ public:
virtual std::vector<double> get_rx_rates(void) = 0;
virtual tune_result_t set_rx_freq(double freq) = 0;
- virtual std::vector<double> get_rx_freq_range(void) = 0;
+ virtual freq_range_t get_rx_freq_range(void) = 0;
virtual void set_rx_gain(float gain) = 0;
virtual float get_rx_gain(void) = 0;
- virtual std::vector<float> get_rx_gain_range(void) = 0;
+ virtual gain_range_t get_rx_gain_range(void) = 0;
virtual void set_rx_antenna(const std::string &ant) = 0;
virtual std::string get_rx_antenna(void) = 0;
@@ -90,11 +74,11 @@ public:
virtual std::vector<double> get_tx_rates(void) = 0;
virtual tune_result_t set_tx_freq(double freq) = 0;
- virtual std::vector<double> get_tx_freq_range(void) = 0;
+ virtual freq_range_t get_tx_freq_range(void) = 0;
virtual void set_tx_gain(float gain) = 0;
virtual float get_tx_gain(void) = 0;
- virtual std::vector<float> get_tx_gain_range(void) = 0;
+ virtual gain_range_t get_tx_gain_range(void) = 0;
virtual void set_tx_antenna(const std::string &ant) = 0;
virtual std::string get_tx_antenna(void) = 0;
diff --git a/host/include/uhd/types.hpp b/host/include/uhd/types.hpp
new file mode 100644
index 000000000..1439f57a1
--- /dev/null
+++ b/host/include/uhd/types.hpp
@@ -0,0 +1,83 @@
+//
+// 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_TYPES_HPP
+#define INCLUDED_UHD_TYPES_HPP
+
+#include <uhd/config.hpp>
+#include <string>
+
+namespace uhd{
+
+ typedef float gain_t; //TODO REMOVE
+ typedef double freq_t; //TODO REMOVE
+
+ /*!
+ * The gain range struct describes possible gain settings.
+ * The mimumum gain, maximum gain, and step size are in dB.
+ */
+ struct UHD_API gain_range_t{
+ float min, max, step;
+ gain_range_t(float min = 0.0, float max = 0.0, float step = 0.0);
+ };
+
+ /*!
+ * The frequency range struct describes possible frequency settings.
+ * Because tuning is very granular (sub-Hz), step size is not listed.
+ * The mimumum frequency and maximum frequency are in Hz.
+ */
+ struct UHD_API freq_range_t{
+ double min, max;
+ freq_range_t(double min = 0.0, double max = 0.0);
+ };
+
+ /*!
+ * The tune result struct holds result of a 2-phase tuning:
+ * The struct hold the result of tuning the dboard as
+ * the target and actual intermediate frequency.
+ * The struct hold the result of tuning the DDC/DUC as
+ * the target and actual digital converter frequency.
+ * It also tell us weather or not the spectrum is inverted.
+ */
+ struct UHD_API tune_result_t{
+ double target_inter_freq;
+ double actual_inter_freq;
+ double target_dxc_freq;
+ double actual_dxc_freq;
+ bool spectrum_inverted;
+ tune_result_t(void);
+ };
+
+ /*!
+ * Clock configuration settings:
+ * The source for the 10MHz reference clock.
+ * The source and polarity for the PPS clock.
+ * Possible settings for the reference and pps source
+ * are implementation specific motherboard properties.
+ * See the MBOARD_PROP_XXX_SOURCE_NAMES properties.
+ */
+ struct clock_config_t{
+ enum polarity_t {POLARITY_NEG, POLARITY_POS};
+ std::string ref_source;
+ std::string pps_source;
+ polarity_t pps_polarity;
+ clock_config_t(void);
+ };
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_TYPES_HPP */
diff --git a/host/include/uhd/utils.hpp b/host/include/uhd/utils.hpp
index 995cb9926..e5333539f 100644
--- a/host/include/uhd/utils.hpp
+++ b/host/include/uhd/utils.hpp
@@ -18,10 +18,11 @@
#ifndef INCLUDED_UHD_UTILS_HPP
#define INCLUDED_UHD_UTILS_HPP
-#include <stdexcept>
-#include <algorithm>
+#include <uhd/config.hpp>
#include <boost/format.hpp>
#include <boost/current_function.hpp>
+#include <stdexcept>
+#include <algorithm>
/*!
* Defines a function that implements the "construct on first use" idiom