| USRP Hardware Driver and USRP Manual Version: 4.9.0.makepkg-0-g9ec1f582 UHD and USRP Manual |

Loading...
Searching...
No Matches
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
9#include <uhd/rfnoc/register_iface.hpp>
10#include <uhd/rfnoc/register_iface_holder.hpp>
11#include <uhd/types/device_addr.hpp>
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
30 class multichan_register_iface
31{
32 public:
33 using sptr = std::shared_ptr<multichan_register_iface>;
34
35 multichan_register_iface(register_iface_holder& reg_iface_holder,
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,
62 uhd::time_spec_t time = uhd::time_spec_t::ASAP,
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,
89 time_spec_t time = uhd::time_spec_t::ASAP,
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,
117 uhd::time_spec_t time = uhd::time_spec_t::ASAP,
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,
153 uhd::time_spec_t time = uhd::time_spec_t::ASAP,
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,
172 time_spec_t time = uhd::time_spec_t::ASAP)
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,
195 time_spec_t time = uhd::time_spec_t::ASAP)
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,
223 time_spec_t time = uhd::time_spec_t::ASAP)
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,
272 time_spec_t time = uhd::time_spec_t::ASAP,
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 */
uhd::rfnoc::multichan_register_iface::poll32
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
uhd::rfnoc::multichan_register_iface::block_peek32
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
uhd::rfnoc::multichan_register_iface::poke64
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
uhd::rfnoc::multichan_register_iface::sptr
std::shared_ptr< multichan_register_iface > sptr
Definition multichan_register_iface.hpp:33
uhd::rfnoc::multichan_register_iface::multi_poke32
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
uhd::rfnoc::multichan_register_iface::peek64
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
uhd::rfnoc::multichan_register_iface::poke32
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
uhd::rfnoc::multichan_register_iface::block_poke32
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
uhd::rfnoc::multichan_register_iface::~multichan_register_iface
~multichan_register_iface()=default
uhd::rfnoc::multichan_register_iface::peek32
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
uhd::rfnoc::multichan_register_iface::multichan_register_iface
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
uhd::rfnoc::register_iface_holder
Definition register_iface_holder.hpp:19
uhd::time_spec_t
Definition time_spec.hpp:31
uhd::time_spec_t::ASAP
static constexpr double ASAP
Definition time_spec.hpp:34
device_addr.hpp
uhd::rfnoc
Definition actions.hpp:24
uhd
Definition build_info.hpp:12
register_iface.hpp
register_iface_holder.hpp
time_spec.hpp