diff --git a/host/umsel2_ctrl.cpp b/host/umsel2_ctrl.cpp index ac525998..18ef97d0 100644 --- a/host/umsel2_ctrl.cpp +++ b/host/umsel2_ctrl.cpp @@ -22,8 +22,6 @@ #include #include -static const bool verbose = true; - static const int REG0_NVALUE_SHIFT = 4; static const int REG0_NVALUE_MASK = 0xffff; static const int REG0_PRESCALER_SHIFT = 20; @@ -108,8 +106,8 @@ class umsel2_ctrl_impl : public umsel2_ctrl { public: - umsel2_ctrl_impl(uhd::wb_iface::sptr ctrl, uhd::spi_iface::sptr spiface, const double ref_clock): - _ctrl(ctrl), _spiface(spiface), _ref_clock(ref_clock) + umsel2_ctrl_impl(uhd::wb_iface::sptr ctrl, uhd::spi_iface::sptr spiface, const double ref_clock, const bool verbose): + _ctrl(ctrl), _spiface(spiface), _ref_clock(ref_clock), verbose(verbose) { this->init_synth(SPI_SS_AUX1); this->init_synth(SPI_SS_AUX2); @@ -471,9 +469,10 @@ private: uhd::spi_iface::sptr _spiface; const double _ref_clock; std::map > _regs; + const bool verbose; }; -umsel2_ctrl::sptr umsel2_ctrl::make(uhd::wb_iface::sptr ctrl, uhd::spi_iface::sptr spiface, const double ref_clock) +umsel2_ctrl::sptr umsel2_ctrl::make(uhd::wb_iface::sptr ctrl, uhd::spi_iface::sptr spiface, const double ref_clock, const bool verbose) { - return umsel2_ctrl::sptr(new umsel2_ctrl_impl(ctrl, spiface, ref_clock)); + return umsel2_ctrl::sptr(new umsel2_ctrl_impl(ctrl, spiface, ref_clock, verbose)); } diff --git a/host/umsel2_ctrl.hpp b/host/umsel2_ctrl.hpp index feaac365..d903370a 100644 --- a/host/umsel2_ctrl.hpp +++ b/host/umsel2_ctrl.hpp @@ -35,7 +35,7 @@ class umsel2_ctrl public: typedef boost::shared_ptr sptr; - static sptr make(uhd::wb_iface::sptr ctrl, uhd::spi_iface::sptr spiface, const double ref_clock); + static sptr make(uhd::wb_iface::sptr ctrl, uhd::spi_iface::sptr spiface, const double ref_clock, const bool verbose); /*! * Query the tune range. diff --git a/host/umtrx_impl.cpp b/host/umtrx_impl.cpp index f894dbc6..db02f567 100644 --- a/host/umtrx_impl.cpp +++ b/host/umtrx_impl.cpp @@ -273,9 +273,13 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr) //////////////////////////////////////////////////////////////////////// // setup umsel2 control when present //////////////////////////////////////////////////////////////////////// - //TODO delect umsel2 and setup _umsel2 sptr... - //will be null when not available - _umsel2 = umsel2_ctrl::make(_ctrl/*peek*/, _ctrl/*spi*/, this->get_master_clock_rate()); + const std::string detect_umsel = device_addr.get("umsel", "off"); + if (detect_umsel != "off") + { + //TODO delect umsel2 automatically with I2C communication + const bool umsel_verbose = device_addr.has_key("umsel_verbose"); + _umsel2 = umsel2_ctrl::make(_ctrl/*peek*/, _ctrl/*spi*/, this->get_master_clock_rate(), umsel_verbose); + } //register lock detect for umsel2 if (_umsel2)