From 49520bfecb5e13126224ee915208c2cd936f911c Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 1 Nov 2016 16:45:29 -0700 Subject: rfnoc: ctrl_iface cleanup - ctrl_iface is now longer a wb_iface. All it can do now is send command packets, and receive responses to those. - ctrl_iface does not store command time or tick rate - wb_iface_adapter is no longer a set of functors, but a wrapper around ctrl_iface. Command times are stored once, in the block. - DMA FIFO and radio block controllers have an easier time getting access to a timed_wb_iface --- host/lib/rfnoc/wb_iface_adapter.cpp | 50 +++++++++++++------------------------ 1 file changed, 18 insertions(+), 32 deletions(-) (limited to 'host/lib/rfnoc/wb_iface_adapter.cpp') diff --git a/host/lib/rfnoc/wb_iface_adapter.cpp b/host/lib/rfnoc/wb_iface_adapter.cpp index 3b9202661..64b41d6d2 100644 --- a/host/lib/rfnoc/wb_iface_adapter.cpp +++ b/host/lib/rfnoc/wb_iface_adapter.cpp @@ -6,56 +6,42 @@ // #include +#include using namespace uhd::rfnoc; wb_iface_adapter::wb_iface_adapter( - const poke32_type &poke32_functor_, - const peek32_type &peek32_functor_, - const peek64_type &peek64_functor_, - const gettime_type &gettime_functor_, - const settime_type &settime_functor_ -) : poke32_functor(poke32_functor_) - , peek32_functor(peek32_functor_) - , peek64_functor(peek64_functor_) - , gettime_functor(gettime_functor_) + ctrl_iface::sptr iface, + const gettickrate_type & gettickrate_functor_, + const settime_type & settime_functor_, + const gettime_type & gettime_functor_ +) : _iface(iface) + , gettickrate_functor(gettickrate_functor_) , settime_functor(settime_functor_) -{ - // nop -} - -wb_iface_adapter::wb_iface_adapter( - const poke32_type &poke32_functor_, - const peek32_type &peek32_functor_, - const peek64_type &peek64_functor_ -) : poke32_functor(poke32_functor_) - , peek32_functor(peek32_functor_) - , peek64_functor(peek64_functor_) + , gettime_functor(gettime_functor_) { // nop } void wb_iface_adapter::poke32(const wb_addr_type addr, const uint32_t data) { - poke32_functor(addr / 4, data); // FIXME remove the requirement for /4 + const uint64_t timestamp = gettime_functor().to_ticks(gettickrate_functor()); + _iface->send_cmd_pkt(addr / 4, data, false, timestamp); } uint32_t wb_iface_adapter::peek32(const wb_addr_type addr) { - return peek32_functor(addr / 8); + const uint64_t reg_value = peek64(addr); + return ((addr/4) & 0x1) ? + uint32_t(reg_value >> 32) : + uint32_t(reg_value & 0xffffffff); } uint64_t wb_iface_adapter::peek64(const wb_addr_type addr) { - return peek64_functor(addr / 8); -} - -uhd::time_spec_t wb_iface_adapter::get_time(void) -{ - return gettime_functor(); + const uint64_t timestamp = gettime_functor().to_ticks(gettickrate_functor()); + // TODO: Figure out if we should have a timestamp here + _iface->send_cmd_pkt(SR_READBACK_ADDR, addr / 8, false, timestamp); + return _iface->send_cmd_pkt(SR_READBACK, SR_READBACK_REG_USER, true, timestamp); } -void wb_iface_adapter::set_time(const uhd::time_spec_t& t) -{ - settime_functor(t); -} -- cgit v1.2.3