USRP Hardware Driver and USRP Manual  Version: 4.7.0.0
UHD and USRP Manual
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 
10 #include <uhd/types/time_spec.hpp>
11 #include <cstdint>
12 #include <functional>
13 #include <memory>
14 #include <vector>
15 
16 namespace uhd { namespace rfnoc {
17 
22 {
23  uint32_t end_addr;
24  std::function<void(uint32_t, uint32_t)> poke_fn;
25  std::function<uint32_t(uint32_t)> peek_fn;
26 };
27 
38 {
39 public:
40  using sptr = std::shared_ptr<register_iface>;
41 
42  virtual ~register_iface() = default;
43 
52  using async_msg_validator_t =
53  std::function<bool(uint32_t addr, const std::vector<uint32_t>& data)>;
54 
65  using async_msg_callback_t = std::function<void(
66  uint32_t addr, const std::vector<uint32_t>& data, boost::optional<uint64_t>)>;
67 
80  virtual void poke32(uint32_t addr,
81  uint32_t data,
83  bool ack = false) = 0;
84 
102  void poke64(uint32_t addr,
103  uint64_t data,
105  bool ack = false)
106  {
107  block_poke32(addr,
108  {uint32_t(data & 0xFFFFFFFF), uint32_t((data >> 32) & 0xFFFFFFFF)},
109  time,
110  ack);
111  }
112 
131  virtual void multi_poke32(const std::vector<uint32_t> addrs,
132  const std::vector<uint32_t> data,
134  bool ack = false) = 0;
135 
156  virtual void block_poke32(uint32_t first_addr,
157  const std::vector<uint32_t> data,
159  bool ack = false) = 0;
160 
170  virtual uint32_t peek32(uint32_t addr, time_spec_t time = uhd::time_spec_t::ASAP) = 0;
171 
187  uint64_t peek64(uint32_t addr, time_spec_t time = uhd::time_spec_t::ASAP)
188  {
189  const auto vals = block_peek32(addr, 2, time);
190  return uint64_t(vals[0]) | (uint64_t(vals[1]) << 32);
191  }
192 
212  virtual std::vector<uint32_t> block_peek32(uint32_t first_addr,
213  size_t length,
215 
253  virtual void poll32(uint32_t addr,
254  uint32_t data,
255  uint32_t mask,
256  time_spec_t timeout,
258  bool ack = false) = 0;
259 
260 
271  virtual void sleep(time_spec_t duration, bool ack = false) = 0;
272 
292  virtual void register_async_msg_validator(async_msg_validator_t callback_f) = 0;
293 
301  virtual void register_async_msg_handler(async_msg_callback_t callback_f) = 0;
302 
310  virtual void set_policy(const std::string& name, const uhd::device_addr_t& args) = 0;
311 
317  virtual uint16_t get_src_epid() const = 0;
318 
324  virtual uint16_t get_port_num() const = 0;
325 
338  virtual void define_custom_register_space(const uint32_t start_addr,
339  const uint32_t length,
340  std::function<void(uint32_t, uint32_t)> poke_fn,
341  std::function<uint32_t(uint32_t)> peek_fn) = 0;
342 
343 }; // class register_iface
344 
345 }} /* namespace uhd::rfnoc */
uint64_t peek64(uint32_t addr, time_spec_t time=uhd::time_spec_t::ASAP)
Definition: register_iface.hpp:187
uint32_t end_addr
Definition: register_iface.hpp:23
Definition: time_spec.hpp:28
static constexpr double ASAP
Definition: time_spec.hpp:34
std::shared_ptr< register_iface > sptr
Definition: register_iface.hpp:40
Definition: build_info.hpp:12
std::function< void(uint32_t, uint32_t)> poke_fn
Definition: register_iface.hpp:24
void poke64(uint32_t addr, uint64_t data, time_spec_t time=uhd::time_spec_t::ASAP, bool ack=false)
Definition: register_iface.hpp:102
std::function< bool(uint32_t addr, const std::vector< uint32_t > &data)> async_msg_validator_t
Definition: register_iface.hpp:53
std::function< void(uint32_t addr, const std::vector< uint32_t > &data, boost::optional< uint64_t >)> async_msg_callback_t
Definition: register_iface.hpp:66
UHD_INLINE data_t mask(const soft_reg_field_t field)
Definition: soft_register.hpp:86
Definition: register_iface.hpp:21
Definition: register_iface.hpp:37
Definition: device_addr.hpp:37
std::function< uint32_t(uint32_t)> peek_fn
Definition: register_iface.hpp:25