diff options
| author | mattprost <matt.prost@ni.com> | 2022-04-06 14:00:06 -0500 |
|---|---|---|
| committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-04-07 13:28:02 -0700 |
| commit | a8ad4917d331258e163e1786c0325a4b7e7d2e3e (patch) | |
| tree | b3cd5935981721f5ad98c11dad78122d013f7573 /host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp | |
| parent | eacbf15e30313793841ca6e4abd9cad02fffa5b4 (diff) | |
| download | uhd-a8ad4917d331258e163e1786c0325a4b7e7d2e3e.tar.gz uhd-a8ad4917d331258e163e1786c0325a4b7e7d2e3e.tar.bz2 uhd-a8ad4917d331258e163e1786c0325a4b7e7d2e3e.zip | |
n310: Add frontend bandwidth control
Allow users to control the Mykonos frontend bandwidth settings for
Rx and Tx. Note that this operation requires the daughterboard to
re-initialize, so it may take some time. Values for frontend filter
settings were derived using ADI's AD9371 Filter Wizard.
This feature requires MPM version 4.1 or later on the device.
Co-authored-by: bpadalino <bpadalino@gmail.com>
Signed-off-by: mattprost <matt.prost@ni.com>
Diffstat (limited to 'host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp')
| -rw-r--r-- | host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp | 81 |
1 files changed, 67 insertions, 14 deletions
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp index a2de485e3..8e2463721 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp @@ -122,6 +122,8 @@ magnesium_radio_control_impl::magnesium_radio_control_impl(make_args_ptr make_ar UHD_ASSERT_THROW(_n3xx_timekeeper); _rpcc = _n310_mb_control->get_rpc_client(); UHD_ASSERT_THROW(_rpcc); + _mpm_compat_num = _rpcc->request<std::vector<size_t>>("get_mpm_compat_num"); + UHD_ASSERT_THROW(_mpm_compat_num.size() == 2); _init_defaults(); _init_mpm(); @@ -356,28 +358,79 @@ double magnesium_radio_control_impl::set_rx_frequency( return radio_control_impl::get_rx_frequency(chan); } -double magnesium_radio_control_impl::set_rx_bandwidth( +double magnesium_radio_control_impl::set_tx_bandwidth( const double bandwidth, const size_t chan) { std::lock_guard<std::recursive_mutex> l(_set_lock); - _ad9371->set_bandwidth(bandwidth, chan, RX_DIRECTION); - // FIXME: setting analog bandwidth on AD9371 take no effect. - // Remove this warning when ADI can confirm that it works. - RFNOC_LOG_WARNING("set_rx_bandwidth take no effect on AD9371. " - "Default analog bandwidth is 100MHz"); - return AD9371_RX_MAX_BANDWIDTH; + + if (_mpm_compat_num[0] < 4 || (_mpm_compat_num[0] == 4 && _mpm_compat_num[1] < 1)) { + RFNOC_LOG_WARNING("Setting tx bandwidth not supported. Please upgrade MPM to a " + "minimum version of 4.1."); + radio_control_impl::set_tx_bandwidth(bandwidth, 1 - chan); + return radio_control_impl::set_tx_bandwidth(bandwidth, chan); + } + + const auto curr_bw = get_tx_bandwidth(chan); + if (fp_compare_epsilon<double>(curr_bw) == bandwidth) { + return curr_bw; + } + + // TX frontend components should be deactivated before running init_cals + const auto tx_atr_bits = + _cpld->get_tx_atr_bits(magnesium_cpld_ctrl::BOTH, magnesium_cpld_ctrl::IDLE); + _reset_tx_frontend(magnesium_cpld_ctrl::BOTH); + + RFNOC_LOG_INFO( + "Re-initializing dboard to apply bandwidth settings. This may take some time."); + const auto ret = _ad9371->set_bandwidth(bandwidth, chan, TX_DIRECTION); + RFNOC_LOG_INFO("Bandwidth settings applied: " + std::to_string(ret)); + + // Restore TX frontend components to previous state + _cpld->set_tx_atr_bits( + magnesium_cpld_ctrl::BOTH, magnesium_cpld_ctrl::IDLE, tx_atr_bits); + + // Save the updated bandwidth settings for both channels + radio_control_impl::set_tx_bandwidth(bandwidth, 1 - chan); + return radio_control_impl::set_tx_bandwidth(ret, chan); } -double magnesium_radio_control_impl::set_tx_bandwidth( +double magnesium_radio_control_impl::set_rx_bandwidth( const double bandwidth, const size_t chan) { std::lock_guard<std::recursive_mutex> l(_set_lock); - _ad9371->set_bandwidth(bandwidth, chan, TX_DIRECTION); - // FIXME: setting analog bandwidth on AD9371 take no effect. - // Remove this warning when ADI can confirm that it works. - RFNOC_LOG_WARNING("set_tx_bandwidth take no effect on AD9371. " - "Default analog bandwidth is 100MHz"); - return AD9371_TX_MAX_BANDWIDTH; + + if (_mpm_compat_num[0] < 4 || (_mpm_compat_num[0] == 4 && _mpm_compat_num[1] < 1)) { + RFNOC_LOG_WARNING("Setting rx bandwidth not supported. Please upgrade MPM to a " + "minimum version of 4.1."); + radio_control_impl::set_rx_bandwidth(bandwidth, 1 - chan); + return radio_control_impl::set_rx_bandwidth(bandwidth, chan); + } + + const auto curr_bw = get_rx_bandwidth(chan); + if (fp_compare_epsilon<double>(curr_bw) == bandwidth) { + return curr_bw; + } + + // TX frontend components should be deactivated before running init_cals + // + // We want to avoid any TX signals coming out of the frontend. This is + // necessary even during RX calibration. + const auto tx_atr_bits = + _cpld->get_tx_atr_bits(magnesium_cpld_ctrl::BOTH, magnesium_cpld_ctrl::IDLE); + _reset_tx_frontend(magnesium_cpld_ctrl::BOTH); + + RFNOC_LOG_INFO( + "Re-initializing dboard to apply bandwidth settings. This may take some time."); + const auto ret = _ad9371->set_bandwidth(bandwidth, chan, RX_DIRECTION); + RFNOC_LOG_INFO("Bandwidth settings applied: " + std::to_string(ret)); + + // Restore TX frontend components to previous state + _cpld->set_tx_atr_bits( + magnesium_cpld_ctrl::BOTH, magnesium_cpld_ctrl::IDLE, tx_atr_bits); + + // Save the updated bandwidth settings for both channels + radio_control_impl::set_rx_bandwidth(bandwidth, 1 - chan); + return radio_control_impl::set_rx_bandwidth(ret, chan); } double magnesium_radio_control_impl::set_tx_gain(const double gain, const size_t chan) |
