USRP Hardware Driver and USRP Manual: register_iface.hpp Source File

| USRP Hardware Driver and USRP Manual Version: 4.9.0.makepkg-0-g9ec1f582 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 <vector>
16
17namespace uhd { namespace rfnoc {
18
22 struct custom_register_space
23{
24 uint32_t end_addr;
25 std::function<void(uint32_t, uint32_t)> poke_fn;
26 std::function<uint32_t(uint32_t)> peek_fn;
27};
28
38 class register_iface
39{
40public:
41 using sptr = std::shared_ptr<register_iface>;
42
43 virtual ~register_iface() = default;
44
53 using async_msg_validator_t =
54 std::function<bool(uint32_t addr, const std::vector<uint32_t>& data)>;
55
66 using async_msg_callback_t = std::function<void(
67 uint32_t addr, const std::vector<uint32_t>& data, boost::optional<uint64_t>)>;
68
81 virtual void poke32(uint32_t addr,
82 uint32_t data,
83 uhd::time_spec_t time = uhd::time_spec_t::ASAP,
84 bool ack = false) = 0;
85
103 void poke64(uint32_t addr,
104 uint64_t data,
105 time_spec_t time = uhd::time_spec_t::ASAP,
106 bool ack = false)
107 {
108 block_poke32(addr,
109 {uint32_t(data & 0xFFFFFFFF), uint32_t((data >> 32) & 0xFFFFFFFF)},
110 time,
111 ack);
112 }
113
132 virtual void multi_poke32(const std::vector<uint32_t> addrs,
133 const std::vector<uint32_t> data,
134 uhd::time_spec_t time = uhd::time_spec_t::ASAP,
135 bool ack = false) = 0;
136
157 virtual void block_poke32(uint32_t first_addr,
158 const std::vector<uint32_t> data,
159 uhd::time_spec_t time = uhd::time_spec_t::ASAP,
160 bool ack = false) = 0;
161
171 virtual uint32_t peek32(uint32_t addr, time_spec_t time = uhd::time_spec_t::ASAP) = 0;
172
188 uint64_t peek64(uint32_t addr, time_spec_t time = uhd::time_spec_t::ASAP)
189 {
190 const auto vals = block_peek32(addr, 2, time);
191 return uint64_t(vals[0]) | (uint64_t(vals[1]) << 32);
192 }
193
213 virtual std::vector<uint32_t> block_peek32(uint32_t first_addr,
214 size_t length,
215 time_spec_t time = uhd::time_spec_t::ASAP) = 0;
216
254 virtual void poll32(uint32_t addr,
255 uint32_t data,
256 uint32_t mask,
257 time_spec_t timeout,
258 time_spec_t time = uhd::time_spec_t::ASAP,
259 bool ack = false) = 0;
260
261
272 virtual void sleep(time_spec_t duration, bool ack = false) = 0;
273
293 virtual void register_async_msg_validator(async_msg_validator_t callback_f) = 0;
294
302 virtual void register_async_msg_handler(async_msg_callback_t callback_f) = 0;
303
311 virtual void set_policy(const std::string& name, const uhd::device_addr_t& args) = 0;
312
318 virtual uint16_t get_src_epid() const = 0;
319
325 virtual uint16_t get_port_num() const = 0;
326
339 virtual void define_custom_register_space(const uint32_t start_addr,
340 const uint32_t length,
341 std::function<void(uint32_t, uint32_t)> poke_fn,
342 std::function<uint32_t(uint32_t)> peek_fn) = 0;
343
344}; // class register_iface
345
346}} /* namespace uhd::rfnoc */
uhd::device_addr_t
Definition device_addr.hpp:39
uhd::rfnoc::register_iface
Definition register_iface.hpp:39
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::peek64
uint64_t peek64(uint32_t addr, time_spec_t time=uhd::time_spec_t::ASAP)
Definition register_iface.hpp:188
uhd::rfnoc::register_iface::sptr
std::shared_ptr< register_iface > sptr
Definition register_iface.hpp:41
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::async_msg_callback_t
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::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::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:53
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::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:103
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
device_addr.hpp
uhd::rfnoc
Definition actions.hpp:24
uhd
Definition build_info.hpp:12
uhd::rfnoc::custom_register_space
Definition register_iface.hpp:23
uhd::rfnoc::custom_register_space::poke_fn
std::function< void(uint32_t, uint32_t)> poke_fn
Definition register_iface.hpp:25
uhd::rfnoc::custom_register_space::end_addr
uint32_t end_addr
Definition register_iface.hpp:24
uhd::rfnoc::custom_register_space::peek_fn
std::function< uint32_t(uint32_t)> peek_fn
Definition register_iface.hpp:26
time_spec.hpp