aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_cpld.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_cpld.cpp')
-rw-r--r--host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_cpld.cpp98
1 files changed, 51 insertions, 47 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 fd92500b0..8dfca2d6e 100644
--- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_cpld.cpp
+++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_cpld.cpp
@@ -8,38 +8,10 @@
#include "magnesium_cpld_ctrl.hpp"
#include "magnesium_constants.hpp"
#include <uhd/utils/log.hpp>
-#include <uhd/utils/math.hpp>
-/*
- * Magnesium Rev C frequency bands:
- *
- * RX IF frequency is 2.4418 GHz. Have 80 MHz of bandwidth for loband.
- * TX IF frequency is 1.8-2.1 GHz (1.95 GHz is best).
- *
- * For RX:
- * Band SW2-AB SW3-ABC SW4-ABC SW5-ABCD SW6-ABC SW7-AB SW8-AB MIX
- * WB RF1 01 OFF 111 NA --- NA ---- RF3 001 RF2 01 RF2 01 0
- * LB RF2 10 RF5 100 NA --- RF3 0010 RF1 100 RF1 10 RF1 10 1
- * 440-530 RF2 10 RF2 001 NA --- RF1 1000 RF1 100 RF2 01 RF2 01 0
- * 650-1000 RF2 10 RF6 101 NA --- RF4 0001 RF1 100 RF2 01 RF2 01 0
- * 1100-1575 RF2 10 RF4 011 NA --- RF2 0100 RF1 100 RF2 01 RF2 01 0
- * 1600-2250 RF2 10 RF3 010 RF2 010 NA ---- RF2 010 RF2 01 RF2 01 0
- * 2100-2850 RF2 10 RF1 000 RF1 100 NA ---- RF2 010 RF2 01 RF2 01 0
- * 2700+ RF3 11 OFF 111 RF3 001 NA ---- RF2 010 RF2 01 RF2 01 0
- *
- * For TX:
- * Band SW5-AB SW4-AB SW3-X SW2-ABCD SW1-AB SWTRX-AB MIX
- * WB RF1 10 RF2 01 RF1 0 NA ---- SHD 00 RF4 11 0
- * LB RF2 01 RF1 10 RF2 1 RF3 0010 RF3 11 RF1 00 1
- * <800 RF1 10 RF2 01 RF2 1 RF3 0010 RF3 11 RF1 00 0
- * 800-1700 RF1 10 RF2 01 RF2 1 RF2 0100 RF2 10 RF1 00 0
- * 1700-3400 RF1 10 RF2 01 RF2 1 RF1 1000 RF1 01 RF1 00 0
- * 3400-6400 RF1 10 RF2 01 RF2 1 RF4 0001 SHD 00 RF2 10 0
- */
using namespace uhd;
using namespace uhd::usrp;
using namespace uhd::rfnoc;
-using namespace uhd::math::fp_compare;
void magnesium_radio_ctrl_impl::_identify_with_leds(
const int identify_duration
@@ -171,61 +143,79 @@ void magnesium_radio_ctrl_impl::_update_rx_freq_switches(
auto rx_sw4 = magnesium_cpld_ctrl::RX_SW4_FILTER2100X2850MHZFROM;
auto rx_sw5 = magnesium_cpld_ctrl::RX_SW5_FILTER1100X1575MHZFROM;
auto rx_sw6 = magnesium_cpld_ctrl::RX_SW6_BYPASSPATHFROMSWITCH2;
- const auto select_lowband_mixer_path = (fp_compare_epsilon<double>(freq) < MAGNESIUM_LOWBAND_FREQ) ?
+ const auto band = _map_freq_to_rx_band(freq);
+ const bool is_lowband = (band == rx_band::LOWBAND);
+ const auto select_lowband_mixer_path = is_lowband ?
magnesium_cpld_ctrl::LOWBAND_MIXER_PATH_SEL_LOBAND :
magnesium_cpld_ctrl::LOWBAND_MIXER_PATH_SEL_BYPASS;
- const bool enable_lowband_mixer = (fp_compare_epsilon<double>(freq) < MAGNESIUM_LOWBAND_FREQ);
- const bool rx_lna2_enable =
- not bypass_lnas and (fp_compare_epsilon<double>(freq) < MAGNESIUM_RX_BAND4_MIN_FREQ);
+ const bool enable_lowband_mixer = is_lowband;
const bool rx_lna1_enable =
- not bypass_lnas and not rx_lna2_enable;
+ not bypass_lnas and (
+ band == rx_band::BAND4 or
+ band == rx_band::BAND5 or
+ band == rx_band::BAND6);
+ const bool rx_lna2_enable = not bypass_lnas and not rx_lna1_enable;
UHD_LOG_TRACE(unique_id(),
" Enabling LNA1: " << (rx_lna1_enable ? "Yes" : "No") <<
" Enabling LNA2: " << (rx_lna2_enable ? "Yes" : "No"));
// All the defaults are OK when using the bypass path.
if (not bypass_lnas) {
- if (fp_compare_epsilon<double>(freq) < MAGNESIUM_LOWBAND_FREQ) {
+ switch(band) {
+ case rx_band::BAND0:
rx_sw2 = magnesium_cpld_ctrl::RX_SW2_LOWERFILTERBANKTOSWITCH3;
rx_sw3 = magnesium_cpld_ctrl::RX_SW3_FILTER0490LPMHZ;
rx_sw4 = magnesium_cpld_ctrl::RX_SW4_FILTER2700HPMHZ;
rx_sw5 = magnesium_cpld_ctrl::RX_SW5_FILTER0490LPMHZFROM;
rx_sw6 = magnesium_cpld_ctrl::RX_SW6_LOWERFILTERBANKFROMSWITCH5;
- } else if (fp_compare_epsilon<double>(freq) < MAGNESIUM_RX_BAND2_MIN_FREQ) {
+ break;
+ case rx_band::BAND1:
rx_sw2 = magnesium_cpld_ctrl::RX_SW2_LOWERFILTERBANKTOSWITCH3;
rx_sw3 = magnesium_cpld_ctrl::RX_SW3_FILTER0440X0530MHZ;
rx_sw4 = magnesium_cpld_ctrl::RX_SW4_FILTER2700HPMHZ;
rx_sw5 = magnesium_cpld_ctrl::RX_SW5_FILTER0440X0530MHZFROM;
rx_sw6 = magnesium_cpld_ctrl::RX_SW6_LOWERFILTERBANKFROMSWITCH5;
- } else if (fp_compare_epsilon<double>(freq) < MAGNESIUM_RX_BAND3_MIN_FREQ) {
+ break;
+ case rx_band::BAND2:
rx_sw2 = magnesium_cpld_ctrl::RX_SW2_LOWERFILTERBANKTOSWITCH3;
rx_sw3 = magnesium_cpld_ctrl::RX_SW3_FILTER0650X1000MHZ;
rx_sw4 = magnesium_cpld_ctrl::RX_SW4_FILTER2700HPMHZ;
rx_sw5 = magnesium_cpld_ctrl::RX_SW5_FILTER0650X1000MHZFROM;
rx_sw6 = magnesium_cpld_ctrl::RX_SW6_LOWERFILTERBANKFROMSWITCH5;
- } else if (fp_compare_epsilon<double>(freq) < MAGNESIUM_RX_BAND4_MIN_FREQ) {
+ break;
+ case rx_band::BAND3:
rx_sw2 = magnesium_cpld_ctrl::RX_SW2_LOWERFILTERBANKTOSWITCH3;
rx_sw3 = magnesium_cpld_ctrl::RX_SW3_FILTER1100X1575MHZ;
rx_sw4 = magnesium_cpld_ctrl::RX_SW4_FILTER2700HPMHZ;
rx_sw5 = magnesium_cpld_ctrl::RX_SW5_FILTER1100X1575MHZFROM;
rx_sw6 = magnesium_cpld_ctrl::RX_SW6_LOWERFILTERBANKFROMSWITCH5;
- } else if (fp_compare_epsilon<double>(freq) < MAGNESIUM_RX_BAND5_MIN_FREQ) {
+ break;
+ case rx_band::BAND4:
rx_sw2 = magnesium_cpld_ctrl::RX_SW2_LOWERFILTERBANKTOSWITCH3;
rx_sw3 = magnesium_cpld_ctrl::RX_SW3_FILTER1600X2250MHZ;
rx_sw4 = magnesium_cpld_ctrl::RX_SW4_FILTER1600X2250MHZFROM;
rx_sw5 = magnesium_cpld_ctrl::RX_SW5_FILTER0440X0530MHZFROM;
rx_sw6 = magnesium_cpld_ctrl::RX_SW6_UPPERFILTERBANKFROMSWITCH4;
- } else if (fp_compare_epsilon<double>(freq) < MAGNESIUM_RX_BAND6_MIN_FREQ) {
+ break;
+ case rx_band::BAND5:
rx_sw2 = magnesium_cpld_ctrl::RX_SW2_LOWERFILTERBANKTOSWITCH3;
rx_sw3 = magnesium_cpld_ctrl::RX_SW3_FILTER2100X2850MHZ;
rx_sw4 = magnesium_cpld_ctrl::RX_SW4_FILTER2100X2850MHZFROM;
rx_sw5 = magnesium_cpld_ctrl::RX_SW5_FILTER0440X0530MHZFROM;
rx_sw6 = magnesium_cpld_ctrl::RX_SW6_UPPERFILTERBANKFROMSWITCH4;
- } else {
+ break;
+ case rx_band::BAND6:
rx_sw2 = magnesium_cpld_ctrl::RX_SW2_UPPERFILTERBANKTOSWITCH4;
rx_sw3 = magnesium_cpld_ctrl::RX_SW3_SHUTDOWNSW3;
rx_sw4 = magnesium_cpld_ctrl::RX_SW4_FILTER2700HPMHZ;
rx_sw5 = magnesium_cpld_ctrl::RX_SW5_FILTER0440X0530MHZFROM;
rx_sw6 = magnesium_cpld_ctrl::RX_SW6_UPPERFILTERBANKFROMSWITCH4;
+ break;
+ case rx_band::INVALID_BAND:
+ UHD_LOG_ERROR(unique_id(),
+ "Cannot map RX frequency to band: " << freq);
+ break;
+ default:
+ UHD_THROW_INVALID_CODE_PATH();
}
}
@@ -260,45 +250,59 @@ void magnesium_radio_ctrl_impl::_update_tx_freq_switches(
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;
- const auto select_lowband_mixer_path = (fp_compare_epsilon<double>(freq) < MAGNESIUM_LOWBAND_FREQ) ?
+ const auto band = _map_freq_to_tx_band(freq);
+ const bool is_lowband = (band == tx_band::LOWBAND);
+ const auto select_lowband_mixer_path = is_lowband ?
magnesium_cpld_ctrl::LOWBAND_MIXER_PATH_SEL_LOBAND :
magnesium_cpld_ctrl::LOWBAND_MIXER_PATH_SEL_BYPASS;
- const bool enable_lowband_mixer = (fp_compare_epsilon<double>(freq) < MAGNESIUM_LOWBAND_FREQ);
+ const bool enable_lowband_mixer = is_lowband;
// Defaults are fine for bypassing the amp stage
if (bypass_amp) {
_sw_trx[chan_sel] = magnesium_cpld_ctrl::SW_TRX_BYPASSPATHTOTXSW3;
} else {
// Set filters based on frequency
- if (fp_compare_epsilon<double>(freq) < MAGNESIUM_TX_BAND1_MIN_FREQ) {
+ switch(band) {
+ case tx_band::LOWBAND:
_sw_trx[chan_sel] =
magnesium_cpld_ctrl::SW_TRX_FROMLOWERFILTERBANKTXSW1;
tx_sw1 = magnesium_cpld_ctrl::TX_SW1_FROMTXFILTERLP0800MHZ;
tx_sw2 = magnesium_cpld_ctrl::TX_SW2_TOTXFILTERLP0800MHZ;
tx_sw3 = magnesium_cpld_ctrl::TX_SW3_TOTXFILTERBANKS;
- } else if (fp_compare_epsilon<double>(freq) < MAGNESIUM_TX_BAND2_MIN_FREQ) {
+ break;
+ case tx_band::BAND0:
_sw_trx[chan_sel] =
magnesium_cpld_ctrl::SW_TRX_FROMLOWERFILTERBANKTXSW1;
tx_sw1 = magnesium_cpld_ctrl::TX_SW1_FROMTXFILTERLP0800MHZ;
tx_sw2 = magnesium_cpld_ctrl::TX_SW2_TOTXFILTERLP0800MHZ;
tx_sw3 = magnesium_cpld_ctrl::TX_SW3_TOTXFILTERBANKS;
- } else if (fp_compare_epsilon<double>(freq) < MAGNESIUM_TX_BAND3_MIN_FREQ) {
+ break;
+ case tx_band::BAND1:
_sw_trx[chan_sel] =
magnesium_cpld_ctrl::SW_TRX_FROMLOWERFILTERBANKTXSW1;
tx_sw1 = magnesium_cpld_ctrl::TX_SW1_FROMTXFILTERLP1700MHZ;
tx_sw2 = magnesium_cpld_ctrl::TX_SW2_TOTXFILTERLP1700MHZ;
tx_sw3 = magnesium_cpld_ctrl::TX_SW3_TOTXFILTERBANKS;
- } else if (fp_compare_epsilon<double>(freq) < MAGNESIUM_TX_BAND4_MIN_FREQ) {
+ break;
+ case tx_band::BAND2:
_sw_trx[chan_sel] =
magnesium_cpld_ctrl::SW_TRX_FROMLOWERFILTERBANKTXSW1;
tx_sw1 = magnesium_cpld_ctrl::TX_SW1_FROMTXFILTERLP3400MHZ;
tx_sw2 = magnesium_cpld_ctrl::TX_SW2_TOTXFILTERLP3400MHZ;
tx_sw3 = magnesium_cpld_ctrl::TX_SW3_TOTXFILTERBANKS;
- } else {
+ break;
+ case tx_band::BAND3:
_sw_trx[chan_sel] =
magnesium_cpld_ctrl::SW_TRX_FROMTXUPPERFILTERBANKLP6400MHZ;
tx_sw1 = magnesium_cpld_ctrl::TX_SW1_SHUTDOWNTXSW1;
tx_sw2 = magnesium_cpld_ctrl::TX_SW2_TOTXFILTERLP6400MHZ;
tx_sw3 = magnesium_cpld_ctrl::TX_SW3_TOTXFILTERBANKS;
+ break;
+ case tx_band::INVALID_BAND:
+ UHD_LOG_ERROR(unique_id(),
+ "Cannot map TX frequency to band: " << freq);
+ break;
+ default:
+ UHD_THROW_INVALID_CODE_PATH();
}
}