diff options
author | michael-west <michael.west@ettus.com> | 2015-10-07 13:10:01 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2015-12-10 14:21:49 -0800 |
commit | f90b62f3871fb701a8d9cb7c91c1a7f3421fced9 (patch) | |
tree | 85d85ed9be444df4348e397bdaa707cfbb5d4597 /host/lib/usrp | |
parent | 21df150ec873f15c4e85f9564b56586e3fe2afcf (diff) | |
download | uhd-f90b62f3871fb701a8d9cb7c91c1a7f3421fced9.tar.gz uhd-f90b62f3871fb701a8d9cb7c91c1a7f3421fced9.tar.bz2 uhd-f90b62f3871fb701a8d9cb7c91c1a7f3421fced9.zip |
B210: Add VITA time synchronization on internal signal
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/b200/b200_impl.cpp | 22 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_impl.hpp | 1 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_regs.hpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/cores/time_core_3000.cpp | 13 | ||||
-rw-r--r-- | host/lib/usrp/cores/time_core_3000.hpp | 2 |
5 files changed, 30 insertions, 10 deletions
diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index ffce08567..a18e595a6 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -555,7 +555,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s client_settings = boost::make_shared<b200_ad9361_client_t>(); } _codec_ctrl = ad9361_ctrl::make_spi(client_settings, _spi_iface, AD9361_SLAVENO); - + //////////////////////////////////////////////////////////////////// // create codec control objects //////////////////////////////////////////////////////////////////// @@ -623,15 +623,15 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s //register time now and pps onto available radio cores _tree->create<time_spec_t>(mb_path / "time" / "now") - .publish(boost::bind(&time_core_3000::get_time_now, _radio_perifs[0].time64)); + .publish(boost::bind(&time_core_3000::get_time_now, _radio_perifs[0].time64)) + .subscribe(boost::bind(&b200_impl::sync_times, this, _1)) + .set(0.0); _tree->create<time_spec_t>(mb_path / "time" / "pps") .publish(boost::bind(&time_core_3000::get_time_last_pps, _radio_perifs[0].time64)); - for (size_t i = 0; i < _radio_perifs.size(); i++) + BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) { - _tree->access<time_spec_t>(mb_path / "time" / "now") - .subscribe(boost::bind(&time_core_3000::set_time_now, _radio_perifs[i].time64, _1)); _tree->access<time_spec_t>(mb_path / "time" / "pps") - .subscribe(boost::bind(&time_core_3000::set_time_next_pps, _radio_perifs[i].time64, _1)); + .subscribe(boost::bind(&time_core_3000::set_time_next_pps, perif.time64, _1)); } //setup time source props @@ -1074,11 +1074,19 @@ void b200_impl::update_time_source(const std::string &source) throw uhd::key_error("update_time_source: unknown source: " + source); if (_time_source != value) { - _local_ctrl->poke32(TOREG(SR_CORE_PPS_SEL), value); + _local_ctrl->poke32(TOREG(SR_CORE_SYNC), value); _time_source = value; } } +void b200_impl::sync_times(const uhd::time_spec_t& t) +{ + BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) + perif.time64->set_time_sync(t); + _local_ctrl->poke32(TOREG(SR_CORE_SYNC), 1 << 2 | boost::uint32_t(_time_source)); + _local_ctrl->poke32(TOREG(SR_CORE_SYNC), _time_source); +} + /*********************************************************************** * GPIO setup **********************************************************************/ diff --git a/host/lib/usrp/b200/b200_impl.hpp b/host/lib/usrp/b200/b200_impl.hpp index 25fef7d4b..f052c55e6 100644 --- a/host/lib/usrp/b200/b200_impl.hpp +++ b/host/lib/usrp/b200/b200_impl.hpp @@ -167,6 +167,7 @@ private: uhd::usrp::subdev_spec_t coerce_subdev_spec(const uhd::usrp::subdev_spec_t &); void update_subdev_spec(const std::string &tx_rx, const uhd::usrp::subdev_spec_t &); void update_time_source(const std::string &); + void sync_times(const uhd::time_spec_t&); void update_clock_source(const std::string &); void update_bandsel(const std::string& which, double freq); void update_antenna_sel(const size_t which, const std::string &ant); diff --git a/host/lib/usrp/b200/b200_regs.hpp b/host/lib/usrp/b200/b200_regs.hpp index 8f2dd03f3..e9ab81bae 100644 --- a/host/lib/usrp/b200/b200_regs.hpp +++ b/host/lib/usrp/b200/b200_regs.hpp @@ -28,7 +28,7 @@ localparam SR_CORE_SPI = 8; localparam SR_CORE_MISC = 16; localparam SR_CORE_COMPAT = 24; localparam SR_CORE_GPSDO_ST = 40; -localparam SR_CORE_PPS_SEL = 48; +localparam SR_CORE_SYNC = 48; localparam RB32_CORE_SPI = 8; localparam RB32_CORE_MISC = 16; localparam RB32_CORE_STATUS = 20; diff --git a/host/lib/usrp/cores/time_core_3000.cpp b/host/lib/usrp/cores/time_core_3000.cpp index ffae5dc0d..694edf31c 100644 --- a/host/lib/usrp/cores/time_core_3000.cpp +++ b/host/lib/usrp/cores/time_core_3000.cpp @@ -24,8 +24,9 @@ #define REG_TIME_LO _base + 4 #define REG_TIME_CTRL _base + 8 -#define CTRL_LATCH_TIME_PPS (1 << 1) -#define CTRL_LATCH_TIME_NOW (1 << 0) +#define CTRL_LATCH_TIME_NOW (1 << 0) +#define CTRL_LATCH_TIME_PPS (1 << 1) +#define CTRL_LATCH_TIME_SYNC (1 << 2) using namespace uhd; @@ -99,6 +100,14 @@ struct time_core_3000_impl : time_core_3000 _iface->poke32(REG_TIME_CTRL, CTRL_LATCH_TIME_NOW); } + void set_time_sync(const uhd::time_spec_t &time) + { + const boost::uint64_t ticks = time.to_ticks(_tick_rate); + _iface->poke32(REG_TIME_HI, boost::uint32_t(ticks >> 32)); + _iface->poke32(REG_TIME_LO, boost::uint32_t(ticks >> 0)); + _iface->poke32(REG_TIME_CTRL, CTRL_LATCH_TIME_SYNC); + } + void set_time_next_pps(const uhd::time_spec_t &time) { const boost::uint64_t ticks = time.to_ticks(_tick_rate); diff --git a/host/lib/usrp/cores/time_core_3000.hpp b/host/lib/usrp/cores/time_core_3000.hpp index 7463386ba..7dde4e797 100644 --- a/host/lib/usrp/cores/time_core_3000.hpp +++ b/host/lib/usrp/cores/time_core_3000.hpp @@ -53,6 +53,8 @@ public: virtual void set_time_now(const uhd::time_spec_t &time) = 0; + virtual void set_time_sync(const uhd::time_spec_t &time) = 0; + virtual void set_time_next_pps(const uhd::time_spec_t &time) = 0; }; |