Loading...
Searching...
No Matches
register_iface.hpp
Go to the documentation of this file.
//
// Copyright 2019 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
#pragma once
#include <uhd/types/device_addr.hpp>
#include <uhd/types/time_spec.hpp>
#include <boost/optional.hpp>
#include <cstdint>
#include <functional>
#include <memory>
#include <vector>
namespace uhd { namespace rfnoc {
struct custom_register_space
{
uint32_t end_addr;
std::function<void(uint32_t, uint32_t)> poke_fn;
std::function<uint32_t(uint32_t)> peek_fn;
};
class register_iface
{
public:
using sptr = std::shared_ptr<register_iface>;
virtual ~register_iface() = default;
using async_msg_validator_t =
std::function<bool(uint32_t addr, const std::vector<uint32_t>& data)>;
using async_msg_callback_t = std::function<void(
uint32_t addr, const std::vector<uint32_t>& data, boost::optional<uint64_t>)>;
virtual void poke32(uint32_t addr,
uint32_t data,
uhd::time_spec_t time = uhd::time_spec_t::ASAP,
bool ack = false) = 0;
void poke64(uint32_t addr,
uint64_t data,
time_spec_t time = uhd::time_spec_t::ASAP,
bool ack = false)
{
block_poke32(addr,
{uint32_t(data & 0xFFFFFFFF), uint32_t((data >> 32) & 0xFFFFFFFF)},
time,
ack);
}
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 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;
virtual uint32_t peek32(uint32_t addr, time_spec_t time = uhd::time_spec_t::ASAP) = 0;
uint64_t peek64(uint32_t addr, time_spec_t time = uhd::time_spec_t::ASAP)
{
const auto vals = block_peek32(addr, 2, time);
return uint64_t(vals[0]) | (uint64_t(vals[1]) << 32);
}
virtual std::vector<uint32_t> block_peek32(uint32_t first_addr,
size_t length,
time_spec_t time = uhd::time_spec_t::ASAP) = 0;
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;
virtual void sleep(time_spec_t duration, bool ack = false) = 0;
virtual void register_async_msg_validator(async_msg_validator_t callback_f) = 0;
virtual void register_async_msg_handler(async_msg_callback_t callback_f) = 0;
virtual void set_policy(const std::string& name, const uhd::device_addr_t& args) = 0;
virtual uint16_t get_src_epid() const = 0;
virtual uint16_t get_port_num() const = 0;
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;
}; // class register_iface
}} /* 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::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::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::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_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::get_port_num
virtual uint16_t get_port_num() const =0
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