From 18abd4dbbf29ec9372bdd2ee83288fc94c20534c Mon Sep 17 00:00:00 2001
From: Josh Blum <josh@joshknows.com>
Date: Tue, 15 Nov 2011 16:22:18 -0800
Subject: uhd: support for applying cal corrections B100

---
 host/lib/usrp/b100/b100_impl.cpp | 21 +++++++++++++++++++++
 host/lib/usrp/b100/b100_impl.hpp |  2 ++
 2 files changed, 23 insertions(+)

(limited to 'host/lib/usrp/b100')

diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp
index 067fe8d47..7674a0fcf 100644
--- a/host/lib/usrp/b100/b100_impl.cpp
+++ b/host/lib/usrp/b100/b100_impl.cpp
@@ -15,6 +15,7 @@
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
+#include "apply_corrections.hpp"
 #include "b100_impl.hpp"
 #include "b100_ctrl.hpp"
 #include "fpga_regs_standard.h"
@@ -408,6 +409,18 @@ b100_impl::b100_impl(const device_addr_t &device_addr){
         _dboard_iface, _tree->subtree(mb_path / "dboards/A")
     );
 
+    //bind frontend corrections to the dboard freq props
+    const fs_path db_tx_fe_path = mb_path / "dboards" / "A" / "tx_frontends";
+    BOOST_FOREACH(const std::string &name, _tree->list(db_tx_fe_path)){
+        _tree->access<double>(db_tx_fe_path / name / "freq" / "value")
+            .subscribe(boost::bind(&b100_impl::set_tx_fe_corrections, this, _1));
+    }
+    const fs_path db_rx_fe_path = mb_path / "dboards" / "A" / "rx_frontends";
+    BOOST_FOREACH(const std::string &name, _tree->list(db_rx_fe_path)){
+        _tree->access<double>(db_rx_fe_path / name / "freq" / "value")
+            .subscribe(boost::bind(&b100_impl::set_rx_fe_corrections, this, _1));
+    }
+
     //initialize io handling
     this->io_init();
 
@@ -501,3 +514,11 @@ sensor_value_t b100_impl::get_ref_locked(void){
     const bool lock = _clock_ctrl->get_locked();
     return sensor_value_t("Ref", lock, "locked", "unlocked");
 }
+
+void b100_impl::set_rx_fe_corrections(const double lo_freq){
+    apply_rx_fe_corrections(this->get_tree()->subtree("/mboards/0"), "A", lo_freq);
+}
+
+void b100_impl::set_tx_fe_corrections(const double lo_freq){
+    apply_tx_fe_corrections(this->get_tree()->subtree("/mboards/0"), "A", lo_freq);
+}
diff --git a/host/lib/usrp/b100/b100_impl.hpp b/host/lib/usrp/b100/b100_impl.hpp
index 0984260be..96d90b14c 100644
--- a/host/lib/usrp/b100/b100_impl.hpp
+++ b/host/lib/usrp/b100/b100_impl.hpp
@@ -125,6 +125,8 @@ private:
     void clear_fpga_fifo(void);
     void handle_async_message(uhd::transport::managed_recv_buffer::sptr);
     uhd::sensor_value_t get_ref_locked(void);
+    void set_rx_fe_corrections(const double);
+    void set_tx_fe_corrections(const double);
 };
 
 #endif /* INCLUDED_b100_IMPL_HPP */
-- 
cgit v1.2.3