From dbb201e7275ff6e63bac9a749db3ee2c4f1c6418 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 11 Jul 2019 16:49:12 -0700 Subject: sbx: Only update ATRs when lock state changes The SBX tracks the LO lock state via on-board LEDs. However, querying the LO lock status spawns an update to the entire ATR registers. To reduce the number of register reads/writes, the LO lock status LED is now only updated if it changed. --- host/lib/usrp/dboard/db_sbx_common.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/host/lib/usrp/dboard/db_sbx_common.cpp b/host/lib/usrp/dboard/db_sbx_common.cpp index 585e4ba6b..b6eaedc3d 100644 --- a/host/lib/usrp/dboard/db_sbx_common.cpp +++ b/host/lib/usrp/dboard/db_sbx_common.cpp @@ -330,12 +330,14 @@ double sbx_xcvr::set_lo_freq(dboard_iface::unit_t unit, double target_freq) { sensor_value_t sbx_xcvr::get_locked(dboard_iface::unit_t unit) { const bool locked = (this->get_iface()->read_gpio(unit) & LOCKDET_MASK) != 0; + bool& lock_cache = (unit == dboard_iface::UNIT_RX) ? _rx_lo_lock_cache + : _tx_lo_lock_cache; - if (unit == dboard_iface::UNIT_RX) _rx_lo_lock_cache = locked; - if (unit == dboard_iface::UNIT_TX) _tx_lo_lock_cache = locked; - - //write the new lock cache setting to atr regs - update_atr(); + if (lock_cache != locked) { + lock_cache = locked; + // write the new lock cache setting to atr regs + update_atr(); + } return sensor_value_t("LO", locked, "locked", "unlocked"); } -- cgit v1.2.3