From 029e29e24b071e0f316ca74c6d1ff614acc23e19 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 9 Aug 2018 16:42:08 -0500 Subject: b200: Enable access to user regs via the 'enable_user_regs' arg --- host/lib/usrp/b200/b200_impl.cpp | 28 ++++++++++++++++++++++++---- host/lib/usrp/b200/b200_impl.hpp | 5 +++++ host/lib/usrp/b200/b200_regs.hpp | 2 ++ 3 files changed, 31 insertions(+), 4 deletions(-) (limited to 'host/lib') diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index a173c68f8..ae6e0b0d7 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -276,6 +276,7 @@ UHD_STATIC_BLOCK(register_b200_device) b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::sptr &handle) : _product(B200), // Some safe value _revision(0), + _enable_user_regs(device_addr.has_key("enable_user_regs")), _time_source(UNKNOWN), _tick_rate(0.0) // Forces a clock initialization at startup { @@ -836,6 +837,18 @@ void b200_impl::setup_radio(const size_t dspno) perif.duc = tx_dsp_core_3000::make(perif.ctrl, TOREG(SR_TX_DSP)); perif.duc->set_link_rate(10e9/8); //whatever perif.duc->set_freq(tx_dsp_core_3000::DEFAULT_CORDIC_FREQ); + if (_enable_user_regs) { + UHD_LOG_DEBUG("B200", "Enabling user settings registers"); + perif.user_settings = user_settings_core_3000::make(perif.ctrl, + TOREG(SR_USER_SR_BASE), + TOREG(SR_USER_RB_ADDR) + ); + if (!perif.user_settings) { + const std::string error_msg = "Failed to create user settings bus!"; + UHD_LOG_ERROR("B200", error_msg); + throw uhd::runtime_error(error_msg); + } + } //////////////////////////////////////////////////////////////////// // create time control objects @@ -853,9 +866,10 @@ void b200_impl::setup_radio(const size_t dspno) _tree->create(rx_dsp_path / "rate" / "set").set(false); _tree->access(rx_dsp_path / "rate" / "value") .set_coercer(boost::bind(&b200_impl::coerce_rx_samp_rate, this, perif.ddc, dspno, _1)) - .add_coerced_subscriber([this](const double){ + .add_coerced_subscriber([this, rx_dsp_path](const double){ if (this->_tree) { - _tree->access(rx_dsp_path / "rate" / "set").set(true); + this->_tree->access(rx_dsp_path / "rate" / "set") + .set(true); } }) .add_coerced_subscriber(boost::bind(&b200_impl::update_rx_samp_rate, this, dspno, _1)) @@ -875,9 +889,10 @@ void b200_impl::setup_radio(const size_t dspno) _tree->create(tx_dsp_path / "rate" / "set").set(false); _tree->access(tx_dsp_path / "rate" / "value") .set_coercer(boost::bind(&b200_impl::coerce_tx_samp_rate, this, perif.duc, dspno, _1)) - .add_coerced_subscriber([this](const double){ + .add_coerced_subscriber([this, tx_dsp_path](const double){ if (this->_tree) { - tree->access(tx_dsp_path / "rate" / "set").set(true); + this->_tree->access(tx_dsp_path / "rate" / "set") + .set(true); } }) .add_coerced_subscriber(boost::bind(&b200_impl::update_tx_samp_rate, this, dspno, _1)) @@ -923,6 +938,11 @@ void b200_impl::setup_radio(const size_t dspno) _tree->create >(rf_fe_path / "antenna" / "options").set(ants); _tree->create(rf_fe_path / "antenna" / "value").set("TX/RX"); } + + if (_enable_user_regs) { + _tree->create(rf_fe_path / "user_settings/iface") + .set(perif.user_settings); + } } } diff --git a/host/lib/usrp/b200/b200_impl.hpp b/host/lib/usrp/b200/b200_impl.hpp index 3e1a62249..12678c13d 100644 --- a/host/lib/usrp/b200/b200_impl.hpp +++ b/host/lib/usrp/b200/b200_impl.hpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -127,6 +128,9 @@ private: b200_product_t _product; size_t _revision; bool _gpsdo_capable; + //! This flag is true if the FPGA has custom (user) registers and access to + // those needs to be enabled from software. + const bool _enable_user_regs; //controllers b200_iface::sptr _iface; @@ -188,6 +192,7 @@ private: tx_dsp_core_3000::sptr duc; boost::weak_ptr rx_streamer; boost::weak_ptr tx_streamer; + user_settings_core_3000::sptr user_settings; bool ant_rx2; }; std::vector _radio_perifs; diff --git a/host/lib/usrp/b200/b200_regs.hpp b/host/lib/usrp/b200/b200_regs.hpp index 6cc670d22..cedbe0ff5 100644 --- a/host/lib/usrp/b200/b200_regs.hpp +++ b/host/lib/usrp/b200/b200_regs.hpp @@ -37,6 +37,8 @@ localparam SR_TIME = 128; localparam SR_RX_FMT = 136; localparam SR_TX_FMT = 138; localparam SR_FP_GPIO = 200; +localparam SR_USER_SR_BASE = 253; +localparam SR_USER_RB_ADDR = 255; localparam RB32_TEST = 0; localparam RB64_TIME_NOW = 8; -- cgit v1.2.3