From 80dbdef7305da9028ba3747e79774dbb158a5d55 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 9 Oct 2011 20:28:48 -0700 Subject: b100: add reference lock sensor --- host/lib/usrp/b100/b100_impl.cpp | 9 +++++++-- host/lib/usrp/b100/b100_impl.hpp | 2 ++ host/lib/usrp/b100/clock_ctrl.cpp | 7 +++++++ host/lib/usrp/b100/clock_ctrl.hpp | 3 +++ 4 files changed, 19 insertions(+), 2 deletions(-) (limited to 'host/lib/usrp') diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index 5e36a19dd..591a8b49f 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -275,8 +275,8 @@ b100_impl::b100_impl(const 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(&b100_impl::get_ref_locked, this)); //////////////////////////////////////////////////////////////////// // create frontend control objects @@ -491,3 +491,8 @@ void b100_impl::enable_gpif(const bool en) { void b100_impl::clear_fpga_fifo(void) { _fx2_ctrl->usrp_control_write(VRQ_CLEAR_FPGA_FIFO, 0, 0, 0, 0); } + +sensor_value_t b100_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/b100/b100_impl.hpp b/host/lib/usrp/b100/b100_impl.hpp index c9acb17d4..5ec3dde7b 100644 --- a/host/lib/usrp/b100/b100_impl.hpp +++ b/host/lib/usrp/b100/b100_impl.hpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -129,6 +130,7 @@ private: void enable_gpif(const bool); void clear_fpga_fifo(void); void handle_async_message(uhd::transport::managed_recv_buffer::sptr); + uhd::sensor_value_t get_ref_locked(void); }; #endif /* INCLUDED_b100_IMPL_HPP */ diff --git a/host/lib/usrp/b100/clock_ctrl.cpp b/host/lib/usrp/b100/clock_ctrl.cpp index df1442420..fd398abff 100644 --- a/host/lib/usrp/b100/clock_ctrl.cpp +++ b/host/lib/usrp/b100/clock_ctrl.cpp @@ -428,6 +428,13 @@ public: this->latch_regs(); } + bool get_locked(void){ + static const boost::uint8_t addr = 0x01F; + boost::uint32_t reg = this->read_reg(addr); + _ad9522_regs.set_reg(addr, reg); + return _ad9522_regs.digital_lock_detect != 0; + } + private: i2c_iface::sptr _iface; ad9522_regs_t _ad9522_regs; diff --git a/host/lib/usrp/b100/clock_ctrl.hpp b/host/lib/usrp/b100/clock_ctrl.hpp index 68c24bdce..387892bf7 100644 --- a/host/lib/usrp/b100/clock_ctrl.hpp +++ b/host/lib/usrp/b100/clock_ctrl.hpp @@ -125,6 +125,9 @@ public: */ virtual void use_auto_ref(void) = 0; + //! Is the reference locked? + virtual bool get_locked(void) = 0; + }; #endif /* INCLUDED_B100_CLOCK_CTRL_HPP */ -- cgit v1.2.3