From c2122833e25ffe6e8e6918874afe7a3c9a92bc87 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 27 Sep 2011 13:24:17 -0700 Subject: e100: added ref locked sensor for clock reference --- host/lib/usrp/e100/clock_ctrl.cpp | 10 ++++++++++ host/lib/usrp/e100/clock_ctrl.hpp | 3 +++ host/lib/usrp/e100/e100_impl.cpp | 9 +++++++-- host/lib/usrp/e100/e100_impl.hpp | 2 ++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/host/lib/usrp/e100/clock_ctrl.cpp b/host/lib/usrp/e100/clock_ctrl.cpp index 0eb9eef8e..1dd55049b 100644 --- a/host/lib/usrp/e100/clock_ctrl.cpp +++ b/host/lib/usrp/e100/clock_ctrl.cpp @@ -432,6 +432,16 @@ public: this->latch_regs(); } + bool get_locked(void){ + static const boost::uint8_t addr = 0x01F; + boost::uint32_t reg = _iface->read_spi( + UE_SPI_SS_AD9522, spi_config_t::EDGE_RISE, + _ad9522_regs.get_read_reg(addr), 24 + ); + _ad9522_regs.set_reg(addr, reg); + return _ad9522_regs.digital_lock_detect != 0; + } + private: spi_iface::sptr _iface; const bool _dboard_clocks_diff; diff --git a/host/lib/usrp/e100/clock_ctrl.hpp b/host/lib/usrp/e100/clock_ctrl.hpp index 538ea65d8..803265556 100644 --- a/host/lib/usrp/e100/clock_ctrl.hpp +++ b/host/lib/usrp/e100/clock_ctrl.hpp @@ -119,6 +119,9 @@ public: */ virtual void use_auto_ref(void) = 0; + //! Is the reference locked? + virtual bool get_locked(void) = 0; + }; #endif /* INCLUDED_USRP_E100_CLOCK_CTRL_HPP */ diff --git a/host/lib/usrp/e100/e100_impl.cpp b/host/lib/usrp/e100/e100_impl.cpp index b80ee0836..b988de9a1 100644 --- a/host/lib/usrp/e100/e100_impl.cpp +++ b/host/lib/usrp/e100/e100_impl.cpp @@ -226,8 +226,8 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ //////////////////////////////////////////////////////////////////// // and do the misc mboard sensors //////////////////////////////////////////////////////////////////// - //none for now... - _tree->create(mb_path / "sensors"); //phony property so this dir exists + _tree->create(mb_path / "sensors/ref_locked") + .publish(boost::bind(&e100_impl::get_ref_locked, this)); //////////////////////////////////////////////////////////////////// // create frontend control objects @@ -406,3 +406,8 @@ void e100_impl::update_clock_source(const std::string &source){ else if (source == "external") _clock_ctrl->use_external_ref(); else throw uhd::runtime_error("unhandled clock configuration reference source: " + source); } + +sensor_value_t e100_impl::get_ref_locked(void){ + const bool lock = _clock_ctrl->get_locked(); + return sensor_value_t("Ref", lock, "locked", "unlocked"); +} diff --git a/host/lib/usrp/e100/e100_impl.hpp b/host/lib/usrp/e100/e100_impl.hpp index a15197545..99c8481e3 100644 --- a/host/lib/usrp/e100/e100_impl.hpp +++ b/host/lib/usrp/e100/e100_impl.hpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -124,6 +125,7 @@ private: void update_rx_subdev_spec(const uhd::usrp::subdev_spec_t &); void update_tx_subdev_spec(const uhd::usrp::subdev_spec_t &); void update_clock_source(const std::string &); + uhd::sensor_value_t get_ref_locked(void); }; -- cgit v1.2.3