diff options
author | michael-west <michael.west@ettus.com> | 2021-11-04 13:53:20 -0700 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-11-17 14:04:34 -0800 |
commit | 9b78da222fb5e51c1ad9ccd6887d1cf85c4c7926 (patch) | |
tree | 2014c004d639a86d03504f89630c78d8333d2973 /host | |
parent | 43ab4c8b43d8407fc9f345ca4b13634f03ad4a43 (diff) | |
download | uhd-9b78da222fb5e51c1ad9ccd6887d1cf85c4c7926.tar.gz uhd-9b78da222fb5e51c1ad9ccd6887d1cf85c4c7926.tar.bz2 uhd-9b78da222fb5e51c1ad9ccd6887d1cf85c4c7926.zip |
host: Add ability to get time from Radio block
Add API calls to Radio control to get ticks and time.
Signed-off-by: michael-west <michael.west@ettus.com>
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/rfnoc/radio_control.hpp | 14 | ||||
-rw-r--r-- | host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp | 10 | ||||
-rw-r--r-- | host/lib/rfnoc/radio_control_impl.cpp | 20 |
3 files changed, 43 insertions, 1 deletions
diff --git a/host/include/uhd/rfnoc/radio_control.hpp b/host/include/uhd/rfnoc/radio_control.hpp index ffa9b64fe..ab30be02c 100644 --- a/host/include/uhd/rfnoc/radio_control.hpp +++ b/host/include/uhd/rfnoc/radio_control.hpp @@ -65,6 +65,20 @@ public: virtual size_t get_spc() const = 0; /************************************************************************** + * Time-Related API Calls + *************************************************************************/ + /*! Get tick count + * \returns tick count + * \throws uhd::not_implemented_error if not implemented + */ + virtual uint64_t get_ticks_now() = 0; + /*! Get the time + * \returns time now + * \throws uhd::not_implemented_error if not implemented + */ + virtual uhd::time_spec_t get_time_now() = 0; + + /************************************************************************** * RF-Related API Calls *************************************************************************/ /*! Return a list of TX gain profiles for this radio diff --git a/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp b/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp index 0ff0e9b12..b60b0f2a2 100644 --- a/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp +++ b/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp @@ -59,6 +59,12 @@ public: size_t get_spc() const override; /************************************************************************** + * Time-Related API Calls + *************************************************************************/ + uint64_t get_ticks_now() override; + uhd::time_spec_t get_time_now() override; + + /************************************************************************** * RF-specific API calls *************************************************************************/ // Setters @@ -209,6 +215,10 @@ public: { static const uint32_t REG_COMPAT_NUM = 0x00; // Compatibility number register offset + static const uint32_t REG_TIME_LO = + 0x04; // Time lower bits + static const uint32_t REG_TIME_HI = + 0x08; // Time upper bits static const uint32_t REG_RADIO_WIDTH = 0x1000 + 0x04; // Upper 16 bits is sample width, lower 16 bits is NSPC diff --git a/host/lib/rfnoc/radio_control_impl.cpp b/host/lib/rfnoc/radio_control_impl.cpp index c9b9b6bfe..53117176b 100644 --- a/host/lib/rfnoc/radio_control_impl.cpp +++ b/host/lib/rfnoc/radio_control_impl.cpp @@ -26,7 +26,7 @@ const std::string radio_control::ALL_LOS = "all"; const std::string radio_control::ALL_GAINS = ""; const uint16_t radio_control_impl::MAJOR_COMPAT = 0; -const uint16_t radio_control_impl::MINOR_COMPAT = 0; +const uint16_t radio_control_impl::MINOR_COMPAT = 1; const uint32_t radio_control_impl::regmap::REG_COMPAT_NUM; const uint32_t radio_control_impl::regmap::REG_RADIO_WIDTH; @@ -294,6 +294,24 @@ size_t radio_control_impl::get_spc() const return _spc; } + +/****************************************************************************** + * Time-Related API Calls + *****************************************************************************/ +uint64_t radio_control_impl::get_ticks_now() +{ + // Time registers added in 0.1 + if (_fpga_compat < 1) { + throw uhd::not_implemented_error("Radio does not support time readback"); + } + return regs().peek64(regmap::REG_TIME_LO); +} + +uhd::time_spec_t radio_control_impl::get_time_now() +{ + return uhd::time_spec_t::from_ticks(get_ticks_now(), get_rate()); +} + /**************************************************************************** * RF API ***************************************************************************/ |