Loading...
Searching...
No Matches
multichan_register_iface.hpp
Go to the documentation of this file.
//
// Copyright 2020 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
#pragma once
#include <uhd/rfnoc/register_iface.hpp>
#include <uhd/rfnoc/register_iface_holder.hpp>
#include <uhd/types/device_addr.hpp>
#include <uhd/types/time_spec.hpp>
#include <cstdint>
#include <functional>
#include <memory>
#include <vector>
namespace uhd { namespace rfnoc {
class multichan_register_iface
{
public:
using sptr = std::shared_ptr<multichan_register_iface>;
multichan_register_iface(register_iface_holder& reg_iface_holder,
const uint32_t block_base_addr,
const size_t block_size)
: _reg_iface_holder(reg_iface_holder)
, _block_base_addr(block_base_addr)
, _block_size(block_size)
{
}
~multichan_register_iface() = default;
inline 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)
{
_reg_iface_holder.regs().poke32(_get_addr(addr, instance), data, time, ack);
}
inline 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)
{
_reg_iface_holder.regs().poke64(_get_addr(addr, instance), data, time, ack);
}
inline 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)
{
std::vector<uint32_t> abs_addrs(addrs.size());
std::transform(addrs.begin(),
addrs.end(),
abs_addrs.begin(),
[this, instance](
uint32_t addr) -> uint32_t { return _get_addr(addr, instance); });
_reg_iface_holder.regs().multi_poke32(abs_addrs, data, time, ack);
}
inline 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)
{
_reg_iface_holder.regs().block_poke32(
_get_addr(first_addr, instance), data, time, ack);
}
inline uint32_t peek32(uint32_t addr,
const size_t instance = 0,
time_spec_t time = uhd::time_spec_t::ASAP)
{
return _reg_iface_holder.regs().peek32(_get_addr(addr, instance), time);
}
inline uint64_t peek64(uint32_t addr,
const size_t instance = 0,
time_spec_t time = uhd::time_spec_t::ASAP)
{
return _reg_iface_holder.regs().peek64(_get_addr(addr, instance), time);
}
inline 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)
{
return _reg_iface_holder.regs().block_peek32(
_get_addr(first_addr, instance), length, time);
}
inline 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)
{
_reg_iface_holder.regs().poll32(
_get_addr(addr, instance), data, mask, timeout, time, ack);
}
private:
register_iface_holder& _reg_iface_holder;
uint32_t _block_base_addr;
size_t _block_size;
inline uint32_t _get_addr(const uint32_t reg_offset, const size_t instance) const
{
return _block_base_addr + reg_offset + _block_size * instance;
}
}; // class multichan_register_iface
}} /* 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