summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/usrp/multi_usrp.hpp59
-rw-r--r--host/include/uhd/usrp/single_usrp.hpp79
-rw-r--r--host/lib/usrp/multi_usrp.cpp34
-rw-r--r--host/lib/usrp/single_usrp.cpp34
4 files changed, 150 insertions, 56 deletions
diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp
index 6adba85bd..70901fc31 100644
--- a/host/include/uhd/usrp/multi_usrp.hpp
+++ b/host/include/uhd/usrp/multi_usrp.hpp
@@ -73,6 +73,9 @@ public:
//! A wildcard motherboard index
static const size_t ALL_MBOARDS = size_t(~0);
+ //! A wildcard gain element name
+ static const std::string ALL_GAINS;
+
/*!
* Make a new multi usrp from the device address.
* \param dev_addr the device address
@@ -240,27 +243,39 @@ public:
virtual freq_range_t get_rx_freq_range(size_t chan) = 0;
/*!
- * Set the RX gain:
- * Distribute among gain elements in the RX path.
+ * 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(float gain, size_t chan) = 0;
+ virtual void set_rx_gain(float gain, const std::string &name, size_t chan) = 0;
/*!
- * Get the RX gain:
- * Summation of gain elements in the RX path.
+ * 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 float get_rx_gain(size_t chan) = 0;
+ virtual float get_rx_gain(const std::string &name, size_t chan) = 0;
/*!
- * Get the RX gain range.
+ * 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(size_t chan) = 0;
+ virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan) = 0;
+
+ /*!
+ * 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;
/*!
* Select the RX antenna on the subdevice.
@@ -399,27 +414,39 @@ public:
virtual freq_range_t get_tx_freq_range(size_t chan) = 0;
/*!
- * Set the TX gain:
- * Distribute among gain elements in the TX path.
+ * 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(float gain, size_t chan) = 0;
+ virtual void set_tx_gain(float gain, const std::string &name, size_t chan) = 0;
/*!
- * Get the TX gain:
- * Summation of gain elements in the TX path.
+ * 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 float get_tx_gain(size_t chan) = 0;
+ virtual float get_tx_gain(const std::string &name, size_t chan) = 0;
/*!
- * Get the TX gain range.
+ * 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(size_t chan) = 0;
+ virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan) = 0;
+
+ /*!
+ * 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;
/*!
* Select the TX antenna on the subdevice.
diff --git a/host/include/uhd/usrp/single_usrp.hpp b/host/include/uhd/usrp/single_usrp.hpp
index 74a978f05..09bf9c84d 100644
--- a/host/include/uhd/usrp/single_usrp.hpp
+++ b/host/include/uhd/usrp/single_usrp.hpp
@@ -43,6 +43,9 @@ 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
@@ -182,27 +185,49 @@ public:
virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
/*!
- * Set the RX gain:
- * Distribute among gain elements in the RX path.
+ * 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(float gain, size_t chan = 0) = 0;
+ virtual void set_rx_gain(
+ float gain,
+ const std::string &name = ALL_GAINS,
+ size_t chan = 0
+ ) = 0;
/*!
- * Get the RX gain:
- * Summation of gain elements in the RX path.
+ * 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 float get_rx_gain(size_t chan = 0) = 0;
+ virtual float get_rx_gain(
+ const std::string &name = ALL_GAINS,
+ size_t chan = 0
+ ) = 0;
/*!
- * Get the RX gain range.
+ * 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(size_t chan = 0) = 0;
+ virtual gain_range_t get_rx_gain_range(
+ const std::string &name = ALL_GAINS,
+ size_t chan = 0
+ ) = 0;
+
+ /*!
+ * 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.
@@ -332,27 +357,49 @@ public:
virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
/*!
- * Set the TX gain:
- * Distribute among gain elements in the TX path.
+ * 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(float gain, size_t chan = 0) = 0;
+ virtual void set_tx_gain(
+ float gain,
+ const std::string &name = ALL_GAINS,
+ size_t chan = 0
+ ) = 0;
/*!
- * Get the TX gain:
- * Summation of gain elements in the TX path.
+ * 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 float get_tx_gain(size_t chan = 0) = 0;
+ virtual float get_tx_gain(
+ const std::string &name = ALL_GAINS,
+ size_t chan = 0
+ ) = 0;
/*!
- * Get the TX gain range.
+ * 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(size_t chan = 0) = 0;
+ virtual gain_range_t get_tx_gain_range(
+ const std::string &name = ALL_GAINS,
+ size_t chan = 0
+ ) = 0;
+
+ /*!
+ * 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.
diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp
index 027530f31..443b91594 100644
--- a/host/lib/usrp/multi_usrp.cpp
+++ b/host/lib/usrp/multi_usrp.cpp
@@ -35,6 +35,8 @@
using namespace uhd;
using namespace uhd::usrp;
+const std::string multi_usrp::ALL_GAINS = "";
+
/***********************************************************************
* Simple USRP Implementation
**********************************************************************/
@@ -228,16 +230,20 @@ public:
return add_dsp_shift(_rx_subdev(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _rx_dsp(chan/rx_cpm()));
}
- void set_rx_gain(float gain, size_t chan){
- return _rx_gain_group(chan)->set_value(gain);
+ void set_rx_gain(float gain, const std::string &name, size_t chan){
+ return _rx_gain_group(chan)->set_value(gain, name);
+ }
+
+ float get_rx_gain(const std::string &name, size_t chan){
+ return _rx_gain_group(chan)->get_value(name);
}
- float get_rx_gain(size_t chan){
- return _rx_gain_group(chan)->get_value();
+ gain_range_t get_rx_gain_range(const std::string &name, size_t chan){
+ return _rx_gain_group(chan)->get_range(name);
}
- gain_range_t get_rx_gain_range(size_t chan){
- return _rx_gain_group(chan)->get_range();
+ std::vector<std::string> get_rx_gain_names(size_t chan){
+ return _rx_gain_group(chan)->get_names();
}
void set_rx_antenna(const std::string &ant, size_t chan){
@@ -328,16 +334,20 @@ public:
return add_dsp_shift(_tx_subdev(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _tx_dsp(chan/tx_cpm()));
}
- void set_tx_gain(float gain, size_t chan){
- return _tx_gain_group(chan)->set_value(gain);
+ void set_tx_gain(float gain, const std::string &name, size_t chan){
+ return _tx_gain_group(chan)->set_value(gain, name);
+ }
+
+ float get_tx_gain(const std::string &name, size_t chan){
+ return _tx_gain_group(chan)->get_value(name);
}
- float get_tx_gain(size_t chan){
- return _tx_gain_group(chan)->get_value();
+ gain_range_t get_tx_gain_range(const std::string &name, size_t chan){
+ return _tx_gain_group(chan)->get_range(name);
}
- gain_range_t get_tx_gain_range(size_t chan){
- return _tx_gain_group(chan)->get_range();
+ std::vector<std::string> get_tx_gain_names(size_t chan){
+ return _tx_gain_group(chan)->get_names();
}
void set_tx_antenna(const std::string &ant, size_t chan){
diff --git a/host/lib/usrp/single_usrp.cpp b/host/lib/usrp/single_usrp.cpp
index 2faa1280c..5e57849b8 100644
--- a/host/lib/usrp/single_usrp.cpp
+++ b/host/lib/usrp/single_usrp.cpp
@@ -33,6 +33,8 @@
using namespace uhd;
using namespace uhd::usrp;
+const std::string single_usrp::ALL_GAINS = "";
+
/***********************************************************************
* Simple USRP Implementation
**********************************************************************/
@@ -164,16 +166,20 @@ public:
return add_dsp_shift(_rx_subdev(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _rx_dsp());
}
- void set_rx_gain(float gain, size_t chan){
- return _rx_gain_group(chan)->set_value(gain);
+ void set_rx_gain(float gain, const std::string &name, size_t chan){
+ return _rx_gain_group(chan)->set_value(gain, name);
+ }
+
+ float get_rx_gain(const std::string &name, size_t chan){
+ return _rx_gain_group(chan)->get_value(name);
}
- float get_rx_gain(size_t chan){
- return _rx_gain_group(chan)->get_value();
+ gain_range_t get_rx_gain_range(const std::string &name, size_t chan){
+ return _rx_gain_group(chan)->get_range(name);
}
- gain_range_t get_rx_gain_range(size_t chan){
- return _rx_gain_group(chan)->get_range();
+ std::vector<std::string> get_rx_gain_names(size_t chan){
+ return _rx_gain_group(chan)->get_names();
}
void set_rx_antenna(const std::string &ant, size_t chan){
@@ -252,16 +258,20 @@ public:
return add_dsp_shift(_tx_subdev(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _tx_dsp());
}
- void set_tx_gain(float gain, size_t chan){
- return _tx_gain_group(chan)->set_value(gain);
+ void set_tx_gain(float gain, const std::string &name, size_t chan){
+ return _tx_gain_group(chan)->set_value(gain, name);
+ }
+
+ float get_tx_gain(const std::string &name, size_t chan){
+ return _tx_gain_group(chan)->get_value(name);
}
- float get_tx_gain(size_t chan){
- return _tx_gain_group(chan)->get_value();
+ gain_range_t get_tx_gain_range(const std::string &name, size_t chan){
+ return _tx_gain_group(chan)->get_range(name);
}
- gain_range_t get_tx_gain_range(size_t chan){
- return _tx_gain_group(chan)->get_range();
+ std::vector<std::string> get_tx_gain_names(size_t chan){
+ return _tx_gain_group(chan)->get_names();
}
void set_tx_antenna(const std::string &ant, size_t chan){