diff options
author | Martin Braun <martin.braun@ettus.com> | 2020-03-02 15:25:13 -0800 |
---|---|---|
committer | atrnati <54334261+atrnati@users.noreply.github.com> | 2020-03-03 08:51:32 -0600 |
commit | 876d4150aa3da531ddd687b48afada6e43f79146 (patch) | |
tree | fd72a71419f4cd800d4e500cfcaded4dfc8dc367 /host/lib/usrp/dboard/rhodium | |
parent | 1393553d623bdf4ba40d5435c9719b6ce990d9ac (diff) | |
download | uhd-876d4150aa3da531ddd687b48afada6e43f79146.tar.gz uhd-876d4150aa3da531ddd687b48afada6e43f79146.tar.bz2 uhd-876d4150aa3da531ddd687b48afada6e43f79146.zip |
uhd: Apply clang-format against all .cpp and .hpp files in host/
Note: template_lvbitx.{cpp,hpp} need to be excluded from the list of
files that clang-format gets applied against.
Diffstat (limited to 'host/lib/usrp/dboard/rhodium')
-rw-r--r-- | host/lib/usrp/dboard/rhodium/rhodium_bands.cpp | 101 | ||||
-rw-r--r-- | host/lib/usrp/dboard/rhodium/rhodium_constants.hpp | 51 | ||||
-rw-r--r-- | host/lib/usrp/dboard/rhodium/rhodium_cpld_ctrl.cpp | 411 | ||||
-rw-r--r-- | host/lib/usrp/dboard/rhodium/rhodium_cpld_ctrl.hpp | 217 | ||||
-rw-r--r-- | host/lib/usrp/dboard/rhodium/rhodium_radio_control.cpp | 94 | ||||
-rw-r--r-- | host/lib/usrp/dboard/rhodium/rhodium_radio_control.hpp | 81 |
6 files changed, 418 insertions, 537 deletions
diff --git a/host/lib/usrp/dboard/rhodium/rhodium_bands.cpp b/host/lib/usrp/dboard/rhodium/rhodium_bands.cpp index 9e0a1d3d3..9f72135dd 100644 --- a/host/lib/usrp/dboard/rhodium/rhodium_bands.cpp +++ b/host/lib/usrp/dboard/rhodium/rhodium_bands.cpp @@ -14,58 +14,58 @@ using namespace uhd::rfnoc; using namespace uhd::math::fp_compare; namespace { - constexpr double FREQ_COMPARE_EPSILON = 1e-5; +constexpr double FREQ_COMPARE_EPSILON = 1e-5; - /* Note on the RX filter bank: - * - * The RX path has 8 bands, which we call BAND0 through BAND7. BAND0 is the - * lowest frequency band. BAND7 is the highest frequency band. - * - * The following constants define lower cutoff frequencies for each band. - * RHODIUM_RX_BAND1_MIN_FREQ is the cutover frequency for switching from - * BAND0 to BAND1, and so on. - * - * Bands 1-7 have both high- and low-pass filters (effectively band - * passes). Band 0 has only low-pass filters. Frequencies have been - * chosen to allow as much of the full bandwidth through unattenuated. - * - * Switch selection logic for these bands can be found in - * rhodium_radio_control_impl::_update_rx_freq_switches() - */ - constexpr double RHODIUM_RX_BAND0_MIN_FREQ = RHODIUM_MIN_FREQ; - constexpr double RHODIUM_RX_BAND1_MIN_FREQ = 450e6; - constexpr double RHODIUM_RX_BAND2_MIN_FREQ = 760e6; - constexpr double RHODIUM_RX_BAND3_MIN_FREQ = 1100e6; - constexpr double RHODIUM_RX_BAND4_MIN_FREQ = 1410e6; - constexpr double RHODIUM_RX_BAND5_MIN_FREQ = 2050e6; - constexpr double RHODIUM_RX_BAND6_MIN_FREQ = 3000e6; - constexpr double RHODIUM_RX_BAND7_MIN_FREQ = 4500e6; +/* Note on the RX filter bank: + * + * The RX path has 8 bands, which we call BAND0 through BAND7. BAND0 is the + * lowest frequency band. BAND7 is the highest frequency band. + * + * The following constants define lower cutoff frequencies for each band. + * RHODIUM_RX_BAND1_MIN_FREQ is the cutover frequency for switching from + * BAND0 to BAND1, and so on. + * + * Bands 1-7 have both high- and low-pass filters (effectively band + * passes). Band 0 has only low-pass filters. Frequencies have been + * chosen to allow as much of the full bandwidth through unattenuated. + * + * Switch selection logic for these bands can be found in + * rhodium_radio_control_impl::_update_rx_freq_switches() + */ +constexpr double RHODIUM_RX_BAND0_MIN_FREQ = RHODIUM_MIN_FREQ; +constexpr double RHODIUM_RX_BAND1_MIN_FREQ = 450e6; +constexpr double RHODIUM_RX_BAND2_MIN_FREQ = 760e6; +constexpr double RHODIUM_RX_BAND3_MIN_FREQ = 1100e6; +constexpr double RHODIUM_RX_BAND4_MIN_FREQ = 1410e6; +constexpr double RHODIUM_RX_BAND5_MIN_FREQ = 2050e6; +constexpr double RHODIUM_RX_BAND6_MIN_FREQ = 3000e6; +constexpr double RHODIUM_RX_BAND7_MIN_FREQ = 4500e6; - /* Note on the TX filter bank: - * - * The TX path has 8 bands, which we call BAND0 through BAND7. BAND0 is the - * lowest frequency band. BAND7 is the highest frequency band. - * - * The following constants define lower cutoff frequencies for each band. - * RHODIUM_TX_BAND1_MIN_FREQ is the cutover frequency for switching from - * BAND0 to BAND1, and so on. - * - * All filters on the TX filter bank are low pass filters (no high pass - * filters). Frequencies have been chosen to allow as much of the full - * bandwidth through unattenuated. - * - * Switch selection logic for these bands can be found in - * rhodium_radio_control_impl::_update_tx_freq_switches() - */ - constexpr double RHODIUM_TX_BAND0_MIN_FREQ = RHODIUM_MIN_FREQ; - constexpr double RHODIUM_TX_BAND1_MIN_FREQ = 450e6; - constexpr double RHODIUM_TX_BAND2_MIN_FREQ = 650e6; - constexpr double RHODIUM_TX_BAND3_MIN_FREQ = 1000e6; - constexpr double RHODIUM_TX_BAND4_MIN_FREQ = 1350e6; - constexpr double RHODIUM_TX_BAND5_MIN_FREQ = 1900e6; - constexpr double RHODIUM_TX_BAND6_MIN_FREQ = 3000e6; - constexpr double RHODIUM_TX_BAND7_MIN_FREQ = 4100e6; -} +/* Note on the TX filter bank: + * + * The TX path has 8 bands, which we call BAND0 through BAND7. BAND0 is the + * lowest frequency band. BAND7 is the highest frequency band. + * + * The following constants define lower cutoff frequencies for each band. + * RHODIUM_TX_BAND1_MIN_FREQ is the cutover frequency for switching from + * BAND0 to BAND1, and so on. + * + * All filters on the TX filter bank are low pass filters (no high pass + * filters). Frequencies have been chosen to allow as much of the full + * bandwidth through unattenuated. + * + * Switch selection logic for these bands can be found in + * rhodium_radio_control_impl::_update_tx_freq_switches() + */ +constexpr double RHODIUM_TX_BAND0_MIN_FREQ = RHODIUM_MIN_FREQ; +constexpr double RHODIUM_TX_BAND1_MIN_FREQ = 450e6; +constexpr double RHODIUM_TX_BAND2_MIN_FREQ = 650e6; +constexpr double RHODIUM_TX_BAND3_MIN_FREQ = 1000e6; +constexpr double RHODIUM_TX_BAND4_MIN_FREQ = 1350e6; +constexpr double RHODIUM_TX_BAND5_MIN_FREQ = 1900e6; +constexpr double RHODIUM_TX_BAND6_MIN_FREQ = 3000e6; +constexpr double RHODIUM_TX_BAND7_MIN_FREQ = 4100e6; +} // namespace rhodium_radio_control_impl::rx_band rhodium_radio_control_impl::_map_freq_to_rx_band( const double freq) @@ -132,4 +132,3 @@ bool rhodium_radio_control_impl::_is_tx_lowband(const double freq) { return _map_freq_to_tx_band(freq) == tx_band::TX_BAND_0; } - diff --git a/host/lib/usrp/dboard/rhodium/rhodium_constants.hpp b/host/lib/usrp/dboard/rhodium/rhodium_constants.hpp index 69e6bf676..cc6a70dc3 100644 --- a/host/lib/usrp/dboard/rhodium/rhodium_constants.hpp +++ b/host/lib/usrp/dboard/rhodium/rhodium_constants.hpp @@ -8,9 +8,9 @@ #define INCLUDED_LIBUHD_RHODIUM_CONSTANTS_HPP #include <array> -#include <vector> -#include <string> #include <cstddef> +#include <string> +#include <vector> static constexpr double RHODIUM_FREQ_COMPARE_EPSILON = 1e-5; @@ -26,37 +26,34 @@ static constexpr double RHODIUM_LO1_MIN_FREQ = 450e6; // Hz static constexpr double RHODIUM_LO1_MAX_FREQ = 6e9; // Hz static constexpr double RHODIUM_LO1_REF_FREQ = 122.88e6; // Hz -static constexpr double RHODIUM_LO_0_9_GHZ_LPF_THRESHOLD_FREQ = 0.975e9; // Hz +static constexpr double RHODIUM_LO_0_9_GHZ_LPF_THRESHOLD_FREQ = 0.975e9; // Hz static constexpr double RHODIUM_LO_2_25_GHZ_LPF_THRESHOLD_FREQ = 2.3e9; // Hz static constexpr double RHODIUM_LOWBAND_FREQ = 450e6; // Hz -static constexpr double RHODIUM_RX_IF_FREQ = 2.44e9; // Hz -static constexpr double RHODIUM_TX_IF_FREQ = 1.95e9; // Hz +static constexpr double RHODIUM_RX_IF_FREQ = 2.44e9; // Hz +static constexpr double RHODIUM_TX_IF_FREQ = 1.95e9; // Hz -static constexpr double RX_MIN_GAIN = 0.0; -static constexpr double RX_MAX_GAIN = 60.0; +static constexpr double RX_MIN_GAIN = 0.0; +static constexpr double RX_MAX_GAIN = 60.0; static constexpr double RX_GAIN_STEP = 1.0; -static constexpr double TX_MIN_GAIN = 0.0; -static constexpr double TX_MAX_GAIN = 60.0; +static constexpr double TX_MIN_GAIN = 0.0; +static constexpr double TX_MAX_GAIN = 60.0; static constexpr double TX_GAIN_STEP = 1.0; -static constexpr double LO_MIN_GAIN = 0.0; -static constexpr double LO_MAX_GAIN = 30.0; +static constexpr double LO_MIN_GAIN = 0.0; +static constexpr double LO_MAX_GAIN = 30.0; static constexpr double LO_GAIN_STEP = 1.0; -static constexpr double LO_MIN_POWER = 0.0; -static constexpr double LO_MAX_POWER = 63.0; +static constexpr double LO_MIN_POWER = 0.0; +static constexpr double LO_MAX_POWER = 63.0; static constexpr double LO_POWER_STEP = 1.0; static constexpr double RHODIUM_DEFAULT_BANDWIDTH = 250e6; // Hz static const std::vector<std::string> RHODIUM_RX_ANTENNAS = { - "TX/RX", "RX2", "CAL", "TERM" -}; + "TX/RX", "RX2", "CAL", "TERM"}; -static const std::vector<std::string> RHODIUM_TX_ANTENNAS = { - "TX/RX", "CAL", "TERM" -}; +static const std::vector<std::string> RHODIUM_TX_ANTENNAS = {"TX/RX", "CAL", "TERM"}; // These names are taken from radio_rhodium.xml static constexpr char SPUR_DODGING_PROP_NAME[] = "spur_dodging"; @@ -69,13 +66,13 @@ static constexpr char RHODIUM_DEFAULT_HB_SPUR_REDUCTION_MODE[] = "disabled"; static constexpr char RHODIUM_FPGPIO_BANK[] = "FP0"; static constexpr uint32_t RHODIUM_GPIO_MASK = 0x1F; -static constexpr uint32_t SW10_GPIO_MASK = 0x3; -static constexpr uint32_t LED_GPIO_MASK = 0x1C; +static constexpr uint32_t SW10_GPIO_MASK = 0x3; +static constexpr uint32_t LED_GPIO_MASK = 0x1C; -static constexpr uint32_t SW10_FROMTXLOWBAND = 0x0; +static constexpr uint32_t SW10_FROMTXLOWBAND = 0x0; static constexpr uint32_t SW10_FROMTXHIGHBAND = 0x1; -static constexpr uint32_t SW10_ISOLATION = 0x2; -static constexpr uint32_t SW10_TORX = 0x3; +static constexpr uint32_t SW10_ISOLATION = 0x2; +static constexpr uint32_t SW10_TORX = 0x3; static constexpr uint32_t LED_RX = 0x04; static constexpr uint32_t LED_RX2 = 0x08; @@ -95,12 +92,8 @@ static constexpr char RHODIUM_LO_POWER[] = "lo"; static constexpr char RHODIUM_FE_NAME[] = "Rhodium"; static constexpr int NUM_LO_OUTPUT_PORT_NAMES = 4; -static constexpr std::array<const char*, NUM_LO_OUTPUT_PORT_NAMES> LO_OUTPUT_PORT_NAMES = { - "LO_OUT_0", - "LO_OUT_1", - "LO_OUT_2", - "LO_OUT_3" -}; +static constexpr std::array<const char*, NUM_LO_OUTPUT_PORT_NAMES> LO_OUTPUT_PORT_NAMES = + {"LO_OUT_0", "LO_OUT_1", "LO_OUT_2", "LO_OUT_3"}; static constexpr size_t RHODIUM_NUM_CHANS = 1; diff --git a/host/lib/usrp/dboard/rhodium/rhodium_cpld_ctrl.cpp b/host/lib/usrp/dboard/rhodium/rhodium_cpld_ctrl.cpp index 8d294bc48..0617cbd94 100644 --- a/host/lib/usrp/dboard/rhodium/rhodium_cpld_ctrl.cpp +++ b/host/lib/usrp/dboard/rhodium/rhodium_cpld_ctrl.cpp @@ -6,8 +6,8 @@ #include "rhodium_cpld_ctrl.hpp" #include "rhodium_constants.hpp" -#include <uhd/utils/math.hpp> #include <uhd/utils/log.hpp> +#include <uhd/utils/math.hpp> #include <boost/format.hpp> #include <chrono> @@ -15,115 +15,100 @@ using namespace uhd; using namespace uhd::math::fp_compare; namespace { - //! Address of the CPLD scratch register - constexpr uint8_t CPLD_REGS_SCRATCH = 0x05; - //! Address of the CPLD gain table selection register - constexpr uint8_t CPLD_REGS_GAIN_TBL_SEL = 0x06; - - constexpr uint32_t MAX_GAIN_INDEX = 60; - constexpr uint32_t MAX_LO_GAIN_INDEX = 30; - - //! RX Demodulator Adjustment thresholds - constexpr double RX_DEMOD_ADJ_1500OHM_THRESHOLD = 3e9; - constexpr double RX_DEMOD_ADJ_200OHM_THRESHOLD = 4.5e9; - - /* - Unlike other CPLD fields, gain control doesn't use a register and instead - commands are directly sent over SPI. The format of these 24-bit commands is - as follows. - 23:22 Table select (1 = RX, 2 = TX) - 21:16 Gain index - 15:14 Reserved - 13 Write enable for DSA1 - 12:7 Reserved - 6 Write enable for DSA2 - 5:0 Reserved - The CPLD replies with the current attenuation settings as follows, but we - ignore this reply in our code. - 23:13 Reserved - 12:7 Current attenuator setting for DSA1 - 6 Reserved - 5:0 Current attenuator setting for DSA2 - */ - //! Gain loader constants - constexpr size_t GAIN_CTRL_TABLE_FIELD = 22; - constexpr size_t GAIN_CTRL_INDEX_FIELD = 16; - constexpr size_t GAIN_CTRL_DSA1_FIELD = 13; - constexpr size_t GAIN_CTRL_DSA2_FIELD = 6; - - constexpr uint32_t GAIN_CTRL_TABLE_RX = 1; - constexpr uint32_t GAIN_CTRL_TABLE_TX = 2; - constexpr uint32_t GAIN_CTRL_DSA1_WRITE_ENABLE = 1; - constexpr uint32_t GAIN_CTRL_DSA2_WRITE_ENABLE = 1; - - /* - Similar to gain control, LO control doesn't use a register and instead - commands are directly sent over SPI. The format of these 24-bit commands is - as follows: - 23:22 Table select (Always 3 = LO) - 21:16 Attenuator setting - 15:14 Reserved - 13 Write enable for RX LO DSA - 12:7 Reserved - 6 Write enable for TX LO DSA - 5:0 Reserved - The CPLD replies with the current attenuator settings as follows, but we - ignore this reply in our code. - 23:13 Reserved - 12:7 Current attenuator setting for RX LO DSA - 6 Reserved - 5:0 Current attenuator setting for TX LO DSA - */ - //! LO Gain loader constants - constexpr size_t LO_GAIN_CTRL_TABLE_FIELD = 22; - constexpr size_t LO_GAIN_CTRL_INDEX_FIELD = 16; - constexpr size_t LO_GAIN_CTRL_RX_LO_FIELD = 13; - constexpr size_t LO_GAIN_CTRL_TX_LO_FIELD = 6; - - constexpr uint32_t LO_GAIN_CTRL_TABLE_LO = 3; - constexpr uint32_t LO_GAIN_CTRL_RX_LO_WRITE_ENABLE = 1; - constexpr uint32_t LO_GAIN_CTRL_RX_LO_WRITE_DISABLE = 0; - constexpr uint32_t LO_GAIN_CTRL_TX_LO_WRITE_ENABLE = 1; - constexpr uint32_t LO_GAIN_CTRL_TX_LO_WRITE_DISABLE = 0; -} - -rhodium_cpld_ctrl::rhodium_cpld_ctrl( - write_spi_t write_fn, - read_spi_t read_fn -) +//! Address of the CPLD scratch register +constexpr uint8_t CPLD_REGS_SCRATCH = 0x05; +//! Address of the CPLD gain table selection register +constexpr uint8_t CPLD_REGS_GAIN_TBL_SEL = 0x06; + +constexpr uint32_t MAX_GAIN_INDEX = 60; +constexpr uint32_t MAX_LO_GAIN_INDEX = 30; + +//! RX Demodulator Adjustment thresholds +constexpr double RX_DEMOD_ADJ_1500OHM_THRESHOLD = 3e9; +constexpr double RX_DEMOD_ADJ_200OHM_THRESHOLD = 4.5e9; + +/* +Unlike other CPLD fields, gain control doesn't use a register and instead +commands are directly sent over SPI. The format of these 24-bit commands is +as follows. + 23:22 Table select (1 = RX, 2 = TX) + 21:16 Gain index + 15:14 Reserved + 13 Write enable for DSA1 + 12:7 Reserved + 6 Write enable for DSA2 + 5:0 Reserved +The CPLD replies with the current attenuation settings as follows, but we +ignore this reply in our code. + 23:13 Reserved + 12:7 Current attenuator setting for DSA1 + 6 Reserved + 5:0 Current attenuator setting for DSA2 +*/ +//! Gain loader constants +constexpr size_t GAIN_CTRL_TABLE_FIELD = 22; +constexpr size_t GAIN_CTRL_INDEX_FIELD = 16; +constexpr size_t GAIN_CTRL_DSA1_FIELD = 13; +constexpr size_t GAIN_CTRL_DSA2_FIELD = 6; + +constexpr uint32_t GAIN_CTRL_TABLE_RX = 1; +constexpr uint32_t GAIN_CTRL_TABLE_TX = 2; +constexpr uint32_t GAIN_CTRL_DSA1_WRITE_ENABLE = 1; +constexpr uint32_t GAIN_CTRL_DSA2_WRITE_ENABLE = 1; + +/* +Similar to gain control, LO control doesn't use a register and instead +commands are directly sent over SPI. The format of these 24-bit commands is +as follows: + 23:22 Table select (Always 3 = LO) + 21:16 Attenuator setting + 15:14 Reserved + 13 Write enable for RX LO DSA + 12:7 Reserved + 6 Write enable for TX LO DSA + 5:0 Reserved +The CPLD replies with the current attenuator settings as follows, but we +ignore this reply in our code. + 23:13 Reserved + 12:7 Current attenuator setting for RX LO DSA + 6 Reserved + 5:0 Current attenuator setting for TX LO DSA +*/ +//! LO Gain loader constants +constexpr size_t LO_GAIN_CTRL_TABLE_FIELD = 22; +constexpr size_t LO_GAIN_CTRL_INDEX_FIELD = 16; +constexpr size_t LO_GAIN_CTRL_RX_LO_FIELD = 13; +constexpr size_t LO_GAIN_CTRL_TX_LO_FIELD = 6; + +constexpr uint32_t LO_GAIN_CTRL_TABLE_LO = 3; +constexpr uint32_t LO_GAIN_CTRL_RX_LO_WRITE_ENABLE = 1; +constexpr uint32_t LO_GAIN_CTRL_RX_LO_WRITE_DISABLE = 0; +constexpr uint32_t LO_GAIN_CTRL_TX_LO_WRITE_ENABLE = 1; +constexpr uint32_t LO_GAIN_CTRL_TX_LO_WRITE_DISABLE = 0; +} // namespace + +rhodium_cpld_ctrl::rhodium_cpld_ctrl(write_spi_t write_fn, read_spi_t read_fn) { - _write_reg_fn = [write_fn](const uint8_t addr, const uint32_t data){ + _write_reg_fn = [write_fn](const uint8_t addr, const uint32_t data) { UHD_LOG_TRACE("RH_CPLD", - str(boost::format("Writing to CPLD: 0x%02X -> 0x%04X") - % uint32_t(addr) % data)); - const uint32_t spi_transaction = 0 - | ((addr & 0x7F) << 17) - | data - ; - UHD_LOG_TRACE("RH_CPLD", - str(boost::format("SPI Transaction: 0x%04X") - % spi_transaction)); + str(boost::format("Writing to CPLD: 0x%02X -> 0x%04X") % uint32_t(addr) + % data)); + const uint32_t spi_transaction = 0 | ((addr & 0x7F) << 17) | data; + UHD_LOG_TRACE( + "RH_CPLD", str(boost::format("SPI Transaction: 0x%04X") % spi_transaction)); write_fn(spi_transaction); }; _write_raw_fn = [write_fn](const uint32_t data) { - UHD_LOG_TRACE("RH_CPLD", - str(boost::format("Writing to CPLD: 0x%06X") - % data)); - UHD_LOG_TRACE("RH_CPLD", - str(boost::format("SPI Transaction: 0x%06X") - % data)); + UHD_LOG_TRACE("RH_CPLD", str(boost::format("Writing to CPLD: 0x%06X") % data)); + UHD_LOG_TRACE("RH_CPLD", str(boost::format("SPI Transaction: 0x%06X") % data)); write_fn(data); }; - _read_reg_fn = [read_fn](const uint8_t addr){ + _read_reg_fn = [read_fn](const uint8_t addr) { UHD_LOG_TRACE("RH_CPLD", - str(boost::format("Reading from CPLD address 0x%02X") - % uint32_t(addr))); - const uint32_t spi_transaction = (1<<16) - | ((addr & 0x7F) << 17) - ; - UHD_LOG_TRACE("RH_CPLD", - str(boost::format("SPI Transaction: 0x%04X") - % spi_transaction)); + str(boost::format("Reading from CPLD address 0x%02X") % uint32_t(addr))); + const uint32_t spi_transaction = (1 << 16) | ((addr & 0x7F) << 17); + UHD_LOG_TRACE( + "RH_CPLD", str(boost::format("SPI Transaction: 0x%04X") % spi_transaction)); return read_fn(spi_transaction); }; @@ -162,26 +147,23 @@ uint16_t rhodium_cpld_ctrl::get_scratch() return get_reg(CPLD_REGS_SCRATCH); } -void rhodium_cpld_ctrl::set_tx_switches( - const tx_sw2_t tx_sw2, +void rhodium_cpld_ctrl::set_tx_switches(const tx_sw2_t tx_sw2, const tx_sw3_sw4_t tx_sw3_sw4, const tx_sw5_t tx_sw5, const tx_hb_lb_sel_t tx_hb_lb_sel, - const bool defer_commit -) { + const bool defer_commit) +{ UHD_LOG_TRACE("RH_CPLD", - "Configuring TX band selection switches."\ - " sw2=" << tx_sw2 << - " sw3_sw4=" << tx_sw3_sw4 << - " sw5=" << tx_sw5 << - " hb_lb_sel=" << tx_hb_lb_sel - ); + "Configuring TX band selection switches." + " sw2=" + << tx_sw2 << " sw3_sw4=" << tx_sw3_sw4 << " sw5=" << tx_sw5 + << " hb_lb_sel=" << tx_hb_lb_sel); std::lock_guard<std::mutex> l(_set_mutex); - _regs.tx_sw2 = rhodium_cpld_regs_t::tx_sw2_t(tx_sw2); - _regs.tx_sw3_sw4 = rhodium_cpld_regs_t::tx_sw3_sw4_t(tx_sw3_sw4); - _regs.tx_sw5 = rhodium_cpld_regs_t::tx_sw5_t(tx_sw5); + _regs.tx_sw2 = rhodium_cpld_regs_t::tx_sw2_t(tx_sw2); + _regs.tx_sw3_sw4 = rhodium_cpld_regs_t::tx_sw3_sw4_t(tx_sw3_sw4); + _regs.tx_sw5 = rhodium_cpld_regs_t::tx_sw5_t(tx_sw5); _regs.tx_hb_lb_sel = rhodium_cpld_regs_t::tx_hb_lb_sel_t(tx_hb_lb_sel); if (not defer_commit) { @@ -189,29 +171,25 @@ void rhodium_cpld_ctrl::set_tx_switches( } } -void rhodium_cpld_ctrl::set_rx_switches( - const rx_sw2_sw7_t rx_sw2_sw7, +void rhodium_cpld_ctrl::set_rx_switches(const rx_sw2_sw7_t rx_sw2_sw7, const rx_sw3_t rx_sw3, const rx_sw4_sw5_t rx_sw4_sw5, const rx_sw6_t rx_sw6, const rx_hb_lb_sel_t rx_hb_lb_sel, - const bool defer_commit -) { + const bool defer_commit) +{ UHD_LOG_TRACE("RH_CPLD", - "Configuring RX band selection switches."\ - " sw2_sw7=" << rx_sw2_sw7 << - " sw3=" << rx_sw3 << - " sw4_sw5=" << rx_sw4_sw5 << - " sw6=" << rx_sw6 << - " hb_lb_sel=" << rx_hb_lb_sel - ); + "Configuring RX band selection switches." + " sw2_sw7=" + << rx_sw2_sw7 << " sw3=" << rx_sw3 << " sw4_sw5=" << rx_sw4_sw5 + << " sw6=" << rx_sw6 << " hb_lb_sel=" << rx_hb_lb_sel); std::lock_guard<std::mutex> l(_set_mutex); - _regs.rx_sw2_sw7 = rhodium_cpld_regs_t::rx_sw2_sw7_t(rx_sw2_sw7); - _regs.rx_sw3 = rhodium_cpld_regs_t::rx_sw3_t(rx_sw3); - _regs.rx_sw4_sw5 = rhodium_cpld_regs_t::rx_sw4_sw5_t(rx_sw4_sw5); - _regs.rx_sw6 = rhodium_cpld_regs_t::rx_sw6_t(rx_sw6); + _regs.rx_sw2_sw7 = rhodium_cpld_regs_t::rx_sw2_sw7_t(rx_sw2_sw7); + _regs.rx_sw3 = rhodium_cpld_regs_t::rx_sw3_t(rx_sw3); + _regs.rx_sw4_sw5 = rhodium_cpld_regs_t::rx_sw4_sw5_t(rx_sw4_sw5); + _regs.rx_sw6 = rhodium_cpld_regs_t::rx_sw6_t(rx_sw6); _regs.rx_hb_lb_sel = rhodium_cpld_regs_t::rx_hb_lb_sel_t(rx_hb_lb_sel); if (not defer_commit) { @@ -220,19 +198,16 @@ void rhodium_cpld_ctrl::set_rx_switches( } void rhodium_cpld_ctrl::set_rx_input_switches( - const rx_sw1_t rx_sw1, - const cal_iso_sw_t cal_iso_sw, - const bool defer_commit -) { + const rx_sw1_t rx_sw1, const cal_iso_sw_t cal_iso_sw, const bool defer_commit) +{ UHD_LOG_TRACE("RH_CPLD", - "Configuring RX input selection switches."\ - " sw1=" << rx_sw1 << - " cal_iso=" << cal_iso_sw - ); + "Configuring RX input selection switches." + " sw1=" + << rx_sw1 << " cal_iso=" << cal_iso_sw); std::lock_guard<std::mutex> l(_set_mutex); - _regs.rx_sw1 = rhodium_cpld_regs_t::rx_sw1_t(rx_sw1); + _regs.rx_sw1 = rhodium_cpld_regs_t::rx_sw1_t(rx_sw1); _regs.cal_iso_sw = rhodium_cpld_regs_t::cal_iso_sw_t(cal_iso_sw); if (not defer_commit) { @@ -241,13 +216,12 @@ void rhodium_cpld_ctrl::set_rx_input_switches( } void rhodium_cpld_ctrl::set_tx_output_switches( - const tx_sw1_t tx_sw1, - const bool defer_commit -) { + const tx_sw1_t tx_sw1, const bool defer_commit) +{ UHD_LOG_TRACE("RH_CPLD", - "Configuring TX output selection switches."\ - " sw1=" << tx_sw1 - ); + "Configuring TX output selection switches." + " sw1=" + << tx_sw1); std::lock_guard<std::mutex> l(_set_mutex); @@ -259,9 +233,8 @@ void rhodium_cpld_ctrl::set_tx_output_switches( } void rhodium_cpld_ctrl::set_rx_lo_source( - const rx_lo_input_sel_t rx_lo_input_sel, - const bool defer_commit -) { + const rx_lo_input_sel_t rx_lo_input_sel, const bool defer_commit) +{ UHD_LOG_TRACE("RH_CPLD", "Setting RX LO source to " << rx_lo_input_sel); std::lock_guard<std::mutex> l(_set_mutex); @@ -273,9 +246,8 @@ void rhodium_cpld_ctrl::set_rx_lo_source( } void rhodium_cpld_ctrl::set_tx_lo_source( - const tx_lo_input_sel_t tx_lo_input_sel, - const bool defer_commit -) { + const tx_lo_input_sel_t tx_lo_input_sel, const bool defer_commit) +{ UHD_LOG_TRACE("RH_CPLD", "Setting TX LO source to " << tx_lo_input_sel); std::lock_guard<std::mutex> l(_set_mutex); @@ -286,29 +258,32 @@ void rhodium_cpld_ctrl::set_tx_lo_source( } } -void rhodium_cpld_ctrl::set_rx_lo_path( - const double freq, - const bool defer_commit -) { +void rhodium_cpld_ctrl::set_rx_lo_path(const double freq, const bool defer_commit) +{ UHD_LOG_TRACE("RH_CPLD", "Configuring RX LO filter and settings. freq=" << freq); std::lock_guard<std::mutex> l(_set_mutex); auto freq_compare = fp_compare_epsilon<double>(freq, RHODIUM_FREQ_COMPARE_EPSILON); if (freq_compare < RX_DEMOD_ADJ_1500OHM_THRESHOLD) { - _regs.rx_demod_adj = rhodium_cpld_regs_t::rx_demod_adj_t::RX_DEMOD_ADJ_RES_1500_OHM; + _regs.rx_demod_adj = + rhodium_cpld_regs_t::rx_demod_adj_t::RX_DEMOD_ADJ_RES_1500_OHM; } else if (freq_compare < RX_DEMOD_ADJ_200OHM_THRESHOLD) { - _regs.rx_demod_adj = rhodium_cpld_regs_t::rx_demod_adj_t::RX_DEMOD_ADJ_RES_200_OHM; + _regs.rx_demod_adj = + rhodium_cpld_regs_t::rx_demod_adj_t::RX_DEMOD_ADJ_RES_200_OHM; } else { _regs.rx_demod_adj = rhodium_cpld_regs_t::rx_demod_adj_t::RX_DEMOD_ADJ_RES_OPEN; } if (freq_compare < RHODIUM_LO_0_9_GHZ_LPF_THRESHOLD_FREQ) { - _regs.rx_lo_filter_sel = rhodium_cpld_regs_t::rx_lo_filter_sel_t::RX_LO_FILTER_SEL_0_9GHZ_LPF; + _regs.rx_lo_filter_sel = + rhodium_cpld_regs_t::rx_lo_filter_sel_t::RX_LO_FILTER_SEL_0_9GHZ_LPF; } else if (freq_compare < RHODIUM_LO_2_25_GHZ_LPF_THRESHOLD_FREQ) { - _regs.rx_lo_filter_sel = rhodium_cpld_regs_t::rx_lo_filter_sel_t::RX_LO_FILTER_SEL_2_25GHZ_LPF; + _regs.rx_lo_filter_sel = + rhodium_cpld_regs_t::rx_lo_filter_sel_t::RX_LO_FILTER_SEL_2_25GHZ_LPF; } else { - _regs.rx_lo_filter_sel = rhodium_cpld_regs_t::rx_lo_filter_sel_t::RX_LO_FILTER_SEL_5_85GHZ_LPF; + _regs.rx_lo_filter_sel = + rhodium_cpld_regs_t::rx_lo_filter_sel_t::RX_LO_FILTER_SEL_5_85GHZ_LPF; } if (not defer_commit) { @@ -316,21 +291,22 @@ void rhodium_cpld_ctrl::set_rx_lo_path( } } -void rhodium_cpld_ctrl::set_tx_lo_path( - const double freq, - const bool defer_commit -) { +void rhodium_cpld_ctrl::set_tx_lo_path(const double freq, const bool defer_commit) +{ UHD_LOG_TRACE("RH_CPLD", "Configuring TX LO filter and settings. freq=" << freq); std::lock_guard<std::mutex> l(_set_mutex); auto freq_compare = fp_compare_epsilon<double>(freq, RHODIUM_FREQ_COMPARE_EPSILON); if (freq_compare < RHODIUM_LO_0_9_GHZ_LPF_THRESHOLD_FREQ) { - _regs.tx_lo_filter_sel = rhodium_cpld_regs_t::tx_lo_filter_sel_t::TX_LO_FILTER_SEL_0_9GHZ_LPF; + _regs.tx_lo_filter_sel = + rhodium_cpld_regs_t::tx_lo_filter_sel_t::TX_LO_FILTER_SEL_0_9GHZ_LPF; } else if (freq_compare < RHODIUM_LO_2_25_GHZ_LPF_THRESHOLD_FREQ) { - _regs.tx_lo_filter_sel = rhodium_cpld_regs_t::tx_lo_filter_sel_t::TX_LO_FILTER_SEL_2_25GHZ_LPF; + _regs.tx_lo_filter_sel = + rhodium_cpld_regs_t::tx_lo_filter_sel_t::TX_LO_FILTER_SEL_2_25GHZ_LPF; } else { - _regs.tx_lo_filter_sel = rhodium_cpld_regs_t::tx_lo_filter_sel_t::TX_LO_FILTER_SEL_5_85GHZ_LPF; + _regs.tx_lo_filter_sel = + rhodium_cpld_regs_t::tx_lo_filter_sel_t::TX_LO_FILTER_SEL_5_85GHZ_LPF; } if (not defer_commit) { @@ -338,43 +314,35 @@ void rhodium_cpld_ctrl::set_tx_lo_path( } } -void rhodium_cpld_ctrl::set_gain_index( - const uint32_t index, +void rhodium_cpld_ctrl::set_gain_index(const uint32_t index, const gain_band_t band, const uhd::direction_t dir, - const bool defer_commit -) { + const bool defer_commit) +{ UHD_ASSERT_THROW(index <= MAX_GAIN_INDEX); UHD_ASSERT_THROW(dir == RX_DIRECTION or dir == TX_DIRECTION); - if (band == HIGH) - { - if (dir == RX_DIRECTION) - { + if (band == HIGH) { + if (dir == RX_DIRECTION) { _regs.rx_gain_tbl_sel = rhodium_cpld_regs_t::RX_GAIN_TBL_SEL_HIGHBAND; - } - else { + } else { _regs.tx_gain_tbl_sel = rhodium_cpld_regs_t::TX_GAIN_TBL_SEL_HIGHBAND; } } else { - if (dir == RX_DIRECTION) - { + if (dir == RX_DIRECTION) { _regs.rx_gain_tbl_sel = rhodium_cpld_regs_t::RX_GAIN_TBL_SEL_LOWBAND; - } - else { + } else { _regs.tx_gain_tbl_sel = rhodium_cpld_regs_t::TX_GAIN_TBL_SEL_LOWBAND; } } - const uint8_t table_id = (dir == RX_DIRECTION) ? - GAIN_CTRL_TABLE_RX : - GAIN_CTRL_TABLE_TX; + const uint8_t table_id = (dir == RX_DIRECTION) ? GAIN_CTRL_TABLE_RX + : GAIN_CTRL_TABLE_TX; - const uint32_t cmd = - (table_id << GAIN_CTRL_TABLE_FIELD) | - (index << GAIN_CTRL_INDEX_FIELD) | - (GAIN_CTRL_DSA1_WRITE_ENABLE << GAIN_CTRL_DSA1_FIELD) | - (GAIN_CTRL_DSA2_WRITE_ENABLE << GAIN_CTRL_DSA2_FIELD); + const uint32_t cmd = (table_id << GAIN_CTRL_TABLE_FIELD) + | (index << GAIN_CTRL_INDEX_FIELD) + | (GAIN_CTRL_DSA1_WRITE_ENABLE << GAIN_CTRL_DSA1_FIELD) + | (GAIN_CTRL_DSA2_WRITE_ENABLE << GAIN_CTRL_DSA2_FIELD); std::lock_guard<std::mutex> l(_set_mutex); _gain_queue.emplace_back(cmd); @@ -385,28 +353,25 @@ void rhodium_cpld_ctrl::set_gain_index( } void rhodium_cpld_ctrl::set_lo_gain( - const uint32_t index, - const uhd::direction_t dir, - const bool defer_commit -) { + const uint32_t index, const uhd::direction_t dir, const bool defer_commit) +{ UHD_ASSERT_THROW(index <= MAX_LO_GAIN_INDEX); // The DSA has 0-30 dB of attenuation in 1 dB steps // This index directly controls the attenuation value of the LO DSA, // so reverse the gain value to write the value const uint32_t attenuation = MAX_LO_GAIN_INDEX - index; - const uint8_t set_rx = (dir == RX_DIRECTION or dir == DX_DIRECTION) ? - LO_GAIN_CTRL_RX_LO_WRITE_ENABLE : - LO_GAIN_CTRL_RX_LO_WRITE_DISABLE; - const uint8_t set_tx = (dir == TX_DIRECTION or dir == DX_DIRECTION) ? - LO_GAIN_CTRL_TX_LO_WRITE_ENABLE : - LO_GAIN_CTRL_TX_LO_WRITE_DISABLE; - - const uint32_t cmd = - (LO_GAIN_CTRL_TABLE_LO << LO_GAIN_CTRL_TABLE_FIELD) | - (attenuation << LO_GAIN_CTRL_INDEX_FIELD) | - (set_rx << LO_GAIN_CTRL_RX_LO_FIELD) | - (set_tx << LO_GAIN_CTRL_TX_LO_FIELD); + const uint8_t set_rx = (dir == RX_DIRECTION or dir == DX_DIRECTION) + ? LO_GAIN_CTRL_RX_LO_WRITE_ENABLE + : LO_GAIN_CTRL_RX_LO_WRITE_DISABLE; + const uint8_t set_tx = (dir == TX_DIRECTION or dir == DX_DIRECTION) + ? LO_GAIN_CTRL_TX_LO_WRITE_ENABLE + : LO_GAIN_CTRL_TX_LO_WRITE_DISABLE; + + const uint32_t cmd = (LO_GAIN_CTRL_TABLE_LO << LO_GAIN_CTRL_TABLE_FIELD) + | (attenuation << LO_GAIN_CTRL_INDEX_FIELD) + | (set_rx << LO_GAIN_CTRL_RX_LO_FIELD) + | (set_tx << LO_GAIN_CTRL_TX_LO_FIELD); std::lock_guard<std::mutex> l(_set_mutex); _gain_queue.emplace_back(cmd); @@ -431,9 +396,7 @@ void rhodium_cpld_ctrl::_loopback_test() if (actual != random_number) { UHD_LOGGER_ERROR("RH_CPLD") << "CPLD scratch loopback failed! " - << boost::format("Expected: 0x%04X Got: 0x%04X") - % random_number % actual - ; + << boost::format("Expected: 0x%04X Got: 0x%04X") % random_number % actual; throw uhd::runtime_error("CPLD scratch loopback failed!"); } UHD_LOG_TRACE("RH_CPLD", "CPLD scratch loopback test passed!"); @@ -442,33 +405,27 @@ void rhodium_cpld_ctrl::_loopback_test() void rhodium_cpld_ctrl::commit(const bool save_all) { UHD_LOGGER_TRACE("RH_CPLD") - << "Storing register cache " - << (save_all ? "completely" : "selectively") - << " to CPLD via SPI..." - ; - auto changed_addrs = save_all ? - _regs.get_all_addrs() : - _regs.get_changed_addrs<size_t>(); - for (const auto addr: changed_addrs) { + << "Storing register cache " << (save_all ? "completely" : "selectively") + << " to CPLD via SPI..."; + auto changed_addrs = save_all ? _regs.get_all_addrs() + : _regs.get_changed_addrs<size_t>(); + for (const auto addr : changed_addrs) { _write_reg_fn(addr, _regs.get_reg(addr)); } _regs.save_state(); UHD_LOG_TRACE("RH_CPLD", - "Storing cache complete: " \ - "Updated " << changed_addrs.size() << " registers.") - ; + "Storing cache complete: " + "Updated " + << changed_addrs.size() << " registers."); - UHD_LOGGER_TRACE("RH_CPLD") - << "Writing queued gain commands " - << "to CPLD via SPI..." - ; + UHD_LOGGER_TRACE("RH_CPLD") << "Writing queued gain commands " + << "to CPLD via SPI..."; for (const auto cmd : _gain_queue) { _write_raw_fn(cmd); } UHD_LOG_TRACE("RH_CPLD", - "Writing queued gain commands complete: " \ - "Wrote " << _gain_queue.size() << " commands.") - ; + "Writing queued gain commands complete: " + "Wrote " + << _gain_queue.size() << " commands."); _gain_queue.clear(); } - diff --git a/host/lib/usrp/dboard/rhodium/rhodium_cpld_ctrl.hpp b/host/lib/usrp/dboard/rhodium/rhodium_cpld_ctrl.hpp index d60ae6e66..18b0b8c78 100644 --- a/host/lib/usrp/dboard/rhodium/rhodium_cpld_ctrl.hpp +++ b/host/lib/usrp/dboard/rhodium/rhodium_cpld_ctrl.hpp @@ -38,14 +38,14 @@ public: }; enum tx_sw1_t { - TX_SW1_TOLOWBAND = 0, - TX_SW1_TOSWITCH2 = 1, + TX_SW1_TOLOWBAND = 0, + TX_SW1_TOSWITCH2 = 1, TX_SW1_TOCALLOOPBACK = 2, - TX_SW1_ISOLATION = 3 + TX_SW1_ISOLATION = 3 }; enum tx_sw2_t { - TX_SW2_FROMSWITCH3 = 0, + TX_SW2_FROMSWITCH3 = 0, TX_SW2_FROMTXFILTERLP6000MHZ = 1, TX_SW2_FROMTXFILTERLP4100MHZ = 2, TX_SW2_FROMTXFILTERLP3000MHZ = 3 @@ -62,23 +62,23 @@ public: TX_SW5_TOTXFILTERLP3000MHZ = 0, TX_SW5_TOTXFILTERLP4100MHZ = 1, TX_SW5_TOTXFILTERLP6000MHZ = 2, - TX_SW5_TOSWITCH4 = 3 + TX_SW5_TOSWITCH4 = 3 }; enum rx_sw1_t { RX_SW1_FROMCALLOOPBACK = 0, - RX_SW1_FROMRX2INPUT = 1, - RX_SW1_ISOLATION = 2, - RX_SW1_FROMTXRXINPUT = 3 + RX_SW1_FROMRX2INPUT = 1, + RX_SW1_ISOLATION = 2, + RX_SW1_FROMTXRXINPUT = 3 }; enum rx_sw2_sw7_t { - RX_SW2_SW7_LOWBANDFILTERBANK = 0, + RX_SW2_SW7_LOWBANDFILTERBANK = 0, RX_SW2_SW7_HIGHBANDFILTERBANK = 1 }; enum rx_sw3_t { - RX_SW3_TOSWITCH4 = 0, + RX_SW3_TOSWITCH4 = 0, RX_SW3_TOFILTER4500X6000MHZ = 1, RX_SW3_TOFILTER3000X4500MHZ = 2, RX_SW3_TOFILTER2050X3000MHZ = 3 @@ -95,52 +95,33 @@ public: RX_SW6_FROMFILTER2050X3000MHZ = 0, RX_SW6_FROMFILTER3000X4500MHZ = 1, RX_SW6_FROMFILTER4500X6000MHZ = 2, - RX_SW6_FROMSWITCH5 = 3, + RX_SW6_FROMSWITCH5 = 3, }; - enum cal_iso_sw_t { - CAL_ISO_ISOLATION = 0, - CAL_ISO_CALLOOPBACK = 1 - }; + enum cal_iso_sw_t { CAL_ISO_ISOLATION = 0, CAL_ISO_CALLOOPBACK = 1 }; - enum tx_hb_lb_sel_t { - TX_HB_LB_SEL_LOWBAND = 0, - TX_HB_LB_SEL_HIGHBAND = 1 - }; + enum tx_hb_lb_sel_t { TX_HB_LB_SEL_LOWBAND = 0, TX_HB_LB_SEL_HIGHBAND = 1 }; - enum tx_lo_input_sel_t { - TX_LO_INPUT_SEL_INTERNAL = 0, - TX_LO_INPUT_SEL_EXTERNAL = 1 - }; + enum tx_lo_input_sel_t { TX_LO_INPUT_SEL_INTERNAL = 0, TX_LO_INPUT_SEL_EXTERNAL = 1 }; - enum rx_hb_lb_sel_t { - RX_HB_LB_SEL_LOWBAND = 0, - RX_HB_LB_SEL_HIGHBAND = 1 - }; + enum rx_hb_lb_sel_t { RX_HB_LB_SEL_LOWBAND = 0, RX_HB_LB_SEL_HIGHBAND = 1 }; - enum rx_lo_input_sel_t { - RX_LO_INPUT_SEL_INTERNAL = 1, - RX_LO_INPUT_SEL_EXTERNAL = 0 - }; + enum rx_lo_input_sel_t { RX_LO_INPUT_SEL_INTERNAL = 1, RX_LO_INPUT_SEL_EXTERNAL = 0 }; - enum rx_demod_adj { - RX_DEMOD_OPEN = 0, - RX_DEMOD_200OHM = 1, - RX_DEMOD_1500OHM = 2 - }; + enum rx_demod_adj { RX_DEMOD_OPEN = 0, RX_DEMOD_200OHM = 1, RX_DEMOD_1500OHM = 2 }; enum tx_lo_filter_sel_t { - TX_LO_FILTER_SEL_0_9GHZ_LPF = 0, + TX_LO_FILTER_SEL_0_9GHZ_LPF = 0, TX_LO_FILTER_SEL_5_85GHZ_LPF = 1, TX_LO_FILTER_SEL_2_25GHZ_LPF = 2, - TX_LO_FILTER_SEL_ISOLATION = 3 + TX_LO_FILTER_SEL_ISOLATION = 3 }; enum rx_lo_filter_sel_t { - RX_LO_FILTER_SEL_0_9GHZ_LPF = 0, + RX_LO_FILTER_SEL_0_9GHZ_LPF = 0, RX_LO_FILTER_SEL_5_85GHZ_LPF = 1, RX_LO_FILTER_SEL_2_25GHZ_LPF = 2, - RX_LO_FILTER_SEL_ISOLATION = 3 + RX_LO_FILTER_SEL_ISOLATION = 3 }; /*! Constructor. @@ -148,10 +129,7 @@ public: * \param write_spi_fn SPI write function * \param read_spi_fn SPI read function */ - rhodium_cpld_ctrl( - write_spi_t write_spi_fn, - read_spi_t read_spi_fn - ); + rhodium_cpld_ctrl(write_spi_t write_spi_fn, read_spi_t read_spi_fn); /************************************************************************** * API @@ -187,13 +165,11 @@ public: * \param tx_hb_lb_sel Power on the highband or lowband amplifier * \param tx_lo_filter_sel Select LPF filter for LO */ - void set_tx_switches( - const tx_sw2_t tx_sw2, + void set_tx_switches(const tx_sw2_t tx_sw2, const tx_sw3_sw4_t tx_sw3_sw4, const tx_sw5_t tx_sw5, const tx_hb_lb_sel_t tx_hb_lb_sel, - const bool defer_commit = false - ); + const bool defer_commit = false); /*! Frequency-related settings, receive side * @@ -204,14 +180,12 @@ public: * \param rx_hb_lb_sel Power on the highband or lowband amplifier * \param rx_lo_filter_sel Select LPF filter for LO */ - void set_rx_switches( - const rx_sw2_sw7_t rx_sw2_sw7, + void set_rx_switches(const rx_sw2_sw7_t rx_sw2_sw7, const rx_sw3_t rx_sw3, const rx_sw4_sw5_t rx_sw4_sw5, const rx_sw6_t rx_sw6, const rx_hb_lb_sel_t rx_hb_lb_sel, - const bool defer_commit = false - ); + const bool defer_commit = false); /*! Input switches for RX side * @@ -220,91 +194,72 @@ public: * \param rx_sw1 Input selection of RX path * \param cal_iso_sw Terminates the calibration loopback path */ - void set_rx_input_switches( - const rx_sw1_t rx_sw1, + void set_rx_input_switches(const rx_sw1_t rx_sw1, const cal_iso_sw_t cal_iso_sw, - const bool defer_commit = false - ); - - /*! Output switches for TX side - * - * Note: These are not frequency dependent. - * - * \param tx_sw1 Output selection of TX path - */ - void set_tx_output_switches( - const tx_sw1_t tx_sw1, - const bool defer_commit = false - ); - - /*! Input switch for RX LO - * - * \param rx_lo_input_sel Selects RX LO source - */ + const bool defer_commit = false); + + /*! Output switches for TX side + * + * Note: These are not frequency dependent. + * + * \param tx_sw1 Output selection of TX path + */ + void set_tx_output_switches(const tx_sw1_t tx_sw1, const bool defer_commit = false); + + /*! Input switch for RX LO + * + * \param rx_lo_input_sel Selects RX LO source + */ void set_rx_lo_source( - const rx_lo_input_sel_t rx_lo_input_sel, - const bool defer_commit = false - ); - - /*! Input switch for TX LO - * - * \param tx_lo_input_sel Selects TX LO source - */ + const rx_lo_input_sel_t rx_lo_input_sel, const bool defer_commit = false); + + /*! Input switch for TX LO + * + * \param tx_lo_input_sel Selects TX LO source + */ void set_tx_lo_source( - const tx_lo_input_sel_t tx_lo_input_sel, - const bool defer_commit = false - ); - - /*! Configure RX LO filter, synth, and mixer settings - * - * \param freq RX LO Frequency - */ - void set_rx_lo_path( - const double freq, - const bool defer_commit = false - ); - - /*! Configure TX LO filter, synth, and mixer settings - * - * \param freq TX LO Frequency - */ - void set_tx_lo_path( - const double freq, - const bool defer_commit = false - ); - - - /*! Gain index setting for the RF frontend - * - * Sets the gain index to one of the predefined values that have been - * loaded into the CPLD by gain table loader in MPM. - * - * \param index Index of the gain table entry to apply (0-60) - * \param band Selects which table to use (lowband or highband) - * \param dir Selects which RF frontend to apply to (RX or TX) - */ - void set_gain_index( - const uint32_t index, + const tx_lo_input_sel_t tx_lo_input_sel, const bool defer_commit = false); + + /*! Configure RX LO filter, synth, and mixer settings + * + * \param freq RX LO Frequency + */ + void set_rx_lo_path(const double freq, const bool defer_commit = false); + + /*! Configure TX LO filter, synth, and mixer settings + * + * \param freq TX LO Frequency + */ + void set_tx_lo_path(const double freq, const bool defer_commit = false); + + + /*! Gain index setting for the RF frontend + * + * Sets the gain index to one of the predefined values that have been + * loaded into the CPLD by gain table loader in MPM. + * + * \param index Index of the gain table entry to apply (0-60) + * \param band Selects which table to use (lowband or highband) + * \param dir Selects which RF frontend to apply to (RX or TX) + */ + void set_gain_index(const uint32_t index, const gain_band_t band, const uhd::direction_t dir, - const bool defer_commit = false - ); - - /*! Gain setting for LO1 - * - * Sets the attenuation of the RX LO1 DSA or TX LO1 DSA. - * - * Note: This function uses gain as a parameter, although it is - * setting an attenuation. - * - * \param index Gain value to apply (0-30) - * \param dir Selects which LO to apply to (RX, TX, or DX) - */ - void set_lo_gain( - const uint32_t index, + const bool defer_commit = false); + + /*! Gain setting for LO1 + * + * Sets the attenuation of the RX LO1 DSA or TX LO1 DSA. + * + * Note: This function uses gain as a parameter, although it is + * setting an attenuation. + * + * \param index Gain value to apply (0-30) + * \param dir Selects which LO to apply to (RX, TX, or DX) + */ + void set_lo_gain(const uint32_t index, const uhd::direction_t dir, - const bool defer_commit = false - ); + const bool defer_commit = false); private: //! Write function: Take address / data pair, craft SPI transaction diff --git a/host/lib/usrp/dboard/rhodium/rhodium_radio_control.cpp b/host/lib/usrp/dboard/rhodium/rhodium_radio_control.cpp index 54c6333bc..f8ec47c18 100644 --- a/host/lib/usrp/dboard/rhodium/rhodium_radio_control.cpp +++ b/host/lib/usrp/dboard/rhodium/rhodium_radio_control.cpp @@ -18,9 +18,9 @@ #include <uhdlib/utils/narrow.hpp> #include <boost/algorithm/string.hpp> #include <boost/format.hpp> -#include <memory> #include <cmath> #include <cstdlib> +#include <memory> #include <sstream> using namespace uhd; @@ -29,16 +29,16 @@ using namespace uhd::rfnoc; using namespace uhd::math::fp_compare; namespace { - constexpr char RX_FE_CONNECTION_LOWBAND[] = "QI"; - constexpr char RX_FE_CONNECTION_HIGHBAND[] = "IQ"; - constexpr char TX_FE_CONNECTION_LOWBAND[] = "QI"; - constexpr char TX_FE_CONNECTION_HIGHBAND[] = "IQ"; +constexpr char RX_FE_CONNECTION_LOWBAND[] = "QI"; +constexpr char RX_FE_CONNECTION_HIGHBAND[] = "IQ"; +constexpr char TX_FE_CONNECTION_LOWBAND[] = "QI"; +constexpr char TX_FE_CONNECTION_HIGHBAND[] = "IQ"; - constexpr double DEFAULT_IDENTIFY_DURATION = 5.0; // seconds +constexpr double DEFAULT_IDENTIFY_DURATION = 5.0; // seconds - constexpr uint64_t SET_RATE_RPC_TIMEOUT_MS = 10000; +constexpr uint64_t SET_RATE_RPC_TIMEOUT_MS = 10000; -} +} // namespace /****************************************************************************** @@ -51,8 +51,7 @@ rhodium_radio_control_impl::rhodium_radio_control_impl(make_args_ptr make_args) UHD_ASSERT_THROW(get_block_id().get_block_count() < 2); const char radio_slot_name[] = {'A', 'B'}; _radio_slot = radio_slot_name[get_block_id().get_block_count()]; - _rpc_prefix = - (_radio_slot == "A") ? "db_0_" : "db_1_"; + _rpc_prefix = (_radio_slot == "A") ? "db_0_" : "db_1_"; RFNOC_LOG_TRACE("Radio slot: " << _radio_slot); UHD_ASSERT_THROW(get_num_input_ports() == RHODIUM_NUM_CHANS); UHD_ASSERT_THROW(get_num_output_ports() == RHODIUM_NUM_CHANS); @@ -207,14 +206,12 @@ double rhodium_radio_control_impl::set_tx_frequency(const double freq, const siz const bool is_highband = !_is_tx_lowband(coerced_target_freq); - const double target_lo_freq = is_highband ? - coerced_target_freq : _get_lowband_lo_freq() - coerced_target_freq; - const double actual_lo_freq = - set_tx_lo_freq(target_lo_freq, RHODIUM_LO1, chan); - const double coerced_freq = is_highband ? - actual_lo_freq : _get_lowband_lo_freq() - actual_lo_freq; - const auto conn = is_highband ? - TX_FE_CONNECTION_HIGHBAND : TX_FE_CONNECTION_LOWBAND; + const double target_lo_freq = + is_highband ? coerced_target_freq : _get_lowband_lo_freq() - coerced_target_freq; + const double actual_lo_freq = set_tx_lo_freq(target_lo_freq, RHODIUM_LO1, chan); + const double coerced_freq = is_highband ? actual_lo_freq + : _get_lowband_lo_freq() - actual_lo_freq; + const auto conn = is_highband ? TX_FE_CONNECTION_HIGHBAND : TX_FE_CONNECTION_LOWBAND; // update the cached frequency value now so calls to set gain and update // switches will read the new frequency @@ -224,7 +221,8 @@ double rhodium_radio_control_impl::set_tx_frequency(const double freq, const siz set_tx_gain(radio_control_impl::get_tx_gain(chan), 0); if (_get_highband_spur_reduction_enabled(TX_DIRECTION)) { - if (_get_timed_command_enabled() and _is_tx_lowband(old_freq) != not is_highband) { + if (_get_timed_command_enabled() + and _is_tx_lowband(old_freq) != not is_highband) { RFNOC_LOG_WARNING( "Timed tuning commands that transition between lowband and highband, 450 " "MHz, do not function correctly when highband_spur_reduction is enabled! " @@ -260,14 +258,12 @@ double rhodium_radio_control_impl::set_rx_frequency(const double freq, const siz const bool is_highband = !_is_rx_lowband(coerced_target_freq); - const double target_lo_freq = is_highband ? - coerced_target_freq : _get_lowband_lo_freq() - coerced_target_freq; - const double actual_lo_freq = - set_rx_lo_freq(target_lo_freq, RHODIUM_LO1, chan); - const double coerced_freq = is_highband ? - actual_lo_freq : _get_lowband_lo_freq() - actual_lo_freq; - const auto conn = is_highband ? - RX_FE_CONNECTION_HIGHBAND : RX_FE_CONNECTION_LOWBAND; + const double target_lo_freq = + is_highband ? coerced_target_freq : _get_lowband_lo_freq() - coerced_target_freq; + const double actual_lo_freq = set_rx_lo_freq(target_lo_freq, RHODIUM_LO1, chan); + const double coerced_freq = is_highband ? actual_lo_freq + : _get_lowband_lo_freq() - actual_lo_freq; + const auto conn = is_highband ? RX_FE_CONNECTION_HIGHBAND : RX_FE_CONNECTION_LOWBAND; // update the cached frequency value now so calls to set gain and update // switches will read the new frequency @@ -277,7 +273,8 @@ double rhodium_radio_control_impl::set_rx_frequency(const double freq, const siz set_rx_gain(radio_control_impl::get_rx_gain(chan), 0); if (_get_highband_spur_reduction_enabled(RX_DIRECTION)) { - if (_get_timed_command_enabled() and _is_rx_lowband(old_freq) != not is_highband) { + if (_get_timed_command_enabled() + and _is_rx_lowband(old_freq) != not is_highband) { RFNOC_LOG_WARNING( "Timed tuning commands that transition between lowband and highband, 450 " "MHz, do not function correctly when highband_spur_reduction is enabled! " @@ -313,17 +310,17 @@ double rhodium_radio_control_impl::set_tx_gain(const double gain, const size_t c RFNOC_LOG_TRACE("set_tx_gain(gain=" << gain << ", chan=" << chan << ")"); UHD_ASSERT_THROW(chan == 0); - auto freq = this->get_tx_frequency(chan); + auto freq = this->get_tx_frequency(chan); auto index = get_tx_gain_range(chan).clip(gain); - auto old_band = _is_tx_lowband(_tx_frequency_at_last_gain_write) ? - rhodium_cpld_ctrl::gain_band_t::LOW : - rhodium_cpld_ctrl::gain_band_t::HIGH; - auto new_band = _is_tx_lowband(freq) ? - rhodium_cpld_ctrl::gain_band_t::LOW : - rhodium_cpld_ctrl::gain_band_t::HIGH; + auto old_band = _is_tx_lowband(_tx_frequency_at_last_gain_write) + ? rhodium_cpld_ctrl::gain_band_t::LOW + : rhodium_cpld_ctrl::gain_band_t::HIGH; + auto new_band = _is_tx_lowband(freq) ? rhodium_cpld_ctrl::gain_band_t::LOW + : rhodium_cpld_ctrl::gain_band_t::HIGH; - // The CPLD requires a rewrite of the gain control command on a change of lowband or highband + // The CPLD requires a rewrite of the gain control command on a change of lowband or + // highband if (radio_control_impl::get_tx_gain(chan) != index or old_band != new_band) { RFNOC_LOG_TRACE("Writing new TX gain index: " << index); _cpld->set_gain_index(index, new_band, TX_DIRECTION); @@ -342,17 +339,17 @@ double rhodium_radio_control_impl::set_rx_gain(const double gain, const size_t c RFNOC_LOG_TRACE("set_rx_gain(gain=" << gain << ", chan=" << chan << ")"); UHD_ASSERT_THROW(chan == 0); - auto freq = this->get_rx_frequency(chan); + auto freq = this->get_rx_frequency(chan); auto index = get_rx_gain_range(chan).clip(gain); - auto old_band = _is_rx_lowband(_rx_frequency_at_last_gain_write) ? - rhodium_cpld_ctrl::gain_band_t::LOW : - rhodium_cpld_ctrl::gain_band_t::HIGH; - auto new_band = _is_rx_lowband(freq) ? - rhodium_cpld_ctrl::gain_band_t::LOW : - rhodium_cpld_ctrl::gain_band_t::HIGH; + auto old_band = _is_rx_lowband(_rx_frequency_at_last_gain_write) + ? rhodium_cpld_ctrl::gain_band_t::LOW + : rhodium_cpld_ctrl::gain_band_t::HIGH; + auto new_band = _is_rx_lowband(freq) ? rhodium_cpld_ctrl::gain_band_t::LOW + : rhodium_cpld_ctrl::gain_band_t::HIGH; - // The CPLD requires a rewrite of the gain control command on a change of lowband or highband + // The CPLD requires a rewrite of the gain control command on a change of lowband or + // highband if (radio_control_impl::get_rx_gain(chan) != index or old_band != new_band) { RFNOC_LOG_TRACE("Writing new RX gain index: " << index); _cpld->set_gain_index(index, new_band, RX_DIRECTION); @@ -398,13 +395,13 @@ void rhodium_radio_control_impl::_update_atr( const auto rx_ant = (dir == RX_DIRECTION) ? ant : get_rx_antenna(0); const auto tx_ant = (dir == TX_DIRECTION) ? ant : get_tx_antenna(0); - const auto sw10_tx = _is_tx_lowband(get_tx_frequency(0)) ? - SW10_FROMTXLOWBAND : SW10_FROMTXHIGHBAND; + const auto sw10_tx = _is_tx_lowband(get_tx_frequency(0)) ? SW10_FROMTXLOWBAND + : SW10_FROMTXHIGHBAND; const uint32_t atr_idle = SW10_ISOLATION; - const uint32_t atr_rx = [rx_ant]{ + const uint32_t atr_rx = [rx_ant] { if (rx_ant == "TX/RX") { return SW10_TORX | LED_RX; } else if (rx_ant == "RX2") { @@ -414,8 +411,7 @@ void rhodium_radio_control_impl::_update_atr( } }(); - const uint32_t atr_tx = (tx_ant == "TX/RX") ? - (sw10_tx | LED_TX) : SW10_ISOLATION; + const uint32_t atr_tx = (tx_ant == "TX/RX") ? (sw10_tx | LED_TX) : SW10_ISOLATION; const uint32_t atr_dx = [tx_ant, rx_ant, sw10_tx] { uint32_t sw10_return; diff --git a/host/lib/usrp/dboard/rhodium/rhodium_radio_control.hpp b/host/lib/usrp/dboard/rhodium/rhodium_radio_control.hpp index 8cee33f17..4d2bc38ad 100644 --- a/host/lib/usrp/dboard/rhodium/rhodium_radio_control.hpp +++ b/host/lib/usrp/dboard/rhodium/rhodium_radio_control.hpp @@ -71,8 +71,8 @@ public: double set_rate(double rate); // Setters - void set_tx_antenna(const std::string &ant, const size_t chan); - void set_rx_antenna(const std::string &ant, const size_t chan); + void set_tx_antenna(const std::string& ant, const size_t chan); + void set_rx_antenna(const std::string& ant, const size_t chan); double set_tx_frequency(const double freq, const size_t chan); double set_rx_frequency(const double freq, const size_t chan); void set_tx_tune_args(const uhd::device_addr_t&, const size_t chan); @@ -163,8 +163,10 @@ public: * ??? calls ***********************************************************************/ // LO Distribution Control - void set_tx_lo_output_enabled(const bool enabled, const std::string& port_name, const size_t chan); - void set_rx_lo_output_enabled(const bool enabled, const std::string& port_name, const size_t chan); + void set_tx_lo_output_enabled( + const bool enabled, const std::string& port_name, const size_t chan); + void set_rx_lo_output_enabled( + const bool enabled, const std::string& port_name, const size_t chan); bool get_tx_lo_output_enabled(const std::string& port_name, const size_t chan); bool get_rx_lo_output_enabled(const std::string& port_name, const size_t chan); @@ -172,27 +174,29 @@ public: //! Set the external gain for a TX LO // Out of range values will be coerced - double set_tx_lo_gain(const double gain, const std::string &name, const size_t chan); + double set_tx_lo_gain(const double gain, const std::string& name, const size_t chan); //! Set the external gain for an RX LO // Out of range values will be coerced - double set_rx_lo_gain(const double gain, const std::string &name, const size_t chan); + double set_rx_lo_gain(const double gain, const std::string& name, const size_t chan); - double get_tx_lo_gain(const std::string &name, const size_t chan); - double get_rx_lo_gain(const std::string &name, const size_t chan); + double get_tx_lo_gain(const std::string& name, const size_t chan); + double get_rx_lo_gain(const std::string& name, const size_t chan); // LO Output Power Control //! Set the output power setting of a TX LO // Out of range values will be coerced - double set_tx_lo_power(const double power, const std::string &name, const size_t chan); + double set_tx_lo_power( + const double power, const std::string& name, const size_t chan); //! Set the output power setting of a RX LO // Out of range values will be coerced - double set_rx_lo_power(const double power, const std::string &name, const size_t chan); + double set_rx_lo_power( + const double power, const std::string& name, const size_t chan); - double get_tx_lo_power(const std::string &name, const size_t chan); - double get_rx_lo_power(const std::string &name, const size_t chan); + double get_tx_lo_power(const std::string& name, const size_t chan); + double get_rx_lo_power(const std::string& name, const size_t chan); private: @@ -239,42 +243,28 @@ private: void _init_mpm_sensors(const direction_t dir, const size_t chan_idx); //! Get the frequency range for an LO - freq_range_t _get_lo_freq_range(const std::string &name) const; + freq_range_t _get_lo_freq_range(const std::string& name) const; //! Get the current lowband intermediate frequency double _get_lowband_lo_freq() const; //! Configure LO1's export - void _set_lo1_export_enabled( - const bool enabled, - const direction_t dir - ); + void _set_lo1_export_enabled(const bool enabled, const direction_t dir); //! Validate that port_name is valid, and that LO distribution functions // can be called in this instance void _validate_output_port( - const std::string& port_name, - const std::string& function_name - ); + const std::string& port_name, const std::string& function_name); //! Configure LO Distribution board's termination switches void _set_lo_output_enabled( - const bool enabled, - const std::string& port_name, - const direction_t dir - ); + const bool enabled, const std::string& port_name, const direction_t dir); - bool _get_lo_output_enabled( - const std::string& port_name, - const direction_t dir - ); + bool _get_lo_output_enabled(const std::string& port_name, const direction_t dir); //! Configure LO1's output power // Out of range values will be coerced to [0-63] - double _set_lo1_power( - const double power, - const direction_t dir - ); + double _set_lo1_power(const double power, const direction_t dir); //! Flash all front end LEDs at 1 Hz for the specified amount of time void _identify_with_leds(double identify_duration); @@ -328,29 +318,21 @@ private: * Frontend Controls *************************************************************************/ - void _set_tx_fe_connection(const std::string &conn); - void _set_rx_fe_connection(const std::string &conn); + void _set_tx_fe_connection(const std::string& conn); + void _set_rx_fe_connection(const std::string& conn); std::string _get_tx_fe_connection() const; std::string _get_rx_fe_connection() const; /************************************************************************** * CPLD Controls (implemented in rhodium_radio_ctrl_cpld.cpp) *************************************************************************/ - void _update_rx_freq_switches( - const double freq - ); + void _update_rx_freq_switches(const double freq); - void _update_tx_freq_switches( - const double freq - ); + void _update_tx_freq_switches(const double freq); - void _update_rx_input_switches( - const std::string &input - ); + void _update_rx_input_switches(const std::string& input); - void _update_tx_output_switches( - const std::string &output - ); + void _update_tx_output_switches(const std::string& output); /************************************************************************** * Private attributes @@ -412,7 +394,7 @@ private: //! Saved frontend connection for DSP core std::string _rx_fe_connection; std::string _tx_fe_connection; - //! Desired RF frequency + //! Desired RF frequency std::map<direction_t, double> _desired_rf_freq = { {RX_DIRECTION, 2.44e9}, {TX_DIRECTION, 2.44e9}}; //! Frequency at which gain setting was last applied. The CPLD requires a new gain @@ -446,8 +428,8 @@ private: bool _lo_dist_present = false; //! LO Distribution board output status - bool _lo_dist_rx_out_enabled[4] = { false, false, false, false }; - bool _lo_dist_tx_out_enabled[4] = { false, false, false, false }; + bool _lo_dist_rx_out_enabled[4] = {false, false, false, false}; + bool _lo_dist_tx_out_enabled[4] = {false, false, false, false}; std::unordered_map<uhd::direction_t, uhd::device_addr_t, std::hash<size_t>> _tune_args{{uhd::RX_DIRECTION, uhd::device_addr_t()}, @@ -477,4 +459,3 @@ private: }} /* namespace uhd::rfnoc */ #endif /* INCLUDED_LIBUHD_RFNOC_RHODIUM_RADIO_CTRL_IMPL_HPP */ - |