diff options
4 files changed, 46 insertions, 36 deletions
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_cpld.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_cpld.cpp index 28bc7ec35..1c3016587 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_cpld.cpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_cpld.cpp @@ -131,13 +131,12 @@ void magnesium_radio_ctrl_impl::_update_atr_switches( void magnesium_radio_ctrl_impl::_update_rx_freq_switches( const double freq, const bool bypass_lnas, - const size_t chan + const magnesium_cpld_ctrl::chan_sel_t chan_sel ) { UHD_LOG_TRACE(unique_id(), "Update all RX freq related switches. f=" << freq << " Hz, " - "bypass LNAS: " << (bypass_lnas ? "Yes" : "No") << ", chan=" << chan + "bypass LNAS: " << (bypass_lnas ? "Yes" : "No") << ", chan=" << chan_sel ); - auto rx_sw2 = magnesium_cpld_ctrl::RX_SW2_BYPASSPATHTOSWITCH6; auto rx_sw3 = magnesium_cpld_ctrl::RX_SW3_SHUTDOWNSW3; auto rx_sw4 = magnesium_cpld_ctrl::RX_SW4_FILTER2100X2850MHZFROM; @@ -202,14 +201,14 @@ void magnesium_radio_ctrl_impl::_update_rx_freq_switches( } _cpld->set_rx_lna_atr_bits( - magnesium_cpld_ctrl::BOTH, + chan_sel, magnesium_cpld_ctrl::ANY, rx_lna1_enable, rx_lna2_enable, true /* defer commit */ ); _cpld->set_rx_switches( - magnesium_cpld_ctrl::BOTH, + chan_sel, rx_sw2, rx_sw3, rx_sw4, @@ -223,15 +222,12 @@ void magnesium_radio_ctrl_impl::_update_rx_freq_switches( void magnesium_radio_ctrl_impl::_update_tx_freq_switches( const double freq, const bool bypass_amp, - const size_t chan + const magnesium_cpld_ctrl::chan_sel_t chan_sel ){ UHD_LOG_TRACE(unique_id(), "Update all TX freq related switches. f=" << freq << " Hz, " - "bypass amp: " << (bypass_amp ? "Yes" : "No") << ", chan=" << chan + "bypass amp: " << (bypass_amp ? "Yes" : "No") << ", chan=" << chan_sel ); - magnesium_cpld_ctrl::chan_sel_t chan_sel = - _master ? magnesium_cpld_ctrl::CHAN1 : magnesium_cpld_ctrl::CHAN2; - auto tx_sw1 = magnesium_cpld_ctrl::TX_SW1_SHUTDOWNTXSW1; auto tx_sw2 = magnesium_cpld_ctrl::TX_SW2_TOTXFILTERLP6400MHZ; auto tx_sw3 = magnesium_cpld_ctrl::TX_SW3_BYPASSPATHTOTRXSW; @@ -278,13 +274,13 @@ void magnesium_radio_ctrl_impl::_update_tx_freq_switches( } _cpld->set_trx_sw_atr_bits( - magnesium_cpld_ctrl::BOTH, + chan_sel, magnesium_cpld_ctrl::ON, _sw_trx[chan_sel], true /* defer commit */ ); _cpld->set_tx_switches( - magnesium_cpld_ctrl::BOTH, + chan_sel, tx_sw1, tx_sw2, tx_sw3, diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_gain.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_gain.cpp index a8eb7c6fb..d7869a24a 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_gain.cpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_gain.cpp @@ -25,7 +25,9 @@ double magnesium_radio_ctrl_impl::_set_all_gain( "freq=" << freq << " Hz, " "chan=" << chan << ", " "dir=" << dir); - size_t ad9371_chan = _master?0:1; + const size_t ad9371_chan = _master ? 0 : 1; ;// FIXME: use chan when 2 radios + magnesium_cpld_ctrl::chan_sel_t chan_sel = + _master ? magnesium_cpld_ctrl::CHAN1 : magnesium_cpld_ctrl::CHAN2; const auto gain_tuple = get_gain_tuple(gain, freq, dir); const double ad9371_gain = ((dir == RX_DIRECTION) ? AD9371_MAX_RX_GAIN : AD9371_MAX_TX_GAIN) @@ -41,18 +43,18 @@ double magnesium_radio_ctrl_impl::_set_all_gain( _all_rx_gain = gain; _rx_bypass_lnas = gain_tuple.bypass; _update_rx_freq_switches( - radio_ctrl_impl::get_rx_frequency(chan), + this->get_rx_frequency(chan), _rx_bypass_lnas, - chan + chan_sel ); } if (dir == TX_DIRECTION or dir == DX_DIRECTION) { _all_tx_gain = gain; _tx_bypass_amp = gain_tuple.bypass; _update_tx_freq_switches( - radio_ctrl_impl::get_tx_frequency(chan), + this->get_tx_frequency(chan), _tx_bypass_amp, - chan + chan_sel ); } diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp index 3efe61676..c1fc055af 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp @@ -182,7 +182,7 @@ void magnesium_radio_ctrl_impl::set_rx_antenna( _master ? magnesium_cpld_ctrl::CHAN1 : magnesium_cpld_ctrl::CHAN2; _update_atr_switches(chan_sel, RX_DIRECTION, ant); - radio_ctrl_impl::set_rx_antenna(ant, chan); + radio_ctrl_impl::set_rx_antenna(ant, chan); // we don't use _master here since each radio has one antenna. } double magnesium_radio_ctrl_impl::set_tx_frequency( @@ -200,10 +200,14 @@ double magnesium_radio_ctrl_impl::set_tx_frequency( master_fe_base_path(_radio_slot) / fs_path("tx_frontends") / chan; UHD_LOG_DEBUG(unique_id(), "Slave setting TX frequency"); - _tree->access<double>(master_tx_fe_path / "freq" / "value").set(freq); - return _tree->access<double>(master_tx_fe_path / "freq" / "value").get(); + return _tree->access<double>(master_tx_fe_path / "freq" / "value") + .set(freq) + .get(); } - _update_tx_freq_switches(freq, _tx_bypass_amp, chan); + // We need to set the switches on both channels, because they share an LO. + // This way, if we tune channel 0 it will not put channel 1 into a bad + // state. + _update_tx_freq_switches(freq, _tx_bypass_amp, magnesium_cpld_ctrl::BOTH); //double ad9371_freq = freq; double if_freq = 0.0; auto lo_iface = _tx_lo; @@ -240,10 +244,14 @@ double magnesium_radio_ctrl_impl::set_rx_frequency( master_fe_base_path(_radio_slot) / fs_path("rx_frontends") / chan; UHD_LOG_DEBUG(unique_id(), "Slave setting RX frequency"); - _tree->access<double>(master_rx_fe_path / "freq" / "value").set(freq); - return _tree->access<double>(master_rx_fe_path / "freq" / "value").get(); + return _tree->access<double>(master_rx_fe_path / "freq" / "value") + .set(freq) + .get(); } - _update_rx_freq_switches(freq, _rx_bypass_lnas, chan); + // We need to set the switches on both channels, because they share an LO. + // This way, if we tune channel 0 it will not put channel 1 into a bad + // state. + _update_rx_freq_switches(freq, _rx_bypass_lnas, magnesium_cpld_ctrl::BOTH); //double ad9371_freq = freq; double if_freq = 0.0; auto lo_iface = _rx_lo; @@ -260,7 +268,7 @@ double magnesium_radio_ctrl_impl::set_rx_frequency( } //const double actual_ad9371_freq = - _ad9371->set_frequency(freq, chan, RX_DIRECTION); + _ad9371->set_frequency(freq, chan, RX_DIRECTION); radio_ctrl_impl::set_rx_frequency(freq, chan); return freq; // FIXME calc the actual frequency } @@ -276,7 +284,7 @@ double magnesium_radio_ctrl_impl::get_tx_frequency( UHD_LOG_TRACE(unique_id(), "Slave getting TX frequency"); return _tree->access<double>(master_tx_fe_path / "freq" / "value").get(); } - return radio_ctrl_impl::get_tx_frequency(chan); + return radio_ctrl_impl::get_tx_frequency(chan);// only master can get frequency chan here is always 0. } double magnesium_radio_ctrl_impl::get_rx_frequency( @@ -290,7 +298,7 @@ double magnesium_radio_ctrl_impl::get_rx_frequency( UHD_LOG_TRACE(unique_id(), "Slave getting RX frequency"); return _tree->access<double>(master_rx_fe_path / "freq" / "value").get(); } - return radio_ctrl_impl::get_rx_frequency(chan); + return radio_ctrl_impl::get_rx_frequency(chan); // only master can get frequency chan here is always 0. } double magnesium_radio_ctrl_impl::set_rx_bandwidth( @@ -313,13 +321,16 @@ double magnesium_radio_ctrl_impl::set_tx_gain( const double gain, const size_t chan ) { - radio_ctrl_impl::set_tx_gain(gain, chan); - return _set_all_gain( + UHD_LOG_TRACE(unique_id(), + "set_tx_gain(gain=" << gain << ", chan=" << chan << ")"); + const double coerced_gain = _set_all_gain( gain, - radio_ctrl_impl::get_tx_frequency(chan), + this->get_tx_frequency(chan), chan, TX_DIRECTION ); + radio_ctrl_impl::set_tx_gain(coerced_gain, chan); + return coerced_gain; } double magnesium_radio_ctrl_impl::set_rx_gain( @@ -328,13 +339,14 @@ double magnesium_radio_ctrl_impl::set_rx_gain( ) { UHD_LOG_TRACE(unique_id(), "set_rx_gain(gain=" << gain << ", chan=" << chan << ")"); - radio_ctrl_impl::set_rx_gain(gain, chan); - return _set_all_gain( + const double coerced_gain = _set_all_gain( gain, - radio_ctrl_impl::get_rx_frequency(chan), + this->get_rx_frequency(chan), chan, RX_DIRECTION ); + radio_ctrl_impl::set_rx_gain(coerced_gain, chan); + return coerced_gain; } std::vector<std::string> magnesium_radio_ctrl_impl::get_rx_lo_names( diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.hpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.hpp index f1543077c..aa70fa7ad 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.hpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.hpp @@ -48,7 +48,7 @@ public: /************************************************************************ * API calls ***********************************************************************/ - // Note: We use the cached values in radio_ctrl_impl, so most getters are + // Note: We use the cached values in radio_ctrl_impl, so most getters are // not reimplemented here double set_rate(double rate); @@ -174,13 +174,13 @@ private: void _update_rx_freq_switches( const double freq, const bool bypass_lnas, - const size_t chan + const magnesium_cpld_ctrl::chan_sel_t chan_sel ); void _update_tx_freq_switches( const double freq, const bool bypass_amps, - const size_t chan + const magnesium_cpld_ctrl::chan_sel_t chan_sel ); void _update_atr_switches( |