aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Meserve <mark.meserve@ni.com>2019-04-24 16:03:21 -0500
committerMartin Braun <martin.braun@ettus.com>2019-05-02 14:36:21 -0700
commit5645c3117a9377685182f0cdd45090428d65e576 (patch)
treebfbc6b58b6046205bb0d892860446c3b001e59ac
parentb2dd1655de5e9f60cf65918354f25d0e4e62e241 (diff)
downloaduhd-5645c3117a9377685182f0cdd45090428d65e576.tar.gz
uhd-5645c3117a9377685182f0cdd45090428d65e576.tar.bz2
uhd-5645c3117a9377685182f0cdd45090428d65e576.zip
adf435x: add charge pump with double parameter
-rw-r--r--host/lib/include/uhdlib/usrp/common/adf435x.hpp34
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");