diff options
| author | Derek Kozel <derek.kozel@ettus.com> | 2018-07-10 16:51:14 +0000 | 
|---|---|---|
| committer | Martin Braun <martin.braun@ettus.com> | 2018-07-11 10:12:03 -0700 | 
| commit | b39358f490a24ffe4b8b29227736b8d2eb40b956 (patch) | |
| tree | 57ae22193cd0a9ee95c8b3f73d938b167b1c6675 /host/lib | |
| parent | b185c9447a4a33bff14fd697dc294b9ee5d298b3 (diff) | |
| download | uhd-b39358f490a24ffe4b8b29227736b8d2eb40b956.tar.gz uhd-b39358f490a24ffe4b8b29227736b8d2eb40b956.tar.bz2 uhd-b39358f490a24ffe4b8b29227736b8d2eb40b956.zip  | |
uhd: Expose DC Offset range via multi_usrp interface
Diffstat (limited to 'host/lib')
| -rw-r--r-- | host/lib/usrp/cores/rx_frontend_core_200.cpp | 9 | ||||
| -rw-r--r-- | host/lib/usrp/cores/rx_frontend_core_3000.cpp | 9 | ||||
| -rw-r--r-- | host/lib/usrp/cores/tx_frontend_core_200.cpp | 9 | ||||
| -rw-r--r-- | host/lib/usrp/multi_usrp.cpp | 18 | 
4 files changed, 45 insertions, 0 deletions
diff --git a/host/lib/usrp/cores/rx_frontend_core_200.cpp b/host/lib/usrp/cores/rx_frontend_core_200.cpp index 38710db15..f0556e4b0 100644 --- a/host/lib/usrp/cores/rx_frontend_core_200.cpp +++ b/host/lib/usrp/cores/rx_frontend_core_200.cpp @@ -6,6 +6,7 @@  //  #include <uhdlib/usrp/cores/rx_frontend_core_200.hpp> +#include <uhd/types/ranges.hpp>  #include <boost/math/special_functions/round.hpp>  #include <boost/bind.hpp> @@ -21,6 +22,11 @@ using namespace uhd;  #define OFFSET_SET   (1ul << 30)  #define FLAG_MASK (OFFSET_FIXED | OFFSET_SET) +namespace { +  static const double DC_OFFSET_MIN = -1.0; +  static const double DC_OFFSET_MAX = 1.0; +} +  static uint32_t fs_to_bits(const double num, const size_t bits){      return int32_t(boost::math::round(num * (1 << (bits-1))));  } @@ -71,6 +77,9 @@ public:      void populate_subtree(uhd::property_tree::sptr subtree)      { +        subtree->create<uhd::meta_range_t>("dc_offset/range") +            .set(meta_range_t(DC_OFFSET_MIN, DC_OFFSET_MAX)) +        ;          subtree->create<std::complex<double> >("dc_offset/value")              .set(DEFAULT_DC_OFFSET_VALUE)              .set_coercer(boost::bind(&rx_frontend_core_200::set_dc_offset, this, _1)) diff --git a/host/lib/usrp/cores/rx_frontend_core_3000.cpp b/host/lib/usrp/cores/rx_frontend_core_3000.cpp index cf1a105d8..841a72d9b 100644 --- a/host/lib/usrp/cores/rx_frontend_core_3000.cpp +++ b/host/lib/usrp/cores/rx_frontend_core_3000.cpp @@ -6,6 +6,7 @@  //  #include <uhd/types/dict.hpp> +#include <uhd/types/ranges.hpp>  #include <uhdlib/usrp/cores/rx_frontend_core_3000.hpp>  #include <uhdlib/usrp/cores/dsp_core_utils.hpp>  #include <boost/math/special_functions/round.hpp> @@ -34,6 +35,11 @@ using namespace uhd;  #define OFFSET_SET   (1ul << 30)  #define FLAG_MASK (OFFSET_FIXED | OFFSET_SET) +namespace { +    static const double DC_OFFSET_MIN = -1.0; +    static const double DC_OFFSET_MAX = 1.0; +} +  using namespace uhd::usrp;  static uint32_t fs_to_bits(const double num, const size_t bits){ @@ -138,6 +144,9 @@ public:      }      void populate_subtree(uhd::property_tree::sptr subtree) { +        subtree->create<uhd::meta_range_t>("dc_offset/range") +                .set(meta_range_t(DC_OFFSET_MIN, DC_OFFSET_MAX)) +        ;          subtree->create<std::complex<double> >("dc_offset/value")              .set(DEFAULT_DC_OFFSET_VALUE)              .set_coercer(boost::bind(&rx_frontend_core_3000::set_dc_offset, this, _1)) diff --git a/host/lib/usrp/cores/tx_frontend_core_200.cpp b/host/lib/usrp/cores/tx_frontend_core_200.cpp index 7e23e2515..d44a618bc 100644 --- a/host/lib/usrp/cores/tx_frontend_core_200.cpp +++ b/host/lib/usrp/cores/tx_frontend_core_200.cpp @@ -7,6 +7,7 @@  #include <uhdlib/usrp/cores/tx_frontend_core_200.hpp>  #include <uhd/types/dict.hpp> +#include <uhd/types/ranges.hpp>  #include <uhd/exception.hpp>  #include <boost/assign/list_of.hpp>  #include <boost/math/special_functions/round.hpp> @@ -23,6 +24,11 @@ using namespace uhd;  const std::complex<double> tx_frontend_core_200::DEFAULT_DC_OFFSET_VALUE = std::complex<double>(0.0, 0.0);  const std::complex<double> tx_frontend_core_200::DEFAULT_IQ_BALANCE_VALUE = std::complex<double>(0.0, 0.0); +namespace { +  static const double DC_OFFSET_MIN = -1.0; +  static const double DC_OFFSET_MAX = 1.0; +} +  static uint32_t fs_to_bits(const double num, const size_t bits){      return int32_t(boost::math::round(num * (1 << (bits-1))));  } @@ -67,6 +73,9 @@ public:      void populate_subtree(uhd::property_tree::sptr subtree)      { +        subtree->create<uhd::meta_range_t>("dc_offset/range") +            .set(meta_range_t(DC_OFFSET_MIN, DC_OFFSET_MAX)) +        ;          subtree->create< std::complex<double> >("dc_offset/value")              .set(DEFAULT_DC_OFFSET_VALUE)              .set_coercer(boost::bind(&tx_frontend_core_200::set_dc_offset, this, _1)) diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 48da5023b..1d8a0fd7a 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -1541,6 +1541,15 @@ public:          }      } +    meta_range_t get_rx_dc_offset_range(size_t chan) { +        if (_tree->exists(rx_fe_root(chan) / "dc_offset" / "range")) { +            return _tree->access<uhd::meta_range_t>(rx_fe_root(chan) / "dc_offset" / "range").get(); +        } else { +            UHD_LOGGER_WARNING("MULTI_USRP") << "This device does not support querying the RX DC offset range." ; +            return meta_range_t(0, 0); +        } +    } +      void set_rx_iq_balance(const bool enb, size_t chan){          if (chan != ALL_CHANS){              if (_tree->exists(rx_rf_fe_root(chan) / "iq_balance" / "enable")) { @@ -1912,6 +1921,15 @@ public:          }      } +    meta_range_t get_tx_dc_offset_range(size_t chan) { +        if (_tree->exists(tx_fe_root(chan) / "dc_offset" / "range")) { +            return _tree->access<uhd::meta_range_t>(tx_fe_root(chan) / "dc_offset" / "range").get(); +        } else { +            UHD_LOGGER_WARNING("MULTI_USRP") << "This device does not support querying the TX DC offset range." ; +            return meta_range_t(0, 0); +        } +    } +      void set_tx_iq_balance(const std::complex<double> &offset, size_t chan){          if (chan != ALL_CHANS){              if (_tree->exists(tx_fe_root(chan) / "iq_balance" / "value")) {  | 
