diff options
Diffstat (limited to 'host')
| -rw-r--r-- | host/lib/usrp/b200/b200_impl.cpp | 39 | ||||
| -rw-r--r-- | host/lib/usrp/b200/b200_impl.hpp | 2 | 
2 files changed, 31 insertions, 10 deletions
| diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index ed685d536..6de161e87 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -301,6 +301,7 @@ b200_impl::b200_impl(      _revision(0)      , _enable_user_regs(device_addr.has_key("enable_user_regs"))      , _time_source(UNKNOWN) +    , _time_set_with_pps(false)      , _tick_rate(0.0) // Forces a clock initialization at startup  {      _tree                 = property_tree::make(); @@ -715,11 +716,9 @@ b200_impl::b200_impl(      _tree->create<time_spec_t>(mb_path / "time" / "pps")          .set_publisher(              std::bind(&time_core_3000::get_time_last_pps, _radio_perifs[0].time64)); -    for (radio_perifs_t& perif : _radio_perifs) { -        _tree->access<time_spec_t>(mb_path / "time" / "pps") -            .add_coerced_subscriber(std::bind( -                &time_core_3000::set_time_next_pps, perif.time64, std::placeholders::_1)); -    } +    _tree->access<time_spec_t>(mb_path / "time" / "pps") +        .add_coerced_subscriber(std::bind( +            &b200_impl::set_time_next_pps, this, std::placeholders::_1));      // setup time source props      const std::vector<std::string> time_sources = @@ -1305,11 +1304,28 @@ void b200_impl::set_time(const uhd::time_spec_t& t)          perif.time64->set_time_sync(t);      _local_ctrl->poke32(TOREG(SR_CORE_SYNC), 1 << 2 | uint32_t(_time_source));      _local_ctrl->poke32(TOREG(SR_CORE_SYNC), _time_source); +    _time_set_with_pps = false; +} + +void b200_impl::set_time_next_pps(const uhd::time_spec_t& t) +{ +    for (radio_perifs_t& perif : _radio_perifs) +        perif.time64->set_time_next_pps(t); +    _time_set_with_pps = true;  }  void b200_impl::sync_times()  { -    set_time(_radio_perifs[0].time64->get_time_now()); +    if (_time_set_with_pps) { +        UHD_LOG_DEBUG("B200", "Re-synchronizing time using PPS"); +        uhd::time_spec_t time_last_pps = _radio_perifs[0].time64->get_time_last_pps(); +        while (_radio_perifs[0].time64->get_time_last_pps() == time_last_pps) { +            std::this_thread::sleep_for(std::chrono::milliseconds(1)); +        } +        set_time_next_pps(time_last_pps + 2.0); +    } else { +        set_time(_radio_perifs[0].time64->get_time_now()); +    }  }  /*********************************************************************** @@ -1443,7 +1459,7 @@ void b200_impl::update_enables(void)                           and bool(_radio_perifs[_fe2].rx_streamer.lock());      const size_t num_rx = (enb_rx1 ? 1 : 0) + (enb_rx2 ? 1 : 0);      const size_t num_tx = (enb_tx1 ? 1 : 0) + (enb_tx2 ? 1 : 0); -    const bool mimo     = num_rx == 2 or num_tx == 2; +    const uint32_t mimo = (num_rx == 2 or num_tx == 2) ? 1 : 0;      if ((num_rx + num_tx) == 3) {          throw uhd::runtime_error( @@ -1455,9 +1471,12 @@ void b200_impl::update_enables(void)      if ((num_rx + num_tx) == 0)          _codec_ctrl->set_active_chains(true, false, true, false); // enable something -    // figure out if mimo is enabled based on new state -    _gpio_state.mimo = (mimo) ? 1 : 0; -    update_gpio_state(); +    // update MIMO state and re-sync times if necessary +    if (_gpio_state.mimo != mimo) { +        _gpio_state.mimo = mimo; +        update_gpio_state(); +        sync_times(); +    }      // atrs change based on enables      this->update_atrs(); diff --git a/host/lib/usrp/b200/b200_impl.hpp b/host/lib/usrp/b200/b200_impl.hpp index b280bcc87..11bfa112a 100644 --- a/host/lib/usrp/b200/b200_impl.hpp +++ b/host/lib/usrp/b200/b200_impl.hpp @@ -182,6 +182,7 @@ private:      void update_subdev_spec(const std::string& tx_rx, const uhd::usrp::subdev_spec_t&);      void update_time_source(const std::string&);      void set_time(const uhd::time_spec_t&); +    void set_time_next_pps(const uhd::time_spec_t&);      void sync_times(void);      void update_clock_source(const std::string&);      void update_bandsel(const std::string& which, double freq); @@ -248,6 +249,7 @@ private:          NONE     = 3,          UNKNOWN  = 4      } _time_source; +    bool _time_set_with_pps;      void update_gpio_state(void); | 
