diff options
author | Mark Meserve <mark.meserve@ni.com> | 2018-12-19 16:46:49 -0600 |
---|---|---|
committer | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-09 11:47:07 -0800 |
commit | 34f54d3ec7371ba251a2e901638eaae07f3b4cda (patch) | |
tree | 3b76c504622292e3d6298aef4d3208d1eca88210 /host/lib | |
parent | 5c012cad7858cadcaa85ec295080f3c8b21fdee0 (diff) | |
download | uhd-34f54d3ec7371ba251a2e901638eaae07f3b4cda.tar.gz uhd-34f54d3ec7371ba251a2e901638eaae07f3b4cda.tar.bz2 uhd-34f54d3ec7371ba251a2e901638eaae07f3b4cda.zip |
rh: add support for iq and dc correction files
- Update corrections on frequency or LO source change
- Add legacy EEPROM properties
- Move DSP control initialization earlier
- Fix TX antenna list property
Diffstat (limited to 'host/lib')
4 files changed, 88 insertions, 18 deletions
diff --git a/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.cpp b/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.cpp index 245642917..6599e3d82 100644 --- a/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.cpp +++ b/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.cpp @@ -7,6 +7,7 @@ #include "rhodium_radio_ctrl_impl.hpp" #include "rhodium_constants.hpp" #include <uhdlib/utils/narrow.hpp> +#include <uhdlib/usrp/common/apply_corrections.hpp> #include <uhd/utils/log.hpp> #include <uhd/rfnoc/node_ctrl_base.hpp> #include <uhd/transport/chdr.hpp> @@ -200,6 +201,7 @@ double rhodium_radio_ctrl_impl::set_tx_frequency( _rpcc->notify_with_token(_rpc_prefix + "enable_tx_lowband_lo", (!is_highband)); } _update_tx_freq_switches(coerced_freq); + _update_corrections(get_tx_lo_source(RHODIUM_LO1, 0), coerced_freq, TX_DIRECTION); // if TX lowband/highband changed and antenna is TX/RX, // the ATR and SW1 need to be updated _update_tx_output_switches(get_tx_antenna(0)); @@ -252,6 +254,7 @@ double rhodium_radio_ctrl_impl::set_rx_frequency( _rpcc->notify_with_token(_rpc_prefix + "enable_rx_lowband_lo", (!is_highband)); } _update_rx_freq_switches(coerced_freq); + _update_corrections(get_rx_lo_source(RHODIUM_LO1, 0), coerced_freq, RX_DIRECTION); return coerced_freq; } @@ -399,6 +402,40 @@ void rhodium_radio_ctrl_impl::_update_atr( } } +void rhodium_radio_ctrl_impl::_update_corrections( + const std::string lo_source, + const double freq, + const direction_t dir) +{ + const std::string fe_path_part = dir == RX_DIRECTION ? "rx_fe_corrections" + : "tx_fe_corrections"; + const fs_path fe_corr_path = _root_path / fe_path_part / 0; + const fs_path dboard_path = fs_path("dboards") / _radio_slot; + + if (lo_source == "internal") + { + UHD_LOG_DEBUG(unique_id(), + "Enabling frontend corrections for " + << ((dir == RX_DIRECTION) ? "RX" : "TX")); + if (dir == RX_DIRECTION) { + apply_rx_fe_corrections(_tree, dboard_path, fe_corr_path, freq); + } else { + apply_tx_fe_corrections(_tree, dboard_path, fe_corr_path, freq); + } + } else { + UHD_LOG_DEBUG(unique_id(), + "Disabling frontend corrections for " + << ((dir == RX_DIRECTION) ? "RX" : "TX")); + if (dir == RX_DIRECTION) { + _rx_fe_core->set_iq_balance(rx_frontend_core_3000::DEFAULT_IQ_BALANCE_VALUE); + } else { + _tx_fe_core->set_dc_offset(tx_frontend_core_200::DEFAULT_DC_OFFSET_VALUE); + _tx_fe_core->set_iq_balance(tx_frontend_core_200::DEFAULT_IQ_BALANCE_VALUE); + } + } + +} + uhd::gain_range_t rhodium_radio_ctrl_impl::_get_gain_range(direction_t dir) { if (dir == RX_DIRECTION) { @@ -533,12 +570,12 @@ void rhodium_radio_ctrl_impl::set_rpc_client( radio_ctrl_impl::set_rate(_master_clock_rate); UHD_LOG_TRACE(unique_id(), "Checking for existence of Rhodium DB in slot " << _radio_slot); - const auto dboard_info = _rpcc->request<std::vector<std::map<std::string, std::string>>>("get_dboard_info"); + const auto all_dboard_info = _rpcc->request<std::vector<std::map<std::string, std::string>>>("get_dboard_info"); // There is a bug that if only one DB is plugged into slot B the vector // will only have 1 element but not be correlated to slot B at all. // For now, we assume a 1 element array means the DB is in slot A. - if (dboard_info.size() <= get_block_id().get_block_count()) + if (all_dboard_info.size() <= get_block_id().get_block_count()) { UHD_LOG_DEBUG(unique_id(), "No DB detected in slot " << _radio_slot); // Name and master clock rate are needed for RFNoC init, so set the @@ -549,11 +586,10 @@ void rhodium_radio_ctrl_impl::set_rpc_client( ->create<std::string>("name").set("Unknown"); } else { + _dboard_info = all_dboard_info.at(get_block_id().get_block_count()); UHD_LOG_DEBUG(unique_id(), - "Rhodium DB detected in slot " << - _radio_slot << - ". Serial: " << - dboard_info.at(get_block_id().get_block_count()).at("serial")); + "Rhodium DB detected in slot " << _radio_slot << + ". Serial: " << _dboard_info.at("serial")); _init_defaults(); _init_peripherals(); _init_prop_tree(); diff --git a/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.hpp b/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.hpp index c13dd11ae..0cd29cc99 100644 --- a/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.hpp +++ b/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_impl.hpp @@ -215,6 +215,9 @@ private: // ATR registers control SW10 and the frontend LEDs. void _update_atr(const std::string& ant, const direction_t dir); + //! Configure DSP core corrections based on current frequency and LO source + void _update_corrections(const std::string lo_source, const double freq, const direction_t dir); + //! Map a frequency in Hz to an rx_band value. Will return // rx_band::INVALID_BAND if the frequency is out of range. static rx_band _map_freq_to_rx_band(const double freq); @@ -294,6 +297,9 @@ private: //! Prepended for all dboard RPC calls std::string _rpc_prefix; + //! Daughterboard info from MPM + std::map<std::string, std::string> _dboard_info; + //! Additional block args; gets set during set_rpc_client() uhd::device_addr_t _block_args; diff --git a/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_init.cpp b/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_init.cpp index ae72a4bac..a4b2cd17a 100644 --- a/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_init.cpp +++ b/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_init.cpp @@ -16,6 +16,7 @@ #include <string> using namespace uhd; +using namespace uhd::usrp; using namespace uhd::rfnoc; namespace { @@ -166,6 +167,19 @@ void rhodium_radio_ctrl_impl::_init_peripherals() _generate_write_spi(this->_spi, SEN_CPLD, _get_cpld_spi_config()), _generate_read_spi(this->_spi, SEN_CPLD, _get_cpld_spi_config())); + UHD_LOG_TRACE(unique_id(), "Initializing TX frontend DSP core...") + _tx_fe_core = tx_frontend_core_200::make(_get_ctrl(0), regs::sr_addr(TX_FE_BASE)); + _tx_fe_core->set_dc_offset(tx_frontend_core_200::DEFAULT_DC_OFFSET_VALUE); + _tx_fe_core->set_iq_balance(tx_frontend_core_200::DEFAULT_IQ_BALANCE_VALUE); + _tx_fe_core->populate_subtree(_tree->subtree(_root_path / "tx_fe_corrections" / 0)); + + UHD_LOG_TRACE(unique_id(), "Initializing RX frontend DSP core...") + _rx_fe_core = rx_frontend_core_3000::make(_get_ctrl(0), regs::sr_addr(RX_FE_BASE)); + _rx_fe_core->set_adc_rate(_master_clock_rate); + _rx_fe_core->set_dc_offset(rx_frontend_core_3000::DEFAULT_DC_OFFSET_VALUE); + _rx_fe_core->set_dc_offset_auto(rx_frontend_core_3000::DEFAULT_DC_OFFSET_ENABLE); + _rx_fe_core->populate_subtree(_tree->subtree(_root_path / "rx_fe_corrections" / 0)); + UHD_LOG_TRACE(unique_id(), "Writing initial gain values..."); set_tx_gain(RHODIUM_DEFAULT_GAIN, 0); set_tx_lo_gain(RHODIUM_DEFAULT_LO_GAIN, RHODIUM_LO1, 0); @@ -225,17 +239,6 @@ void rhodium_radio_ctrl_impl::_init_peripherals() _update_tx_output_switches(RHODIUM_DEFAULT_TX_ANTENNA); _update_rx_input_switches(RHODIUM_DEFAULT_RX_ANTENNA); - _rx_fe_core = rx_frontend_core_3000::make(_get_ctrl(0), regs::sr_addr(RX_FE_BASE)); - _rx_fe_core->set_adc_rate(_master_clock_rate); - _rx_fe_core->set_dc_offset(rx_frontend_core_3000::DEFAULT_DC_OFFSET_VALUE); - _rx_fe_core->set_dc_offset_auto(rx_frontend_core_3000::DEFAULT_DC_OFFSET_ENABLE); - _rx_fe_core->populate_subtree(_tree->subtree(_root_path / "rx_fe_corrections" / 0)); - - _tx_fe_core = tx_frontend_core_200::make(_get_ctrl(0), regs::sr_addr(TX_FE_BASE)); - _tx_fe_core->set_dc_offset(tx_frontend_core_200::DEFAULT_DC_OFFSET_VALUE); - _tx_fe_core->set_iq_balance(tx_frontend_core_200::DEFAULT_IQ_BALANCE_VALUE); - _tx_fe_core->populate_subtree(_tree->subtree(_root_path / "tx_fe_corrections" / 0)); - UHD_LOG_TRACE(unique_id(), "Checking for existence of LO Distribution board"); _lo_dist_present = _rpcc->request_with_token<bool>(_rpc_prefix + "is_lo_dist_present"); UHD_LOG_DEBUG(unique_id(), str(boost::format("LO distribution board is%s present") % (_lo_dist_present ? "" : " NOT"))); @@ -290,7 +293,7 @@ void rhodium_radio_ctrl_impl::_init_frontend_subtree( }) ; subtree->create<std::vector<std::string>>(tx_fe_path / "antenna" / "options") - .set({RHODIUM_DEFAULT_TX_ANTENNA}) + .set(RHODIUM_TX_ANTENNAS) .add_coerced_subscriber([](const std::vector<std::string> &){ throw uhd::runtime_error( "Attempting to update antenna options!"); @@ -760,6 +763,27 @@ void rhodium_radio_ctrl_impl::_init_prop_tree() const fs_path fe_base = fs_path("dboards") / _radio_slot; this->_init_frontend_subtree(_tree->subtree(fe_base), 0); + // legacy EEPROM paths + auto eeprom_get = [this]() { + auto eeprom = dboard_eeprom_t(); + eeprom.id = boost::lexical_cast<uint16_t>(_dboard_info.at("pid")); + eeprom.revision = _dboard_info.at("rev"); + eeprom.serial = _dboard_info.at("serial"); + return eeprom; + }; + + auto eeprom_set = [](dboard_eeprom_t) { + throw uhd::not_implemented_error("Setting DB EEPROM from this interface not implemented"); + }; + + _tree->create<dboard_eeprom_t>(fe_base / "rx_eeprom") + .set_publisher(eeprom_get) + .add_coerced_subscriber(eeprom_set); + + _tree->create<dboard_eeprom_t>(fe_base / "tx_eeprom") + .set_publisher(eeprom_get) + .add_coerced_subscriber(eeprom_set); + // EEPROM paths subject to change FIXME _tree->create<eeprom_map_t>(_root_path / "eeprom") .set(eeprom_map_t()); diff --git a/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_lo.cpp b/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_lo.cpp index d05000cab..8567229d8 100644 --- a/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_lo.cpp +++ b/host/lib/usrp/dboard/rhodium/rhodium_radio_ctrl_lo.cpp @@ -264,6 +264,8 @@ void rhodium_radio_ctrl_impl::set_tx_lo_source( throw uhd::value_error(str(boost::format("set_tx_lo_source was called with an invalid LO source: %s Valid sources are [internal, external]") % src)); } + _update_corrections(src, get_tx_frequency(0), TX_DIRECTION); + _tx_lo_source = src; } @@ -293,6 +295,8 @@ void rhodium_radio_ctrl_impl::set_rx_lo_source( throw uhd::value_error(str(boost::format("set_rx_lo_source was called with an invalid LO source: %s Valid sources for LO1 are [internal, external]") % src)); } + _update_corrections(src, get_rx_frequency(0), RX_DIRECTION); + _rx_lo_source = src; } |