| USRP Hardware Driver and Device Manual Version: 4.10.0.0 UHD and USRP Manual |

Loading...
Searching...
No Matches
register_iface.hpp
Go to the documentation of this file.
1//
2// Copyright 2019 Ettus Research, a National Instruments Brand
3//
4// SPDX-License-Identifier: GPL-3.0-or-later
5//
6
7#pragma once
8
9#include <uhd/types/device_addr.hpp>
10#include <uhd/types/time_spec.hpp>
11#include <boost/optional.hpp>
12#include <cstdint>
13#include <functional>
14#include <memory>
15#include <optional>
16#include <vector>
17
18 namespace uhd { namespace rfnoc {
19
23 struct custom_register_space
24{
25 uint32_t end_addr;
26 std::function<void(uint32_t, uint32_t)> poke_fn;
27 std::function<uint32_t(uint32_t)> peek_fn;
28};
29
48 struct register_iface_stats
49{
51 uint64_t ctrl_packets_sent = 0;
53 uint64_t ack_packets_received = 0;
55 uint64_t async_packets_received = 0;
57 uint64_t ack_packets_sent = 0;
59 uint64_t ctrl_dropped = 0;
61 uint64_t ctrl_out_of_sequence = 0;
63 ssize_t buffer_fullness = 0;
64
65 std::string UHD_API to_string() const;
66};
67
77 class register_iface
78{
79 public:
80 using sptr = std::shared_ptr<register_iface>;
81
82 virtual ~register_iface() = default;
83
92 using async_msg_validator_t =
93 std::function<bool(uint32_t addr, const std::vector<uint32_t>& data)>;
94
108 using async_msg_callback_t = std::function<void(
109 uint32_t addr, const std::vector<uint32_t>& data, std::optional<uint64_t>)>;
110
115 using async_msg_callback_legacy_t = std::function<void(
116 uint32_t addr, const std::vector<uint32_t>& data, boost::optional<uint64_t>)>;
117
130 virtual void poke32(uint32_t addr,
131 uint32_t data,
132 uhd::time_spec_t time = uhd::time_spec_t::ASAP,
133 bool ack = false) = 0;
134
152 void poke64(uint32_t addr,
153 uint64_t data,
154 time_spec_t time = uhd::time_spec_t::ASAP,
155 bool ack = false)
156 {
157 block_poke32(addr,
158 {uint32_t(data & 0xFFFFFFFF), uint32_t((data >> 32) & 0xFFFFFFFF)},
159 time,
160 ack);
161 }
162
181 virtual void multi_poke32(const std::vector<uint32_t> addrs,
182 const std::vector<uint32_t> data,
183 uhd::time_spec_t time = uhd::time_spec_t::ASAP,
184 bool ack = false) = 0;
185
206 virtual void block_poke32(uint32_t first_addr,
207 const std::vector<uint32_t> data,
208 uhd::time_spec_t time = uhd::time_spec_t::ASAP,
209 bool ack = false) = 0;
210
220 virtual uint32_t peek32(uint32_t addr, time_spec_t time = uhd::time_spec_t::ASAP) = 0;
221
237 uint64_t peek64(uint32_t addr, time_spec_t time = uhd::time_spec_t::ASAP)
238 {
239 const auto vals = block_peek32(addr, 2, time);
240 return uint64_t(vals[0]) | (uint64_t(vals[1]) << 32);
241 }
242
262 virtual std::vector<uint32_t> block_peek32(uint32_t first_addr,
263 size_t length,
264 time_spec_t time = uhd::time_spec_t::ASAP) = 0;
265
303 virtual void poll32(uint32_t addr,
304 uint32_t data,
305 uint32_t mask,
306 time_spec_t timeout,
307 time_spec_t time = uhd::time_spec_t::ASAP,
308 bool ack = false) = 0;
309
310
321 virtual void sleep(time_spec_t duration, bool ack = false) = 0;
322
342 virtual void register_async_msg_validator(async_msg_validator_t callback_f) = 0;
343
351 virtual void register_async_msg_handler(async_msg_callback_t callback_f) = 0;
352
360 [[deprecated("Prefer std::optional over boost::optional.")]] virtual void
361 register_async_msg_handler(async_msg_callback_legacy_t callback_f) = 0;
362
370 virtual void set_policy(const std::string& name, const uhd::device_addr_t& args) = 0;
371
377 virtual uint16_t get_src_epid() const = 0;
378
384 virtual uint16_t get_port_num() const = 0;
385
398 virtual void define_custom_register_space(const uint32_t start_addr,
399 const uint32_t length,
400 std::function<void(uint32_t, uint32_t)> poke_fn,
401 std::function<uint32_t(uint32_t)> peek_fn) = 0;
402
403 virtual register_iface_stats get_stats() const = 0;
404
405}; // class register_iface
406
407}} /* namespace uhd::rfnoc */
uhd::device_addr_t
Definition device_addr.hpp:39
uhd::rfnoc::register_iface
Definition register_iface.hpp:78
uhd::rfnoc::register_iface::register_async_msg_handler
virtual void register_async_msg_handler(async_msg_callback_t callback_f)=0
uhd::rfnoc::register_iface::block_poke32
virtual void block_poke32(uint32_t first_addr, const std::vector< uint32_t > data, uhd::time_spec_t time=uhd::time_spec_t::ASAP, bool ack=false)=0
uhd::rfnoc::register_iface::async_msg_callback_legacy_t
std::function< void( uint32_t addr, const std::vector< uint32_t > &data, boost::optional< uint64_t >)> async_msg_callback_legacy_t
Definition register_iface.hpp:115
uhd::rfnoc::register_iface::peek64
uint64_t peek64(uint32_t addr, time_spec_t time=uhd::time_spec_t::ASAP)
Definition register_iface.hpp:237
uhd::rfnoc::register_iface::sptr
std::shared_ptr< register_iface > sptr
Definition register_iface.hpp:80
uhd::rfnoc::register_iface::get_stats
virtual register_iface_stats get_stats() const =0
uhd::rfnoc::register_iface::poll32
virtual void poll32(uint32_t addr, uint32_t data, uint32_t mask, time_spec_t timeout, time_spec_t time=uhd::time_spec_t::ASAP, bool ack=false)=0
uhd::rfnoc::register_iface::multi_poke32
virtual void multi_poke32(const std::vector< uint32_t > addrs, const std::vector< uint32_t > data, uhd::time_spec_t time=uhd::time_spec_t::ASAP, bool ack=false)=0
uhd::rfnoc::register_iface::register_async_msg_validator
virtual void register_async_msg_validator(async_msg_validator_t callback_f)=0
uhd::rfnoc::register_iface::async_msg_callback_t
std::function< void( uint32_t addr, const std::vector< uint32_t > &data, std::optional< uint64_t >)> async_msg_callback_t
Definition register_iface.hpp:108
uhd::rfnoc::register_iface::get_port_num
virtual uint16_t get_port_num() const =0
uhd::rfnoc::register_iface::async_msg_validator_t
std::function< bool(uint32_t addr, const std::vector< uint32_t > &data)> async_msg_validator_t
Definition register_iface.hpp:92
uhd::rfnoc::register_iface::block_peek32
virtual std::vector< uint32_t > block_peek32(uint32_t first_addr, size_t length, time_spec_t time=uhd::time_spec_t::ASAP)=0
uhd::rfnoc::register_iface::~register_iface
virtual ~register_iface()=default
uhd::rfnoc::register_iface::set_policy
virtual void set_policy(const std::string &name, const uhd::device_addr_t &args)=0
uhd::rfnoc::register_iface::peek32
virtual uint32_t peek32(uint32_t addr, time_spec_t time=uhd::time_spec_t::ASAP)=0
uhd::rfnoc::register_iface::register_async_msg_handler
virtual void register_async_msg_handler(async_msg_callback_legacy_t callback_f)=0
uhd::rfnoc::register_iface::get_src_epid
virtual uint16_t get_src_epid() const =0
uhd::rfnoc::register_iface::define_custom_register_space
virtual void define_custom_register_space(const uint32_t start_addr, const uint32_t length, std::function< void(uint32_t, uint32_t)> poke_fn, std::function< uint32_t(uint32_t)> peek_fn)=0
uhd::rfnoc::register_iface::poke64
void poke64(uint32_t addr, uint64_t data, time_spec_t time=uhd::time_spec_t::ASAP, bool ack=false)
Definition register_iface.hpp:152
uhd::rfnoc::register_iface::sleep
virtual void sleep(time_spec_t duration, bool ack=false)=0
uhd::rfnoc::register_iface::poke32
virtual void poke32(uint32_t addr, uint32_t data, uhd::time_spec_t time=uhd::time_spec_t::ASAP, bool ack=false)=0
uhd::time_spec_t
Definition time_spec.hpp:31
uhd::time_spec_t::ASAP
static constexpr double ASAP
Definition time_spec.hpp:34
UHD_API
#define UHD_API
Definition config.h:87
device_addr.hpp
uhd::rfnoc
Definition actions.hpp:25
uhd
Definition build_info.hpp:12
uhd::rfnoc::custom_register_space
Definition register_iface.hpp:24
uhd::rfnoc::custom_register_space::poke_fn
std::function< void(uint32_t, uint32_t)> poke_fn
Definition register_iface.hpp:26
uhd::rfnoc::custom_register_space::end_addr
uint32_t end_addr
Definition register_iface.hpp:25
uhd::rfnoc::custom_register_space::peek_fn
std::function< uint32_t(uint32_t)> peek_fn
Definition register_iface.hpp:27
uhd::rfnoc::register_iface_stats
Definition register_iface.hpp:49
uhd::rfnoc::register_iface_stats::ctrl_dropped
uint64_t ctrl_dropped
Number of control packets dropped (or ACKs not received).
Definition register_iface.hpp:59
uhd::rfnoc::register_iface_stats::ctrl_out_of_sequence
uint64_t ctrl_out_of_sequence
Number of out-of-sequence control packets.
Definition register_iface.hpp:61
uhd::rfnoc::register_iface_stats::ack_packets_received
uint64_t ack_packets_received
Number of ACK packets received.
Definition register_iface.hpp:53
uhd::rfnoc::register_iface_stats::async_packets_received
uint64_t async_packets_received
Number of async packets received.
Definition register_iface.hpp:55
uhd::rfnoc::register_iface_stats::buffer_fullness
ssize_t buffer_fullness
The fullness of the buffer in the FPGA, as calculated by the software.
Definition register_iface.hpp:63
uhd::rfnoc::register_iface_stats::to_string
std::string UHD_API to_string() const
uhd::rfnoc::register_iface_stats::ack_packets_sent
uint64_t ack_packets_sent
Number of ACK packets sent.
Definition register_iface.hpp:57
uhd::rfnoc::register_iface_stats::ctrl_packets_sent
uint64_t ctrl_packets_sent
Number of control packets sent.
Definition register_iface.hpp:51
time_spec.hpp