aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulian Arnold <julian.arnold@ettus.com>2015-03-05 15:24:46 -0800
committerMartin Braun <martin.braun@ettus.com>2015-03-05 17:18:54 -0800
commit33edac343488fdd87337e308b277adca69f16819 (patch)
tree8f89e8b663f2dc3dd2c2fbaabf5e018622bcf9b0
parentb8815805372feef40b9254a320e091a40c65377e (diff)
downloaduhd-33edac343488fdd87337e308b277adca69f16819.tar.gz
uhd-33edac343488fdd87337e308b277adca69f16819.tar.bz2
uhd-33edac343488fdd87337e308b277adca69f16819.zip
uhd: AGC support
-rw-r--r--host/include/uhd/usrp/multi_usrp.hpp10
-rw-r--r--host/lib/usrp/multi_usrp.cpp36
2 files changed, 46 insertions, 0 deletions
diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp
index 8357b9ffb..e8fcdb4b6 100644
--- a/host/include/uhd/usrp/multi_usrp.hpp
+++ b/host/include/uhd/usrp/multi_usrp.hpp
@@ -514,6 +514,16 @@ public:
virtual void set_normalized_rx_gain(double gain, size_t chan = 0) = 0;
/*!
+ * Enable or disable the RX AGC module.
+ * Once this module is enabled manual gain settings will be ignored.
+ * The AGC will start in a default configuration which should be good for most use cases.
+ * Device specific configuration parameters can be found in the property tree.
+ * \param on Enable or Disable the AGC
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_rx_agc(bool enable, size_t chan = 0) = 0;
+
+ /*!
* 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
diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp
index e7d39b244..bc6e121d0 100644
--- a/host/lib/usrp/multi_usrp.cpp
+++ b/host/lib/usrp/multi_usrp.cpp
@@ -824,6 +824,26 @@ public:
}
void set_rx_gain(double gain, const std::string &name, size_t chan){
+ /* Check if any AGC mode is enable and if so warn the user */
+ if (chan != ALL_CHANS) {
+ if (_tree->exists(rx_rf_fe_root(chan) / "gain" / "agc")) {
+ bool agc = _tree->access<bool>(rx_rf_fe_root(chan) / "gain" / "agc" / "enable").get();
+ if(agc) {
+ UHD_MSG(warning) << "AGC enabled for this channel. Setting will be ignored." << std::endl;
+ }
+ }
+ } else {
+ for (size_t c = 0; c < get_rx_num_channels(); c++){
+ if (_tree->exists(rx_rf_fe_root(c) / "gain" / "agc")) {
+ bool agc = _tree->access<bool>(rx_rf_fe_root(chan) / "gain" / "agc" / "enable").get();
+ if(agc) {
+ UHD_MSG(warning) << "AGC enabled for this channel. Setting will be ignored." << std::endl;
+ }
+ }
+ }
+ }
+ /* Apply gain setting.
+ * If device is in AGC mode it will ignore the setting. */
try {
return rx_gain_group(chan)->set_value(gain, name);
} catch (uhd::key_error &e) {
@@ -841,6 +861,22 @@ public:
set_rx_gain(abs_gain, ALL_GAINS, chan);
}
+ void set_rx_agc(bool enable, size_t chan = 0)
+ {
+ if (chan != ALL_CHANS){
+ if (_tree->exists(rx_rf_fe_root(chan) / "gain" / "agc" / "enable")) {
+ _tree->access<bool>(rx_rf_fe_root(chan) / "gain" / "agc" / "enable").set(enable);
+ } else {
+ UHD_MSG(warning) << "AGC is not available on this device." << std::endl;
+ }
+ return;
+ }
+ for (size_t c = 0; c < get_rx_num_channels(); c++){
+ this->set_rx_agc(enable, c);
+ }
+
+ }
+
double get_rx_gain(const std::string &name, size_t chan){
try {
return rx_gain_group(chan)->get_value(name);