diff options
author | Mark Meserve <mark.meserve@ni.com> | 2019-04-24 16:03:21 -0500 |
---|---|---|
committer | michael-west <michael.west@ettus.com> | 2019-05-21 17:20:42 -0700 |
commit | 10b18d3b3e3d758a0843ea6dc31f2f00c5da1614 (patch) | |
tree | c98f0fbe3bd802d5e49a3cedbfaf07c8d599abc5 /host/lib | |
parent | 170172d101ffd83908dbba4aab9fe81400ca85d8 (diff) | |
download | uhd-10b18d3b3e3d758a0843ea6dc31f2f00c5da1614.tar.gz uhd-10b18d3b3e3d758a0843ea6dc31f2f00c5da1614.tar.bz2 uhd-10b18d3b3e3d758a0843ea6dc31f2f00c5da1614.zip |
adf435x: add charge pump with double parameter
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/include/uhdlib/usrp/common/adf435x.hpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/host/lib/include/uhdlib/usrp/common/adf435x.hpp b/host/lib/include/uhdlib/usrp/common/adf435x.hpp index f6ce26e51..e126bb896 100644 --- a/host/lib/include/uhdlib/usrp/common/adf435x.hpp +++ b/host/lib/include/uhdlib/usrp/common/adf435x.hpp @@ -81,6 +81,10 @@ public: virtual void set_charge_pump_current(charge_pump_current_t cp_current) = 0; + virtual double set_charge_pump_current(double current, bool flush = false) = 0; + + virtual uhd::meta_range_t get_charge_pump_current_range() = 0; + virtual uhd::range_t get_int_range() = 0; virtual double set_frequency(double target_freq, bool int_n_mode, bool flush = false) = 0; @@ -198,6 +202,36 @@ public: } } + double set_charge_pump_current(const double current, const bool flush) + { + const auto cp_range = get_charge_pump_current_range(); + + const auto coerced_current = cp_range.clip(current, true); + const int current_step = std::round((coerced_current / cp_range.step()) - 1); + + UHD_ASSERT_THROW(current_step >= 0 and current_step < 16); + set_charge_pump_current( + static_cast<adf435x_iface::charge_pump_current_t>(current_step)); + + if (flush) { + commit(); + } + + if (std::abs(current - coerced_current) > 0.01e-6) { + UHD_LOG_WARNING("ADF435x", + "Requested charge pump current was coerced! Requested: " + << std::setw(4) << current << " A Actual: " << coerced_current + << " A"); + } + + return coerced_current; + } + + uhd::meta_range_t get_charge_pump_current_range() + { + return uhd::meta_range_t(.3125e-6, 5e-6, .3125e-6); + } + uhd::range_t get_int_range() { if (_N_min < 0) throw uhd::runtime_error("set_prescaler must be called before get_int_range"); |