diff options
author | Ashish Chaudhari <ashish@ettus.com> | 2019-05-25 20:45:34 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:18 -0800 |
commit | efd8e88859421c0a1876cbe850536dc28a21df69 (patch) | |
tree | 0835dbc9ef27a0471581bebedcba09a74f4d3de4 /host/lib/rfnoc | |
parent | 15c058015f56cfcd0e42cf6779a6e6ef6e0da911 (diff) | |
download | uhd-efd8e88859421c0a1876cbe850536dc28a21df69.tar.gz uhd-efd8e88859421c0a1876cbe850536dc28a21df69.tar.bz2 uhd-efd8e88859421c0a1876cbe850536dc28a21df69.zip |
rfnoc: Added clock_iface to convey info about clocks
The inteface provides a mechanism for users of clocks to query
information such as the running status or rate
Diffstat (limited to 'host/lib/rfnoc')
-rw-r--r-- | host/lib/rfnoc/chdr_ctrl_endpoint.cpp | 8 | ||||
-rw-r--r-- | host/lib/rfnoc/ctrlport_endpoint.cpp | 37 |
2 files changed, 26 insertions, 19 deletions
diff --git a/host/lib/rfnoc/chdr_ctrl_endpoint.cpp b/host/lib/rfnoc/chdr_ctrl_endpoint.cpp index cab90fb49..6ded83c0f 100644 --- a/host/lib/rfnoc/chdr_ctrl_endpoint.cpp +++ b/host/lib/rfnoc/chdr_ctrl_endpoint.cpp @@ -67,8 +67,8 @@ public: virtual ctrlport_endpoint::sptr get_ctrlport_ep(uint16_t port, size_t buff_capacity, size_t max_outstanding_async_msgs, - double ctrl_clk_freq, - double timebase_freq) + const clock_iface& client_clk, + const clock_iface& timebase_clk) { std::lock_guard<std::mutex> lock(_mutex); @@ -93,8 +93,8 @@ public: port, buff_capacity, max_outstanding_async_msgs, - ctrl_clk_freq, - timebase_freq); + client_clk, + timebase_clk); _endpoint_map.insert(std::make_pair(port, ctrlport_ep)); UHD_LOG_DEBUG("RFNOC", boost::format("Created ctrlport endpoint for port %d on EPID %d") % port diff --git a/host/lib/rfnoc/ctrlport_endpoint.cpp b/host/lib/rfnoc/ctrlport_endpoint.cpp index 69f45ab9e..d5f4ef98c 100644 --- a/host/lib/rfnoc/ctrlport_endpoint.cpp +++ b/host/lib/rfnoc/ctrlport_endpoint.cpp @@ -41,15 +41,15 @@ public: uint16_t local_port, size_t buff_capacity, size_t max_outstanding_async_msgs, - double ctrl_clk_freq, - double timebase_freq) + const clock_iface& client_clk, + const clock_iface& timebase_clk) : _handle_send(send_fcn) , _my_epid(my_epid) , _local_port(local_port) , _buff_capacity(buff_capacity) , _max_outstanding_async_msgs(max_outstanding_async_msgs) - , _ctrl_clk_freq(ctrl_clk_freq) - , _timebase_freq(timebase_freq) + , _client_clk(client_clk) + , _timebase_clk(timebase_clk) { } @@ -166,7 +166,7 @@ public: // Send request auto request = send_request_packet(OP_POLL, addr, - {data, mask, static_cast<uint32_t>(timeout.get_real_secs() * _ctrl_clk_freq)}, + {data, mask, static_cast<uint32_t>(timeout.to_ticks(_client_clk.get_freq()))}, timestamp, timeout_time); // Optionally wait for an ACK @@ -182,7 +182,7 @@ public: // Send request auto request = send_request_packet(OP_SLEEP, 0, - {static_cast<uint32_t>(duration.get_real_secs() * _ctrl_clk_freq)}, + {static_cast<uint32_t>(duration.to_ticks(_client_clk.get_freq()))}, uhd::time_spec_t::ASAP, timeout_time); // Optionally wait for an ACK @@ -313,10 +313,17 @@ private: { std::unique_lock<std::mutex> lock(_mutex); + if (!_client_clk.is_running()) { + throw uhd::system_error("Ctrlport client clock is not running"); + } + // Convert from uhd::time_spec to timestamp boost::optional<uint64_t> timestamp; if (time_spec != time_spec_t::ASAP) { - timestamp = time_spec.to_ticks(_timebase_freq); + if (!_timebase_clk.is_running()) { + throw uhd::system_error("Timebase clock is not running"); + } + timestamp = time_spec.to_ticks(_timebase_clk.get_freq()); } // Assemble the control payload @@ -428,10 +435,10 @@ private: const size_t _buff_capacity; //! The max number of outstanding async messages that a block can have at any time const size_t _max_outstanding_async_msgs; - //! The clock rate of the clock that drives the ctrlport endpoint - const double _ctrl_clk_freq; - //! The clock rate of the primary timebase used for timed commands - const double _timebase_freq; + //! The clock that drives the ctrlport endpoint + const clock_iface& _client_clk; + //! The clock that drives the timing logic for the ctrlport endpoint + const clock_iface& _timebase_clk; //! The function to call to handle an async message async_msg_callback_t _handle_async_msg = async_msg_callback_t(); @@ -458,14 +465,14 @@ ctrlport_endpoint::sptr ctrlport_endpoint::make(const send_fn_t& handle_send, uint16_t local_port, size_t buff_capacity, size_t max_outstanding_async_msgs, - double ctrl_clk_freq, - double timebase_freq) + const clock_iface& client_clk, + const clock_iface& timebase_clk) { return std::make_shared<ctrlport_endpoint_impl>(handle_send, this_epid, local_port, buff_capacity, max_outstanding_async_msgs, - ctrl_clk_freq, - timebase_freq); + client_clk, + timebase_clk); } |