USRP Hardware Driver and USRP Manual  Version: 4.7.0.0
UHD and USRP Manual
multichan_register_iface.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2020 Ettus Research, a National Instruments Brand
3 //
4 // SPDX-License-Identifier: GPL-3.0-or-later
5 //
6 
7 #pragma once
8 
12 #include <uhd/types/time_spec.hpp>
13 #include <cstdint>
14 #include <functional>
15 #include <memory>
16 #include <vector>
17 
18 namespace uhd { namespace rfnoc {
19 
31 {
32 public:
33  using sptr = std::shared_ptr<multichan_register_iface>;
34 
36  const uint32_t block_base_addr,
37  const size_t block_size)
38  : _reg_iface_holder(reg_iface_holder)
39  , _block_base_addr(block_base_addr)
40  , _block_size(block_size)
41  {
42  }
43 
44  ~multichan_register_iface() = default;
45 
59  inline void poke32(uint32_t addr,
60  uint32_t data,
61  const size_t instance = 0,
63  bool ack = false)
64  {
65  _reg_iface_holder.regs().poke32(_get_addr(addr, instance), data, time, ack);
66  }
67 
86  inline void poke64(uint32_t addr,
87  uint64_t data,
88  const size_t instance = 0,
90  bool ack = false)
91  {
92  _reg_iface_holder.regs().poke64(_get_addr(addr, instance), data, time, ack);
93  }
94 
114  inline void multi_poke32(const std::vector<uint32_t> addrs,
115  const std::vector<uint32_t> data,
116  const size_t instance = 0,
118  bool ack = false)
119  {
120  std::vector<uint32_t> abs_addrs(addrs.size());
121  std::transform(addrs.begin(),
122  addrs.end(),
123  abs_addrs.begin(),
124  [this, instance](
125  uint32_t addr) -> uint32_t { return _get_addr(addr, instance); });
126  _reg_iface_holder.regs().multi_poke32(abs_addrs, data, time, ack);
127  }
128 
150  inline void block_poke32(uint32_t first_addr,
151  const std::vector<uint32_t> data,
152  const size_t instance = 0,
154  bool ack = false)
155  {
156  _reg_iface_holder.regs().block_poke32(
157  _get_addr(first_addr, instance), data, time, ack);
158  }
159 
170  inline uint32_t peek32(uint32_t addr,
171  const size_t instance = 0,
173  {
174  return _reg_iface_holder.regs().peek32(_get_addr(addr, instance), time);
175  }
176 
193  inline uint64_t peek64(uint32_t addr,
194  const size_t instance = 0,
196  {
197  return _reg_iface_holder.regs().peek64(_get_addr(addr, instance), time);
198  }
199 
220  inline std::vector<uint32_t> block_peek32(uint32_t first_addr,
221  size_t length,
222  const size_t instance = 0,
224  {
225  return _reg_iface_holder.regs().block_peek32(
226  _get_addr(first_addr, instance), length, time);
227  }
228 
267  inline void poll32(uint32_t addr,
268  uint32_t data,
269  uint32_t mask,
270  time_spec_t timeout,
271  const size_t instance = 0,
273  bool ack = false)
274  {
275  _reg_iface_holder.regs().poll32(
276  _get_addr(addr, instance), data, mask, timeout, time, ack);
277  }
278 
279 private:
280  register_iface_holder& _reg_iface_holder;
281  uint32_t _block_base_addr;
282  size_t _block_size;
283 
284  inline uint32_t _get_addr(const uint32_t reg_offset, const size_t instance) const
285  {
286  return _block_base_addr + reg_offset + _block_size * instance;
287  }
288 
289 }; // class multichan_register_iface
290 
291 }} /* namespace uhd::rfnoc */
std::shared_ptr< multichan_register_iface > sptr
Definition: multichan_register_iface.hpp:33
std::vector< uint32_t > block_peek32(uint32_t first_addr, size_t length, const size_t instance=0, time_spec_t time=uhd::time_spec_t::ASAP)
Definition: multichan_register_iface.hpp:220
Definition: register_iface_holder.hpp:18
uint64_t peek64(uint32_t addr, time_spec_t time=uhd::time_spec_t::ASAP)
Definition: register_iface.hpp:187
Definition: time_spec.hpp:28
void block_poke32(uint32_t first_addr, const std::vector< uint32_t > data, const size_t instance=0, uhd::time_spec_t time=uhd::time_spec_t::ASAP, bool ack=false)
Definition: multichan_register_iface.hpp:150
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
uint32_t peek32(uint32_t addr, const size_t instance=0, time_spec_t time=uhd::time_spec_t::ASAP)
Definition: multichan_register_iface.hpp:170
static constexpr double ASAP
Definition: time_spec.hpp:34
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
multichan_register_iface(register_iface_holder &reg_iface_holder, const uint32_t block_base_addr, const size_t block_size)
Definition: multichan_register_iface.hpp:35
void poke32(uint32_t addr, uint32_t data, const size_t instance=0, uhd::time_spec_t time=uhd::time_spec_t::ASAP, bool ack=false)
Definition: multichan_register_iface.hpp:59
virtual uint32_t peek32(uint32_t addr, time_spec_t time=uhd::time_spec_t::ASAP)=0
register_iface & regs()
Definition: register_iface_holder.hpp:28
virtual void poke32(uint32_t addr, uint32_t data, uhd::time_spec_t time=uhd::time_spec_t::ASAP, bool ack=false)=0
Definition: build_info.hpp:12
void poke64(uint32_t addr, uint64_t data, const size_t instance=0, time_spec_t time=uhd::time_spec_t::ASAP, bool ack=false)
Definition: multichan_register_iface.hpp:86
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
void multi_poke32(const std::vector< uint32_t > addrs, const std::vector< uint32_t > data, const size_t instance=0, uhd::time_spec_t time=uhd::time_spec_t::ASAP, bool ack=false)
Definition: multichan_register_iface.hpp:114
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
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_INLINE data_t mask(const soft_reg_field_t field)
Definition: soft_register.hpp:86
uint64_t peek64(uint32_t addr, const size_t instance=0, time_spec_t time=uhd::time_spec_t::ASAP)
Definition: multichan_register_iface.hpp:193
Definition: multichan_register_iface.hpp:30
void poll32(uint32_t addr, uint32_t data, uint32_t mask, time_spec_t timeout, const size_t instance=0, time_spec_t time=uhd::time_spec_t::ASAP, bool ack=false)
Definition: multichan_register_iface.hpp:267