diff options
author | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-14 10:35:25 -0800 |
---|---|---|
committer | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-16 11:40:23 -0800 |
commit | 967be2a4e82b1a125b26bb72a60318a4fb2b50c4 (patch) | |
tree | 8a24954b54d1546dc8049a17e485adb0a605f74f /host/lib/usrp/dboard/neon | |
parent | aafe4e8b742a0e21d3818f21f34e3c8613132530 (diff) | |
download | uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.tar.gz uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.tar.bz2 uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.zip |
uhd: mpm: apply clang-format to all files
Applying formatting changes to all .cpp and .hpp files in the following
directories:
```
find host/examples/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/tests/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/lib/usrp/dboard/neon/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/lib/usrp/dboard/magnesium/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/lib/usrp/device3/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/lib/usrp/mpmd/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/lib/usrp/x300/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find host/utils/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
find mpm/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
```
Also formatted host/include/, except Cpp03 was used as a the language
standard instead of Cpp11.
```
sed -i 's/ Cpp11/ Cpp03/g' .clang-format
find host/include/ -iname *.hpp -o -iname *.cpp | \
xargs clang-format -i -style=file
```
Formatting style was designated by the .clang-format file.
Diffstat (limited to 'host/lib/usrp/dboard/neon')
-rw-r--r-- | host/lib/usrp/dboard/neon/neon_ad9361_iface.cpp | 69 | ||||
-rw-r--r-- | host/lib/usrp/dboard/neon/neon_bands.cpp | 101 | ||||
-rw-r--r-- | host/lib/usrp/dboard/neon/neon_constants.hpp | 38 | ||||
-rw-r--r-- | host/lib/usrp/dboard/neon/neon_radio_ctrl_impl.cpp | 519 | ||||
-rw-r--r-- | host/lib/usrp/dboard/neon/neon_radio_ctrl_impl.hpp | 127 | ||||
-rw-r--r-- | host/lib/usrp/dboard/neon/neon_radio_ctrl_init.cpp | 477 | ||||
-rw-r--r-- | host/lib/usrp/dboard/neon/neon_regs.hpp | 17 |
7 files changed, 580 insertions, 768 deletions
diff --git a/host/lib/usrp/dboard/neon/neon_ad9361_iface.cpp b/host/lib/usrp/dboard/neon/neon_ad9361_iface.cpp index e19f890ca..a9cf28fc2 100644 --- a/host/lib/usrp/dboard/neon/neon_ad9361_iface.cpp +++ b/host/lib/usrp/dboard/neon/neon_ad9361_iface.cpp @@ -14,38 +14,33 @@ using namespace uhd; class neon_ad9361_iface : public ad9361_ctrl { public: - neon_ad9361_iface( - rpc_client::sptr rpcc - ) : _rpcc(rpcc) - , _rpc_prefix("db_0_") - , _log_prefix("AD9361") + neon_ad9361_iface(rpc_client::sptr rpcc) + : _rpcc(rpcc), _rpc_prefix("db_0_"), _log_prefix("AD9361") { - UHD_LOG_TRACE(_log_prefix, - "Initialized controls with RPC prefix " << _rpc_prefix); + UHD_LOG_TRACE( + _log_prefix, "Initialized controls with RPC prefix " << _rpc_prefix); } - double set_bw_filter(const std::string &which, const double bw) + double set_bw_filter(const std::string& which, const double bw) { return _rpcc->request_with_token<double>( this->_rpc_prefix + "set_bw_filter", which, bw); } - double set_gain(const std::string &which, const double value) + double set_gain(const std::string& which, const double value) { return _rpcc->request_with_token<double>( this->_rpc_prefix + "set_gain", which, value); } - void set_agc(const std::string &which, bool enable) + void set_agc(const std::string& which, bool enable) { - _rpcc->request_with_token<void>( - this->_rpc_prefix + "set_agc", which, enable); + _rpcc->request_with_token<void>(this->_rpc_prefix + "set_agc", which, enable); } - void set_agc_mode(const std::string &which, const std::string &mode) + void set_agc_mode(const std::string& which, const std::string& mode) { - _rpcc->request_with_token<void>( - this->_rpc_prefix + "set_agc_mode", which, mode); + _rpcc->request_with_token<void>(this->_rpc_prefix + "set_agc_mode", which, mode); } double set_clock_rate(const double rate) @@ -60,43 +55,41 @@ public: this->_rpc_prefix + "set_active_chains", tx1, tx2, rx1, rx2); } - double tune(const std::string &which, const double value) + double tune(const std::string& which, const double value) { return _rpcc->request_with_token<double>( this->_rpc_prefix + "tune", which, value); } - void set_dc_offset_auto(const std::string &which, const bool on) + void set_dc_offset_auto(const std::string& which, const bool on) { _rpcc->request_with_token<void>( this->_rpc_prefix + "set_dc_offset_auto", which, on); } - void set_timing_mode(const std::string &timing_mode) + void set_timing_mode(const std::string& timing_mode) { _rpcc->request_with_token<void>( this->_rpc_prefix + "set_timing_mode", timing_mode); } - void set_iq_balance_auto(const std::string &which, const bool on) + void set_iq_balance_auto(const std::string& which, const bool on) { _rpcc->request_with_token<void>( this->_rpc_prefix + "set_iq_balance_auto", which, on); } - double get_freq(const std::string &which) + double get_freq(const std::string& which) { - return _rpcc->request_with_token<double>( - this->_rpc_prefix + "get_freq", which); + return _rpcc->request_with_token<double>(this->_rpc_prefix + "get_freq", which); } void data_port_loopback(const bool on) { - _rpcc->request_with_token<void>( - this->_rpc_prefix + "data_port_loopback", on); + _rpcc->request_with_token<void>(this->_rpc_prefix + "data_port_loopback", on); } - sensor_value_t get_rssi(const std::string &which) + sensor_value_t get_rssi(const std::string& which) { return sensor_value_t(_rpcc->request_with_token<sensor_value_t::sensor_map_t>( this->_rpc_prefix + "get_rssi", which)); @@ -108,23 +101,25 @@ public: this->_rpc_prefix + "get_temperature")); } - std::vector<std::string> get_filter_names(const std::string &which) + std::vector<std::string> get_filter_names(const std::string& which) { return _rpcc->request_with_token<std::vector<std::string>>( this->_rpc_prefix + "get_filter_names", which); } - filter_info_base::sptr get_filter(const std::string &/*which*/, - const std::string &/*filter_name*/) + filter_info_base::sptr get_filter( + const std::string& /*which*/, const std::string& /*filter_name*/) { - throw uhd::runtime_error("ad9361_ctrl::get_filter is not supported over an RPC connection"); + throw uhd::runtime_error( + "ad9361_ctrl::get_filter is not supported over an RPC connection"); } - void set_filter(const std::string &/*which*/, - const std::string &/*filter_name*/, - const filter_info_base::sptr /*filter*/) + void set_filter(const std::string& /*which*/, + const std::string& /*filter_name*/, + const filter_info_base::sptr /*filter*/) { - throw uhd::runtime_error("ad9361_ctrl::set_filter is not supported over an RPC connection"); + throw uhd::runtime_error( + "ad9361_ctrl::set_filter is not supported over an RPC connection"); } void output_digital_test_tone(bool enb) @@ -150,13 +145,11 @@ ad9361_ctrl::sptr make_rpc(rpc_client::sptr rpcc) return ad9361_ctrl::sptr(new neon_ad9361_iface(rpcc)); } -/*! Helper function to convert direction and channel to the 'which' required by most Catalina - driver functions */ +/*! Helper function to convert direction and channel to the 'which' required by most + Catalina driver functions */ std::string get_which_ad9361_chain(const direction_t dir, const size_t chan) { UHD_ASSERT_THROW(dir == RX_DIRECTION or dir == TX_DIRECTION); UHD_ASSERT_THROW(chan == 0 or chan == 1); - return str(boost::format("%s%d") - % (dir == RX_DIRECTION ? "RX" : "TX") - % (chan + 1)); + return str(boost::format("%s%d") % (dir == RX_DIRECTION ? "RX" : "TX") % (chan + 1)); } diff --git a/host/lib/usrp/dboard/neon/neon_bands.cpp b/host/lib/usrp/dboard/neon/neon_bands.cpp index 25aa0a181..303d2801d 100644 --- a/host/lib/usrp/dboard/neon/neon_bands.cpp +++ b/host/lib/usrp/dboard/neon/neon_bands.cpp @@ -4,8 +4,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later // -#include "neon_radio_ctrl_impl.hpp" #include "neon_constants.hpp" +#include "neon_radio_ctrl_impl.hpp" #include <uhd/utils/math.hpp> /* @@ -51,54 +51,55 @@ using namespace uhd::rfnoc; using namespace uhd::math::fp_compare; namespace { - /* Note on the RX filter bank: - * - * The RX path has 7 bands, which we call LB_B2, B3, .. HB same as - * the schematic. - * - * The following constants define lower cutoff frequencies for each band. - * LB_B2 does not have a lower cutoff frequency, it is implied by - * AD9361_MIN_FREQ. NEON_RX_BAND1_MIN_FREQ is the cutover frequency - * for switching from LB_B2 to LB_B3, and so on. - * - * Bands 1-6 have both high- and low-pass filters (effectively band - * passes). Frequencies need to be chosen to allow as much of the full - * bandwidth through unattenuated. - */ - constexpr double NEON_RX_LB_BAND3_MIN_FREQ = 450e6; - constexpr double NEON_RX_LB_BAND4_MIN_FREQ = 700e6; - constexpr double NEON_RX_LB_BAND5_MIN_FREQ = 1200e6; - constexpr double NEON_RX_LB_BAND6_MIN_FREQ = 1800e6; - constexpr double NEON_RX_LB_BAND7_MIN_FREQ = 2350e6; - constexpr double NEON_RX_HB_MIN_FREQ = 2600e6; +/* Note on the RX filter bank: + * + * The RX path has 7 bands, which we call LB_B2, B3, .. HB same as + * the schematic. + * + * The following constants define lower cutoff frequencies for each band. + * LB_B2 does not have a lower cutoff frequency, it is implied by + * AD9361_MIN_FREQ. NEON_RX_BAND1_MIN_FREQ is the cutover frequency + * for switching from LB_B2 to LB_B3, and so on. + * + * Bands 1-6 have both high- and low-pass filters (effectively band + * passes). Frequencies need to be chosen to allow as much of the full + * bandwidth through unattenuated. + */ +constexpr double NEON_RX_LB_BAND3_MIN_FREQ = 450e6; +constexpr double NEON_RX_LB_BAND4_MIN_FREQ = 700e6; +constexpr double NEON_RX_LB_BAND5_MIN_FREQ = 1200e6; +constexpr double NEON_RX_LB_BAND6_MIN_FREQ = 1800e6; +constexpr double NEON_RX_LB_BAND7_MIN_FREQ = 2350e6; +constexpr double NEON_RX_HB_MIN_FREQ = 2600e6; - /* Note on the TX filter bank: - * - * The TX path has 9 bands, which we name according to the schematic. - * - * The following constants define lower cutoff frequencies for each band. - * LB_80 does not have a lower cutoff frequency, it is implied by - * AD9361_MIN_FREQ. NEON_TX_LB_160_MIN_FREQ is the cutover frequency - * for switching from LB_80 to LB_160, and so on. - * - * On current Neon revisions, all filters on the TX filter bank are - * low pass filters (no high pass filters). - * Frequencies need to be chosen to allow as much of the full bandwidth - * through unattenuated (so don't go all the way up to the cutoff frequency - * of that filter). - */ - constexpr double NEON_TX_LB_160_MIN_FREQ = 117.7e6; - constexpr double NEON_TX_LB_225_MIN_FREQ = 178.2e6; - constexpr double NEON_TX_LB_400_MIN_FREQ = 284.3e6; - constexpr double NEON_TX_LB_575_MIN_FREQ = 453.7e6; - constexpr double NEON_TX_LB_1000_MIN_FREQ = 723.8e6; - constexpr double NEON_TX_LB_1700_MIN_FREQ = 1154.9e6; - constexpr double NEON_TX_LB_2750_MIN_FREQ = 1842.6e6; - constexpr double NEON_TX_HB_MIN_FREQ = 2940.0e6; -} +/* Note on the TX filter bank: + * + * The TX path has 9 bands, which we name according to the schematic. + * + * The following constants define lower cutoff frequencies for each band. + * LB_80 does not have a lower cutoff frequency, it is implied by + * AD9361_MIN_FREQ. NEON_TX_LB_160_MIN_FREQ is the cutover frequency + * for switching from LB_80 to LB_160, and so on. + * + * On current Neon revisions, all filters on the TX filter bank are + * low pass filters (no high pass filters). + * Frequencies need to be chosen to allow as much of the full bandwidth + * through unattenuated (so don't go all the way up to the cutoff frequency + * of that filter). + */ +constexpr double NEON_TX_LB_160_MIN_FREQ = 117.7e6; +constexpr double NEON_TX_LB_225_MIN_FREQ = 178.2e6; +constexpr double NEON_TX_LB_400_MIN_FREQ = 284.3e6; +constexpr double NEON_TX_LB_575_MIN_FREQ = 453.7e6; +constexpr double NEON_TX_LB_1000_MIN_FREQ = 723.8e6; +constexpr double NEON_TX_LB_1700_MIN_FREQ = 1154.9e6; +constexpr double NEON_TX_LB_2750_MIN_FREQ = 1842.6e6; +constexpr double NEON_TX_HB_MIN_FREQ = 2940.0e6; +} // namespace -neon_radio_ctrl_impl::rx_band -neon_radio_ctrl_impl::_map_freq_to_rx_band(const double freq) { +neon_radio_ctrl_impl::rx_band neon_radio_ctrl_impl::_map_freq_to_rx_band( + const double freq) +{ neon_radio_ctrl_impl::rx_band band; if (fp_compare_epsilon<double>(freq) < AD9361_RX_MIN_FREQ) { @@ -124,8 +125,9 @@ neon_radio_ctrl_impl::_map_freq_to_rx_band(const double freq) { return band; } -neon_radio_ctrl_impl::tx_band -neon_radio_ctrl_impl::_map_freq_to_tx_band(const double freq) { +neon_radio_ctrl_impl::tx_band neon_radio_ctrl_impl::_map_freq_to_tx_band( + const double freq) +{ neon_radio_ctrl_impl::tx_band band; if (fp_compare_epsilon<double>(freq) < AD9361_TX_MIN_FREQ) { @@ -154,4 +156,3 @@ neon_radio_ctrl_impl::_map_freq_to_tx_band(const double freq) { return band; } - diff --git a/host/lib/usrp/dboard/neon/neon_constants.hpp b/host/lib/usrp/dboard/neon/neon_constants.hpp index 58e5244fc..42cfb6579 100644 --- a/host/lib/usrp/dboard/neon/neon_constants.hpp +++ b/host/lib/usrp/dboard/neon/neon_constants.hpp @@ -7,16 +7,16 @@ #ifndef INCLUDED_LIBUHD_NEON_CONSTANTS_HPP #define INCLUDED_LIBUHD_NEON_CONSTANTS_HPP -#include <vector> -#include <string> #include <cstddef> +#include <string> +#include <vector> -static constexpr size_t FPGPIO_MASTER_RADIO = 0; -static constexpr size_t TOTAL_RADIO_PORTS = 2; -static constexpr double AD9361_RX_MIN_BANDWIDTH = 20.0e6; // HZ +static constexpr size_t FPGPIO_MASTER_RADIO = 0; +static constexpr size_t TOTAL_RADIO_PORTS = 2; +static constexpr double AD9361_RX_MIN_BANDWIDTH = 20.0e6; // HZ static constexpr double AD9361_RX_MAX_BANDWIDTH = 40.0e6; // HZ -static constexpr double AD9361_TX_MIN_BANDWIDTH = 20.0e6; // HZ +static constexpr double AD9361_TX_MIN_BANDWIDTH = 20.0e6; // HZ static constexpr double AD9361_TX_MAX_BANDWIDTH = 40.0e6; // HZ static constexpr double AD9361_TX_MIN_FREQ = 47.0e6; // Hz @@ -27,27 +27,25 @@ static constexpr double AD9361_RX_MAX_FREQ = 6.0e9; // Hz static constexpr double NEON_RADIO_RATE = 16e6; // Hz -static constexpr double AD9361_MIN_RX_GAIN = 0.0; // dB -static constexpr double AD9361_MAX_RX_GAIN = 76; // dB +static constexpr double AD9361_MIN_RX_GAIN = 0.0; // dB +static constexpr double AD9361_MAX_RX_GAIN = 76; // dB static constexpr double AD9361_RX_GAIN_STEP = 1.0; // dB -static constexpr double AD9361_MIN_TX_GAIN = 0.0; // dB -static constexpr double AD9361_MAX_TX_GAIN = 89.75; // dB +static constexpr double AD9361_MIN_TX_GAIN = 0.0; // dB +static constexpr double AD9361_MAX_TX_GAIN = 89.75; // dB static constexpr double AD9361_TX_GAIN_STEP = 0.25; // dB -static constexpr bool NEON_DEFAULT_AUTO_DC_OFFSET = true; +static constexpr bool NEON_DEFAULT_AUTO_DC_OFFSET = true; static constexpr bool NEON_DEFAULT_AUTO_IQ_BALANCE = true; -static constexpr bool NEON_DEFAULT_AGC_ENABLE = false; +static constexpr bool NEON_DEFAULT_AGC_ENABLE = false; -static constexpr double NEON_DEFAULT_GAIN = 0.0; -static constexpr double NEON_DEFAULT_FREQ = 2.4e9; // Hz -static constexpr double NEON_DEFAULT_BANDWIDTH = 40e6; // Hz -static constexpr char NEON_DEFAULT_RX_ANTENNA[] = "RX2"; -static constexpr char NEON_DEFAULT_TX_ANTENNA[] = "TX/RX"; +static constexpr double NEON_DEFAULT_GAIN = 0.0; +static constexpr double NEON_DEFAULT_FREQ = 2.4e9; // Hz +static constexpr double NEON_DEFAULT_BANDWIDTH = 40e6; // Hz +static constexpr char NEON_DEFAULT_RX_ANTENNA[] = "RX2"; +static constexpr char NEON_DEFAULT_TX_ANTENNA[] = "TX/RX"; -static const std::vector<std::string> NEON_RX_ANTENNAS = { - "RX2", "TX/RX" -}; +static const std::vector<std::string> NEON_RX_ANTENNAS = {"RX2", "TX/RX"}; static constexpr size_t NEON_NUM_CHANS = 2; diff --git a/host/lib/usrp/dboard/neon/neon_radio_ctrl_impl.cpp b/host/lib/usrp/dboard/neon/neon_radio_ctrl_impl.cpp index 71e467848..d8fabcee0 100644 --- a/host/lib/usrp/dboard/neon/neon_radio_ctrl_impl.cpp +++ b/host/lib/usrp/dboard/neon/neon_radio_ctrl_impl.cpp @@ -7,20 +7,20 @@ #include "neon_radio_ctrl_impl.hpp" #include "neon_constants.hpp" #include "neon_regs.hpp" -#include <uhd/utils/log.hpp> +#include <uhd/exception.hpp> #include <uhd/rfnoc/node_ctrl_base.hpp> #include <uhd/transport/chdr.hpp> -#include <uhd/utils/algorithm.hpp> -#include <uhd/utils/math.hpp> #include <uhd/types/direction.hpp> #include <uhd/types/eeprom.hpp> -#include <uhd/exception.hpp> +#include <uhd/utils/algorithm.hpp> +#include <uhd/utils/log.hpp> +#include <uhd/utils/math.hpp> #include <boost/algorithm/string.hpp> -#include <boost/make_shared.hpp> #include <boost/format.hpp> -#include <sstream> +#include <boost/make_shared.hpp> #include <cmath> #include <cstdlib> +#include <sstream> using namespace uhd; using namespace uhd::usrp; @@ -34,7 +34,7 @@ UHD_RFNOC_RADIO_BLOCK_CONSTRUCTOR(neon_radio_ctrl) { UHD_LOG_TRACE(unique_id(), "Entering neon_radio_ctrl_impl ctor..."); const char radio_slot_name[1] = {'A'}; - _radio_slot = radio_slot_name[get_block_id().get_block_count()]; + _radio_slot = radio_slot_name[get_block_id().get_block_count()]; UHD_LOG_TRACE(unique_id(), "Radio slot: " << _radio_slot); _rpc_prefix = "db_0_"; @@ -58,38 +58,39 @@ bool neon_radio_ctrl_impl::check_radio_config() // mapping of frontend to radio perif index static const size_t FE0 = 0; static const size_t FE1 = 1; - const size_t num_rx = _is_streamer_active(RX_DIRECTION, FE0) + _is_streamer_active(RX_DIRECTION, FE1); - const size_t num_tx = _is_streamer_active(TX_DIRECTION, FE0) + _is_streamer_active(TX_DIRECTION, FE1); + const size_t num_rx = + _is_streamer_active(RX_DIRECTION, FE0) + _is_streamer_active(RX_DIRECTION, FE1); + const size_t num_tx = + _is_streamer_active(TX_DIRECTION, FE0) + _is_streamer_active(TX_DIRECTION, FE1); - //setup the active chains in the codec + // setup the active chains in the codec if ((num_rx + num_tx) == 0) { // Ensure at least one RX chain is enabled so AD9361 outputs a sample clock this->set_streaming_mode(false, false, true, false); } else { - this->set_streaming_mode( - _is_streamer_active(TX_DIRECTION, FE0), - _is_streamer_active(TX_DIRECTION, FE1), - _is_streamer_active(RX_DIRECTION, FE0), - _is_streamer_active(RX_DIRECTION, FE1) - ); + this->set_streaming_mode(_is_streamer_active(TX_DIRECTION, FE0), + _is_streamer_active(TX_DIRECTION, FE1), + _is_streamer_active(RX_DIRECTION, FE0), + _is_streamer_active(RX_DIRECTION, FE1)); } return true; } -void neon_radio_ctrl_impl::set_streaming_mode(const bool tx1, const bool tx2, const bool rx1, const bool rx2) +void neon_radio_ctrl_impl::set_streaming_mode( + const bool tx1, const bool tx2, const bool rx1, const bool rx2) { UHD_LOG_TRACE(unique_id(), "Setting up streaming ...") const size_t num_rx = rx1 + rx2; const size_t num_tx = tx1 + tx2; - //setup the active chains in the codec + // setup the active chains in the codec _ad9361->set_active_chains(tx1, tx2, rx1, rx2); const std::string TIMING_MODE_2R2T = "2R2T"; const std::string TIMING_MODE_1R1T = "1R1T"; - const std::string MIMO = "MIMO"; // 2R2T - const std::string SISO_TX1 = "SISO_TX1"; // 1R1T - const std::string SISO_TX0 = "SISO_TX0"; // 1R1T + const std::string MIMO = "MIMO"; // 2R2T + const std::string SISO_TX1 = "SISO_TX1"; // 1R1T + const std::string SISO_TX0 = "SISO_TX0"; // 1R1T // setup 1R1T/2R2T mode in catalina and fpga // The Catalina interface in the fpga needs to know which TX channel to use for // the data on the LVDS lines. @@ -107,11 +108,11 @@ void neon_radio_ctrl_impl::set_streaming_mode(const bool tx1, const bool tx2, co } } -void neon_radio_ctrl_impl::set_channel_mode(const std::string &channel_mode) +void neon_radio_ctrl_impl::set_channel_mode(const std::string& channel_mode) { - //MIMO for 2R2T mode for 2 channels - //SISO_TX1 for 1R1T mode for 1 channel - TX1 - //SISO_TX0 for 1R1T mode for 1 channel - TX0 + // MIMO for 2R2T mode for 2 channels + // SISO_TX1 for 1R1T mode for 1 channel - TX1 + // SISO_TX0 for 1R1T mode for 1 channel - TX0 _rpcc->request_with_token<void>("set_channel_mode", channel_mode); } @@ -127,9 +128,8 @@ void neon_radio_ctrl_impl::set_channel_mode(const std::string &channel_mode) Note: This currently only tests 2R2T mode */ void neon_radio_ctrl_impl::loopback_self_test( - std::function<void(uint32_t)> poker_functor, - std::function<uint64_t()> peeker_functor -) { + std::function<void(uint32_t)> poker_functor, std::function<uint64_t()> peeker_functor) +{ // Save current rate before running this test const double current_rate = this->get_rate(); // Set 2R2T mode, stream on all channels @@ -139,7 +139,7 @@ void neon_radio_ctrl_impl::loopback_self_test( // Put AD936x in loopback mode _ad9361->data_port_loopback(true); UHD_LOG_INFO(unique_id(), "Performing CODEC loopback test... "); - size_t hash = size_t(time(NULL)); + size_t hash = size_t(time(NULL)); constexpr size_t loopback_count = 100; // Allow some time for AD936x to enter loopback mode. @@ -150,27 +150,26 @@ void neon_radio_ctrl_impl::loopback_self_test( // Sleeping 1ms is far more than enough. std::this_thread::sleep_for(std::chrono::milliseconds(1)); - for (size_t i = 0; i < loopback_count; i++) - { + for (size_t i = 0; i < loopback_count; i++) { // Create test word boost::hash_combine(hash, i); const uint32_t word32 = uint32_t(hash) & 0xfff0fff0; - //const uint32_t word32 = 0xCA00C100; + // const uint32_t word32 = 0xCA00C100; // Write test word to codec_idle idle register (on TX side) poker_functor(word32); // Read back values - TX is lower 32-bits and RX is upper 32-bits const uint64_t rb_word64 = peeker_functor(); - const uint32_t rb_tx = uint32_t(rb_word64 >> 32); - const uint32_t rb_rx = uint32_t(rb_word64 & 0xffffffff); + const uint32_t rb_tx = uint32_t(rb_word64 >> 32); + const uint32_t rb_rx = uint32_t(rb_word64 & 0xffffffff); // Compare TX and RX values to test word bool test_fail = word32 != rb_tx or word32 != rb_rx; - if(test_fail) - { - UHD_LOG_WARNING(unique_id(), "CODEC loopback test failed! " - << boost::format("Expected: 0x%08X Received (TX/RX): 0x%08X/0x%08X") - % word32 % rb_tx % rb_rx); + if (test_fail) { + UHD_LOG_WARNING(unique_id(), + "CODEC loopback test failed! " + << boost::format("Expected: 0x%08X Received (TX/RX): 0x%08X/0x%08X") + % word32 % rb_tx % rb_rx); throw uhd::runtime_error("CODEC loopback test failed."); } } @@ -189,63 +188,50 @@ void neon_radio_ctrl_impl::loopback_self_test( double neon_radio_ctrl_impl::set_rate(const double rate) { std::lock_guard<std::mutex> l(_set_lock); - UHD_LOG_DEBUG(unique_id(), "Asking for clock rate " << rate/1e6 << " MHz\n"); + UHD_LOG_DEBUG(unique_id(), "Asking for clock rate " << rate / 1e6 << " MHz\n"); double actual_tick_rate = _ad9361->set_clock_rate(rate); - UHD_LOG_DEBUG(unique_id(), "Actual clock rate " << actual_tick_rate/1e6 << " MHz\n"); + UHD_LOG_DEBUG( + unique_id(), "Actual clock rate " << actual_tick_rate / 1e6 << " MHz\n"); radio_ctrl_impl::set_rate(rate); return rate; } -void neon_radio_ctrl_impl::set_tx_antenna( - const std::string &ant, - const size_t chan -) { +void neon_radio_ctrl_impl::set_tx_antenna(const std::string& ant, const size_t chan) +{ if (ant != get_tx_antenna(chan)) { - throw uhd::value_error(str( - boost::format("[%s] Requesting invalid TX antenna value: %s") - % unique_id() - % ant - )); + throw uhd::value_error( + str(boost::format("[%s] Requesting invalid TX antenna value: %s") + % unique_id() % ant)); } radio_ctrl_impl::set_tx_antenna(ant, chan); // We can't actually set the TX antenna, so let's stop here. } -void neon_radio_ctrl_impl::set_rx_antenna( - const std::string &ant, - const size_t chan -) { +void neon_radio_ctrl_impl::set_rx_antenna(const std::string& ant, const size_t chan) +{ UHD_ASSERT_THROW(chan <= NEON_NUM_CHANS); - if (std::find(NEON_RX_ANTENNAS.begin(), - NEON_RX_ANTENNAS.end(), - ant) == NEON_RX_ANTENNAS.end()) { - throw uhd::value_error(str( - boost::format("[%s] Requesting invalid RX antenna value: %s") - % unique_id() - % ant - )); + if (std::find(NEON_RX_ANTENNAS.begin(), NEON_RX_ANTENNAS.end(), ant) + == NEON_RX_ANTENNAS.end()) { + throw uhd::value_error( + str(boost::format("[%s] Requesting invalid RX antenna value: %s") + % unique_id() % ant)); } - UHD_LOG_TRACE(unique_id(), - "Setting RX antenna to " << ant << " for chan " << chan); + UHD_LOG_TRACE(unique_id(), "Setting RX antenna to " << ant << " for chan " << chan); radio_ctrl_impl::set_rx_antenna(ant, chan); _set_atr_bits(chan); } -double neon_radio_ctrl_impl::set_tx_frequency( - const double freq, - const size_t chan -) { - UHD_LOG_TRACE(unique_id(), - "set_tx_frequency(f=" << freq << ", chan=" << chan << ")"); +double neon_radio_ctrl_impl::set_tx_frequency(const double freq, const size_t chan) +{ + UHD_LOG_TRACE(unique_id(), "set_tx_frequency(f=" << freq << ", chan=" << chan << ")"); std::lock_guard<std::mutex> l(_set_lock); double clipped_freq = uhd::clip(freq, AD9361_TX_MIN_FREQ, AD9361_TX_MAX_FREQ); - double coerced_freq = _ad9361->tune( - get_which_ad9361_chain(TX_DIRECTION, chan), - clipped_freq); + double coerced_freq = + _ad9361->tune(get_which_ad9361_chain(TX_DIRECTION, chan), clipped_freq); radio_ctrl_impl::set_tx_frequency(coerced_freq, chan); // Front-end switching _set_atr_bits(chan); @@ -253,19 +239,15 @@ double neon_radio_ctrl_impl::set_tx_frequency( return coerced_freq; } -double neon_radio_ctrl_impl::set_rx_frequency( - const double freq, - const size_t chan -) { - UHD_LOG_TRACE(unique_id(), - "set_rx_frequency(f=" << freq << ", chan=" << chan << ")"); +double neon_radio_ctrl_impl::set_rx_frequency(const double freq, const size_t chan) +{ + UHD_LOG_TRACE(unique_id(), "set_rx_frequency(f=" << freq << ", chan=" << chan << ")"); std::lock_guard<std::mutex> l(_set_lock); double clipped_freq = uhd::clip(freq, AD9361_RX_MIN_FREQ, AD9361_RX_MAX_FREQ); - double coerced_freq = _ad9361->tune( - get_which_ad9361_chain(RX_DIRECTION, chan), - clipped_freq); + double coerced_freq = + _ad9361->tune(get_which_ad9361_chain(RX_DIRECTION, chan), clipped_freq); radio_ctrl_impl::set_rx_frequency(coerced_freq, chan); // Front-end switching _set_atr_bits(chan); @@ -273,63 +255,48 @@ double neon_radio_ctrl_impl::set_rx_frequency( return coerced_freq; } -double neon_radio_ctrl_impl::set_rx_bandwidth( - const double bandwidth, - const size_t chan -) { +double neon_radio_ctrl_impl::set_rx_bandwidth(const double bandwidth, const size_t chan) +{ std::lock_guard<std::mutex> l(_set_lock); - double clipped_bw = _ad9361->set_bw_filter( - get_which_ad9361_chain(RX_DIRECTION, chan), - bandwidth); + double clipped_bw = + _ad9361->set_bw_filter(get_which_ad9361_chain(RX_DIRECTION, chan), bandwidth); return radio_ctrl_impl::set_rx_bandwidth(clipped_bw, chan); } -double neon_radio_ctrl_impl::set_tx_bandwidth( - const double bandwidth, - const size_t chan -) { +double neon_radio_ctrl_impl::set_tx_bandwidth(const double bandwidth, const size_t chan) +{ std::lock_guard<std::mutex> l(_set_lock); - double clipped_bw = _ad9361->set_bw_filter( - get_which_ad9361_chain(TX_DIRECTION, chan), - bandwidth); + double clipped_bw = + _ad9361->set_bw_filter(get_which_ad9361_chain(TX_DIRECTION, chan), bandwidth); return radio_ctrl_impl::set_tx_bandwidth(clipped_bw, chan); } -double neon_radio_ctrl_impl::set_tx_gain( - const double gain, - const size_t chan -) { +double neon_radio_ctrl_impl::set_tx_gain(const double gain, const size_t chan) +{ std::lock_guard<std::mutex> l(_set_lock); - UHD_LOG_TRACE(unique_id(), - "set_tx_gain(gain=" << gain << ", chan=" << chan << ")"); + UHD_LOG_TRACE(unique_id(), "set_tx_gain(gain=" << gain << ", chan=" << chan << ")"); double clip_gain = uhd::clip(gain, AD9361_MIN_TX_GAIN, AD9361_MAX_TX_GAIN); - _ad9361->set_gain( - get_which_ad9361_chain(TX_DIRECTION, chan), - clip_gain); + _ad9361->set_gain(get_which_ad9361_chain(TX_DIRECTION, chan), clip_gain); radio_ctrl_impl::set_tx_gain(clip_gain, chan); return clip_gain; } -double neon_radio_ctrl_impl::set_rx_gain( - const double gain, - const size_t chan -) { +double neon_radio_ctrl_impl::set_rx_gain(const double gain, const size_t chan) +{ std::lock_guard<std::mutex> l(_set_lock); - UHD_LOG_TRACE(unique_id(), - "set_rx_gain(gain=" << gain << ", chan=" << chan << ")"); + UHD_LOG_TRACE(unique_id(), "set_rx_gain(gain=" << gain << ", chan=" << chan << ")"); double clip_gain = uhd::clip(gain, AD9361_MIN_RX_GAIN, AD9361_MAX_RX_GAIN); - _ad9361->set_gain( - get_which_ad9361_chain(RX_DIRECTION, chan), - clip_gain); + _ad9361->set_gain(get_which_ad9361_chain(RX_DIRECTION, chan), clip_gain); radio_ctrl_impl::set_rx_gain(clip_gain, chan); return clip_gain; } size_t neon_radio_ctrl_impl::get_chan_from_dboard_fe( - const std::string &fe, const direction_t /* dir */ -) { + const std::string& fe, const direction_t /* dir */ +) +{ const size_t chan = boost::lexical_cast<size_t>(fe); - if (chan > _get_num_radios()-1) { + if (chan > _get_num_radios() - 1) { UHD_LOG_WARNING(unique_id(), boost::format("Invalid channel determined from dboard frontend %s.") % fe); } @@ -337,122 +304,107 @@ size_t neon_radio_ctrl_impl::get_chan_from_dboard_fe( } std::string neon_radio_ctrl_impl::get_dboard_fe_from_chan( - const size_t chan, - const direction_t /* dir */ -) { + const size_t chan, const direction_t /* dir */ +) +{ return std::to_string(chan); } void neon_radio_ctrl_impl::set_rpc_client( - uhd::rpc_client::sptr rpcc, - const uhd::device_addr_t &block_args -) { - _rpcc = rpcc; + uhd::rpc_client::sptr rpcc, const uhd::device_addr_t& block_args) +{ + _rpcc = rpcc; _block_args = block_args; UHD_LOG_TRACE(unique_id(), "Instantiating AD9361 control object..."); _ad9361 = make_rpc(_rpcc); UHD_LOG_TRACE(unique_id(), "Setting Catalina Defaults... "); - //Initialize catalina + // Initialize catalina this->_init_codec(); if (block_args.has_key("identify")) { const std::string identify_val = block_args.get("identify"); - int identify_duration = std::atoi(identify_val.c_str()); + int identify_duration = std::atoi(identify_val.c_str()); if (identify_duration == 0) { identify_duration = 5; } UHD_LOG_INFO(unique_id(), "Running LED identification process for " << identify_duration - << " seconds."); + << " seconds."); _identify_with_leds(identify_duration); } // Note: MCR gets set during the init() call (prior to this), which takes // in arguments from the device args. So if block_args contains a // master_clock_rate key, then it should better be whatever the device is // configured to do. - _master_clock_rate = _rpcc->request_with_token<double>( - _rpc_prefix + "get_master_clock_rate"); + _master_clock_rate = + _rpcc->request_with_token<double>(_rpc_prefix + "get_master_clock_rate"); if (block_args.cast<double>("master_clock_rate", _master_clock_rate) - != _master_clock_rate) { + != _master_clock_rate) { throw uhd::runtime_error(str( boost::format("Master clock rate mismatch. Device returns %f MHz, " "but should have been %f MHz.") % (_master_clock_rate / 1e6) - % (block_args.cast<double>( - "master_clock_rate", _master_clock_rate) / 1e6) - )); - + % (block_args.cast<double>("master_clock_rate", _master_clock_rate) / 1e6))); } - UHD_LOG_DEBUG(unique_id(), - "Master Clock Rate is: " << (_master_clock_rate / 1e6) << " MHz."); + UHD_LOG_DEBUG( + unique_id(), "Master Clock Rate is: " << (_master_clock_rate / 1e6) << " MHz."); this->set_rate(_master_clock_rate); // Loopback test for (size_t chan = 0; chan < _get_num_radios(); chan++) { loopback_self_test( - [this, chan](const uint32_t value){ - this->sr_write(regs::CODEC_IDLE, value, chan); - }, - [this, chan](){ + [this, chan]( + const uint32_t value) { this->sr_write(regs::CODEC_IDLE, value, chan); }, + [this, chan]() { return this->user_reg_read64(regs::RB_CODEC_READBACK, chan); - } - ); + }); } const size_t db_idx = get_block_id().get_block_count(); _tree->access<eeprom_map_t>(_root_path / "eeprom") - .add_coerced_subscriber([this, db_idx](const eeprom_map_t& db_eeprom){ + .add_coerced_subscriber([this, db_idx](const eeprom_map_t& db_eeprom) { this->_rpcc->notify_with_token("set_db_eeprom", db_idx, db_eeprom); }) - .set_publisher([this, db_idx](){ - return this->_rpcc->request_with_token<eeprom_map_t>( - "get_db_eeprom", db_idx - ); - }) - ; + .set_publisher([this, db_idx]() { + return this->_rpcc->request_with_token<eeprom_map_t>("get_db_eeprom", db_idx); + }); // Init sensors - for (const auto &dir : std::vector<direction_t>{RX_DIRECTION, TX_DIRECTION}) { + for (const auto& dir : std::vector<direction_t>{RX_DIRECTION, TX_DIRECTION}) { for (size_t chan_idx = 0; chan_idx < NEON_NUM_CHANS; chan_idx++) { _init_mpm_sensors(dir, chan_idx); } } } -bool neon_radio_ctrl_impl::get_lo_lock_status( - const direction_t dir -) { - if (not (bool(_rpcc))) { - UHD_LOG_DEBUG(unique_id(), - "Reported no LO lock due to lack of RPC connection."); +bool neon_radio_ctrl_impl::get_lo_lock_status(const direction_t dir) +{ + if (not(bool(_rpcc))) { + UHD_LOG_DEBUG(unique_id(), "Reported no LO lock due to lack of RPC connection."); return false; } const std::string trx = (dir == RX_DIRECTION) ? "rx" : "tx"; - bool lo_lock = _rpcc->request_with_token<bool>( - _rpc_prefix + "get_ad9361_lo_lock", trx); + bool lo_lock = + _rpcc->request_with_token<bool>(_rpc_prefix + "get_ad9361_lo_lock", trx); UHD_LOG_TRACE(unique_id(), "AD9361 " << trx << " LO reports lock: " << (lo_lock ? "Yes" : "No")); return lo_lock; } -void neon_radio_ctrl_impl::_set_atr_bits( - const size_t chan -) { - const auto rx_freq = radio_ctrl_impl::get_rx_frequency(chan); - const auto tx_freq = radio_ctrl_impl::get_tx_frequency(chan); - const auto rx_ant = radio_ctrl_impl::get_rx_antenna(chan); - const uint32_t rx_regs = _get_rx_switches(chan, rx_freq, rx_ant); - const uint32_t tx_regs = _get_tx_switches(chan, tx_freq); - const uint32_t idle_regs = TX_AMP_OFF << TX_AMP_SHIFT | - TRX1_SW_TX_HB << TRX_SW_SHIFT | - TX_SW2_LB_80 << TX_SW2_SHIFT | - TX_SW1_LB_80 << TX_SW1_SHIFT | - RX_SW3_OFF << RX_SW3_SHIFT | - RX_SW2_OFF << RX_SW2_SHIFT | - RX_SW1_OFF << RX_SW1_SHIFT; +void neon_radio_ctrl_impl::_set_atr_bits(const size_t chan) +{ + const auto rx_freq = radio_ctrl_impl::get_rx_frequency(chan); + const auto tx_freq = radio_ctrl_impl::get_tx_frequency(chan); + const auto rx_ant = radio_ctrl_impl::get_rx_antenna(chan); + const uint32_t rx_regs = _get_rx_switches(chan, rx_freq, rx_ant); + const uint32_t tx_regs = _get_tx_switches(chan, tx_freq); + const uint32_t idle_regs = TX_AMP_OFF << TX_AMP_SHIFT | TRX1_SW_TX_HB << TRX_SW_SHIFT + | TX_SW2_LB_80 << TX_SW2_SHIFT + | TX_SW1_LB_80 << TX_SW1_SHIFT | RX_SW3_OFF << RX_SW3_SHIFT + | RX_SW2_OFF << RX_SW2_SHIFT | RX_SW1_OFF << RX_SW1_SHIFT; _db_gpio[chan]->set_atr_reg(usrp::gpio_atr::ATR_REG_IDLE, idle_regs); _db_gpio[chan]->set_atr_reg(usrp::gpio_atr::ATR_REG_RX_ONLY, rx_regs); @@ -462,21 +414,21 @@ void neon_radio_ctrl_impl::_set_atr_bits( // The LED signal names are reversed, but are consistent with the schematic const int idle_led = 0; const bool is_txrx = rx_ant == "TX/RX"; - const int rx_led = 1 << TRX_LED_GRN_SHIFT; - const int tx_led = 1 << TX_LED_RED_SHIFT; + const int rx_led = 1 << TRX_LED_GRN_SHIFT; + const int tx_led = 1 << TX_LED_RED_SHIFT; const int txrx_led = 1 << RX_LED_GRN_SHIFT; _leds_gpio[chan]->set_atr_reg(usrp::gpio_atr::ATR_REG_IDLE, idle_led); - _leds_gpio[chan]->set_atr_reg(usrp::gpio_atr::ATR_REG_RX_ONLY, is_txrx ? txrx_led : rx_led); + _leds_gpio[chan]->set_atr_reg( + usrp::gpio_atr::ATR_REG_RX_ONLY, is_txrx ? txrx_led : rx_led); _leds_gpio[chan]->set_atr_reg(usrp::gpio_atr::ATR_REG_TX_ONLY, tx_led); _leds_gpio[chan]->set_atr_reg(usrp::gpio_atr::ATR_REG_FULL_DUPLEX, rx_led | tx_led); } -void neon_radio_ctrl_impl::_identify_with_leds( - const int identify_duration -) { - auto end_time = std::chrono::steady_clock::now() - + std::chrono::seconds(identify_duration); +void neon_radio_ctrl_impl::_identify_with_leds(const int identify_duration) +{ + auto end_time = + std::chrono::steady_clock::now() + std::chrono::seconds(identify_duration); bool led_state = true; while (std::chrono::steady_clock::now() < end_time) { // Add update_leds @@ -485,141 +437,126 @@ void neon_radio_ctrl_impl::_identify_with_leds( } } -uint32_t neon_radio_ctrl_impl::_get_tx_switches( - const size_t chan, - const double freq -) { - - UHD_LOG_TRACE(unique_id(), - "Update all TX freq related switches. f=" << freq << " Hz, " - ); +uint32_t neon_radio_ctrl_impl::_get_tx_switches(const size_t chan, const double freq) +{ + UHD_LOG_TRACE( + unique_id(), "Update all TX freq related switches. f=" << freq << " Hz, "); auto tx_sw1 = TX_SW1_LB_160; auto tx_sw2 = TX_SW2_LB_160; - auto trx_sw = (chan == 0) ? TRX1_SW_TX_LB: TRX2_SW_TX_LB; + auto trx_sw = (chan == 0) ? TRX1_SW_TX_LB : TRX2_SW_TX_LB; auto tx_amp = TX_AMP_LF_ON; const auto band = _map_freq_to_tx_band(freq); - switch(band) { - case tx_band::LB_80: - tx_sw1 = TX_SW1_LB_80; - tx_sw2 = TX_SW2_LB_80; - break; - case tx_band::LB_160: - tx_sw1 = TX_SW1_LB_160; - tx_sw2 = TX_SW2_LB_160; - break; - case tx_band::LB_225: - tx_sw1 = TX_SW1_LB_225; - tx_sw2 = TX_SW2_LB_225; - break; - case tx_band::LB_400: - tx_sw1 = TX_SW1_LB_400; - tx_sw2 = TX_SW2_LB_400; - break; - case tx_band::LB_575: - tx_sw1 = TX_SW1_LB_575; - tx_sw2 = TX_SW2_LB_575; - break; - case tx_band::LB_1000: - tx_sw1 = TX_SW1_LB_1000; - tx_sw2 = TX_SW2_LB_1000; - break; - case tx_band::LB_1700: - tx_sw1 = TX_SW1_LB_1700; - tx_sw2 = TX_SW2_LB_1700; - break; - case tx_band::LB_2750: - tx_sw1 = TX_SW1_LB_2750; - tx_sw2 = TX_SW2_LB_2750; - break; - case tx_band::HB: - trx_sw = (chan == 0) ? TRX1_SW_TX_HB: TRX2_SW_TX_HB; - tx_amp = TX_AMP_HF_ON; - break; - case tx_band::INVALID_BAND: - UHD_LOG_ERROR(unique_id(), - "Cannot map TX frequency to band: " << freq); - UHD_THROW_INVALID_CODE_PATH(); - break; + switch (band) { + case tx_band::LB_80: + tx_sw1 = TX_SW1_LB_80; + tx_sw2 = TX_SW2_LB_80; + break; + case tx_band::LB_160: + tx_sw1 = TX_SW1_LB_160; + tx_sw2 = TX_SW2_LB_160; + break; + case tx_band::LB_225: + tx_sw1 = TX_SW1_LB_225; + tx_sw2 = TX_SW2_LB_225; + break; + case tx_band::LB_400: + tx_sw1 = TX_SW1_LB_400; + tx_sw2 = TX_SW2_LB_400; + break; + case tx_band::LB_575: + tx_sw1 = TX_SW1_LB_575; + tx_sw2 = TX_SW2_LB_575; + break; + case tx_band::LB_1000: + tx_sw1 = TX_SW1_LB_1000; + tx_sw2 = TX_SW2_LB_1000; + break; + case tx_band::LB_1700: + tx_sw1 = TX_SW1_LB_1700; + tx_sw2 = TX_SW2_LB_1700; + break; + case tx_band::LB_2750: + tx_sw1 = TX_SW1_LB_2750; + tx_sw2 = TX_SW2_LB_2750; + break; + case tx_band::HB: + trx_sw = (chan == 0) ? TRX1_SW_TX_HB : TRX2_SW_TX_HB; + tx_amp = TX_AMP_HF_ON; + break; + case tx_band::INVALID_BAND: + UHD_LOG_ERROR(unique_id(), "Cannot map TX frequency to band: " << freq); + UHD_THROW_INVALID_CODE_PATH(); + break; } - auto tx_regs = tx_amp << TX_AMP_SHIFT | - trx_sw << TRX_SW_SHIFT | - tx_sw2 << TX_SW2_SHIFT | - tx_sw1 << TX_SW1_SHIFT; + auto tx_regs = tx_amp << TX_AMP_SHIFT | trx_sw << TRX_SW_SHIFT + | tx_sw2 << TX_SW2_SHIFT | tx_sw1 << TX_SW1_SHIFT; return tx_regs; } uint32_t neon_radio_ctrl_impl::_get_rx_switches( - const size_t chan, - const double freq, - const std::string &ant -){ - UHD_LOG_TRACE(unique_id(), - "Update all RX freq related switches. f=" << freq << " Hz, " - ); + const size_t chan, const double freq, const std::string& ant) +{ + UHD_LOG_TRACE( + unique_id(), "Update all RX freq related switches. f=" << freq << " Hz, "); // Default to OFF auto rx_sw1 = RX_SW1_OFF; auto rx_sw2 = RX_SW2_OFF; auto rx_sw3 = RX_SW3_OFF; - auto trx_sw = (chan == 0) ? TRX1_SW_RX: TRX2_SW_RX; + auto trx_sw = (chan == 0) ? TRX1_SW_RX : TRX2_SW_RX; if (ant == "TX/RX") { rx_sw3 = RX_SW3_HBRX_LBTRX; - trx_sw = (chan == 0) ? TRX1_SW_RX: TRX2_SW_RX; - } - else if (ant == "RX2") { + trx_sw = (chan == 0) ? TRX1_SW_RX : TRX2_SW_RX; + } else if (ant == "RX2") { rx_sw3 = RX_SW3_HBTRX_LBRX; // Set TRX switch to TX when receiving on RX2 trx_sw = TRX1_SW_TX_HB; } const auto band = _map_freq_to_rx_band(freq); - switch(band) { - case rx_band::LB_B2: - rx_sw1 = RX_SW1_LB_B2; - rx_sw2 = RX_SW2_LB_B2; - break; - case rx_band::LB_B3: - rx_sw1 = RX_SW1_LB_B3; - rx_sw2 = RX_SW2_LB_B3; - break; - case rx_band::LB_B4: - rx_sw1 = RX_SW1_LB_B4; - rx_sw2 = RX_SW2_LB_B4; - break; - case rx_band::LB_B5: - rx_sw1 = RX_SW1_LB_B5; - rx_sw2 = RX_SW2_LB_B5; - break; - case rx_band::LB_B6: - rx_sw1 = RX_SW1_LB_B6; - rx_sw2 = RX_SW2_LB_B6; - break; - case rx_band::LB_B7: - rx_sw1 = RX_SW1_LB_B7; - rx_sw2 = RX_SW2_LB_B7; - break; - case rx_band::HB: - rx_sw1 = RX_SW1_OFF; - rx_sw2 = RX_SW2_OFF; - if (ant == "TX/RX") { - rx_sw3 = RX_SW3_HBTRX_LBRX; - } - else if (ant == "RX2") { - rx_sw3 = RX_SW3_HBRX_LBTRX; - } - break; - case rx_band::INVALID_BAND: - UHD_LOG_ERROR(unique_id(), - "Cannot map RX frequency to band: " << freq); - UHD_THROW_INVALID_CODE_PATH(); - break; + switch (band) { + case rx_band::LB_B2: + rx_sw1 = RX_SW1_LB_B2; + rx_sw2 = RX_SW2_LB_B2; + break; + case rx_band::LB_B3: + rx_sw1 = RX_SW1_LB_B3; + rx_sw2 = RX_SW2_LB_B3; + break; + case rx_band::LB_B4: + rx_sw1 = RX_SW1_LB_B4; + rx_sw2 = RX_SW2_LB_B4; + break; + case rx_band::LB_B5: + rx_sw1 = RX_SW1_LB_B5; + rx_sw2 = RX_SW2_LB_B5; + break; + case rx_band::LB_B6: + rx_sw1 = RX_SW1_LB_B6; + rx_sw2 = RX_SW2_LB_B6; + break; + case rx_band::LB_B7: + rx_sw1 = RX_SW1_LB_B7; + rx_sw2 = RX_SW2_LB_B7; + break; + case rx_band::HB: + rx_sw1 = RX_SW1_OFF; + rx_sw2 = RX_SW2_OFF; + if (ant == "TX/RX") { + rx_sw3 = RX_SW3_HBTRX_LBRX; + } else if (ant == "RX2") { + rx_sw3 = RX_SW3_HBRX_LBTRX; + } + break; + case rx_band::INVALID_BAND: + UHD_LOG_ERROR(unique_id(), "Cannot map RX frequency to band: " << freq); + UHD_THROW_INVALID_CODE_PATH(); + break; } - auto rx_regs = trx_sw << TRX_SW_SHIFT | - rx_sw3 << RX_SW3_SHIFT | - rx_sw2 << RX_SW2_SHIFT | - rx_sw1 << RX_SW1_SHIFT; + auto rx_regs = trx_sw << TRX_SW_SHIFT | rx_sw3 << RX_SW3_SHIFT + | rx_sw2 << RX_SW2_SHIFT | rx_sw1 << RX_SW1_SHIFT; return rx_regs; } diff --git a/host/lib/usrp/dboard/neon/neon_radio_ctrl_impl.hpp b/host/lib/usrp/dboard/neon/neon_radio_ctrl_impl.hpp index ac7fd70e9..88d1eed73 100644 --- a/host/lib/usrp/dboard/neon/neon_radio_ctrl_impl.hpp +++ b/host/lib/usrp/dboard/neon/neon_radio_ctrl_impl.hpp @@ -11,13 +11,12 @@ #include <uhd/types/serial.hpp> #include <uhd/usrp/dboard_manager.hpp> #include <uhd/usrp/gpio_defs.hpp> -#include <uhdlib/usrp/cores/gpio_atr_3000.hpp> -#include <uhdlib/rfnoc/rpc_block_ctrl.hpp> #include <uhdlib/rfnoc/radio_ctrl_impl.hpp> +#include <uhdlib/rfnoc/rpc_block_ctrl.hpp> +#include <uhdlib/usrp/cores/gpio_atr_3000.hpp> #include <mutex> -namespace uhd { - namespace rfnoc { +namespace uhd { namespace rfnoc { /*! \brief Provide access to an Magnesium radio. */ @@ -27,16 +26,7 @@ public: typedef boost::shared_ptr<neon_radio_ctrl_impl> sptr; //! Frequency bands for RX. Bands are a function of the analog filter banks - enum class rx_band { - INVALID_BAND, - LB_B2, - LB_B3, - LB_B4, - LB_B5, - LB_B6, - LB_B7, - HB - }; + enum class rx_band { INVALID_BAND, LB_B2, LB_B3, LB_B4, LB_B5, LB_B6, LB_B7, HB }; //! Frequency bands for TX. Bands are a function of the analog filter banks enum class tx_band { @@ -56,37 +46,28 @@ public: * ATR/ Switches Types *************************************************************************/ //! ATR state - enum atr_state_t { - IDLE, - RX_ONLY, - TX_ONLY, - FULL_DUPLEX - }; + enum atr_state_t { IDLE, RX_ONLY, TX_ONLY, FULL_DUPLEX }; //! Channel select: - enum chan_sel_t { - CHAN1, - CHAN2, - BOTH - }; + enum chan_sel_t { CHAN1, CHAN2, BOTH }; enum tx_sw1_t { - TX_SW1_LB_80 = 3, - TX_SW1_LB_160 = 7, - TX_SW1_LB_225 = 1, - TX_SW1_LB_400 = 5, - TX_SW1_LB_575 = 2, + TX_SW1_LB_80 = 3, + TX_SW1_LB_160 = 7, + TX_SW1_LB_225 = 1, + TX_SW1_LB_400 = 5, + TX_SW1_LB_575 = 2, TX_SW1_LB_1000 = 6, TX_SW1_LB_1700 = 0, TX_SW1_LB_2750 = 4 }; enum tx_sw2_t { - TX_SW2_LB_80 = 7, - TX_SW2_LB_160 = 3, - TX_SW2_LB_225 = 5, - TX_SW2_LB_400 = 1, - TX_SW2_LB_575 = 6, + TX_SW2_LB_80 = 7, + TX_SW2_LB_160 = 3, + TX_SW2_LB_225 = 5, + TX_SW2_LB_400 = 1, + TX_SW2_LB_575 = 6, TX_SW2_LB_1000 = 2, TX_SW2_LB_1700 = 4, TX_SW2_LB_2750 = 0 @@ -95,10 +76,10 @@ public: enum trx_sw_t { TRX1_SW_TX_HB = 2, TRX1_SW_TX_LB = 1, - TRX1_SW_RX = 4, + TRX1_SW_RX = 4, TRX2_SW_TX_HB = 2, TRX2_SW_TX_LB = 4, - TRX2_SW_RX = 1 + TRX2_SW_RX = 1 }; enum rx_sw1_t { @@ -108,7 +89,7 @@ public: RX_SW1_LB_B5 = 3, RX_SW1_LB_B6 = 0, RX_SW1_LB_B7 = 1, - RX_SW1_OFF = 7 + RX_SW1_OFF = 7 }; @@ -119,20 +100,16 @@ public: RX_SW2_LB_B5 = 2, RX_SW2_LB_B6 = 1, RX_SW2_LB_B7 = 0, - RX_SW2_OFF = 7 + RX_SW2_OFF = 7 }; enum rx_sw3_t { RX_SW3_HBRX_LBTRX = 1, RX_SW3_HBTRX_LBRX = 2, - RX_SW3_OFF = 0 //or 3 + RX_SW3_OFF = 0 // or 3 }; - enum tx_amp_t { - TX_AMP_HF_ON = 2, - TX_AMP_LF_ON = 1, - TX_AMP_OFF = 3 - }; + enum tx_amp_t { TX_AMP_HF_ON = 2, TX_AMP_LF_ON = 1, TX_AMP_OFF = 3 }; /************************************************************************ * Structors @@ -149,10 +126,11 @@ public: virtual bool check_radio_config(); //! Set which channel mode is used - void set_channel_mode(const std::string &channel_mode); + void set_channel_mode(const std::string& channel_mode); //! Set streaming mode - active chains, channel_mode, timing_mode - void set_streaming_mode(const bool tx1, const bool tx2, const bool rx1, const bool rx2); + void set_streaming_mode( + const bool tx1, const bool tx2, const bool rx1, const bool rx2); /*! Run a loopback self test. * @@ -163,19 +141,18 @@ public: * * \param iface An interface to the associated radio control core * \param iface The radio control core's address to write the loopback value - * \param iface The radio control core's readback address to read back the returned value + * \param iface The radio control core's readback address to read back the returned + * value * * \throws a uhd::runtime_error if the loopback value didn't match. */ - void loopback_self_test( - std::function<void(uint32_t)> poker_functor, - std::function<uint64_t()> peeker_functor - ); + void loopback_self_test(std::function<void(uint32_t)> poker_functor, + std::function<uint64_t()> peeker_functor); double set_rate(const double rate); - 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); @@ -186,13 +163,10 @@ public: double set_tx_gain(const double gain, const size_t chan); double set_rx_gain(const double gain, const size_t chan); - size_t get_chan_from_dboard_fe(const std::string &fe, const direction_t dir); + size_t get_chan_from_dboard_fe(const std::string& fe, const direction_t dir); std::string get_dboard_fe_from_chan(const size_t chan, const direction_t dir); - void set_rpc_client( - uhd::rpc_client::sptr rpcc, - const uhd::device_addr_t &block_args - ); + void set_rpc_client(uhd::rpc_client::sptr rpcc, const uhd::device_addr_t& block_args); private: /************************************************************************** @@ -205,10 +179,7 @@ private: void _init_defaults(); //! Init a subtree for the RF frontends - void _init_frontend_subtree( - uhd::property_tree::sptr subtree, - const size_t chan_idx - ); + void _init_frontend_subtree(uhd::property_tree::sptr subtree, const size_t chan_idx); //! Initialize Catalina defaults void _init_codec(); @@ -216,10 +187,7 @@ private: //! Initialize property tree void _init_prop_tree(); - void _init_mpm_sensors( - const direction_t dir, - const size_t chan_idx - ); + void _init_mpm_sensors(const direction_t dir, const size_t chan_idx); //! Map a frequency in Hz to an rx_band value. Will return // rx_band::INVALID_BAND if the frequency is out of range. @@ -233,33 +201,21 @@ private: *************************************************************************/ //! Return LO lock status. Factors in current band (low/high) and // direction (TX/RX) - bool get_lo_lock_status( - const direction_t dir - ); + bool get_lo_lock_status(const direction_t dir); /************************************************************************** * Misc Controls *************************************************************************/ //! Blink the front-panel LEDs for \p identify_duration, // and resume normal operation. - void _identify_with_leds( - const int identify_duration - ); + void _identify_with_leds(const int identify_duration); uint32_t _get_rx_switches( - const size_t chan, - const double freq, - const std::string &ant - ); + const size_t chan, const double freq, const std::string& ant); - uint32_t _get_tx_switches( - const size_t chan, - const double freq - ); + uint32_t _get_tx_switches(const size_t chan, const double freq); - void _set_atr_bits( - const size_t chan - ); + void _set_atr_bits(const size_t chan); /************************************************************************** * Private attributes @@ -283,7 +239,7 @@ private: uhd::spi_iface::sptr _spi; //! Reference to the AD9361 controls - //neon_ad9361_iface::uptr _ad9361; + // neon_ad9361_iface::uptr _ad9361; ad9361_ctrl::sptr _ad9361; //! ATR controls. These control the AD9361 gain @@ -305,4 +261,3 @@ private: }} /* namespace uhd::rfnoc */ #endif /* INCLUDED_LIBUHD_RFNOC_NEON_RADIO_CTRL_IMPL_HPP */ - diff --git a/host/lib/usrp/dboard/neon/neon_radio_ctrl_init.cpp b/host/lib/usrp/dboard/neon/neon_radio_ctrl_init.cpp index c71fd0169..783f0c7b2 100644 --- a/host/lib/usrp/dboard/neon/neon_radio_ctrl_init.cpp +++ b/host/lib/usrp/dboard/neon/neon_radio_ctrl_init.cpp @@ -4,17 +4,17 @@ // SPDX-License-Identifier: GPL-3.0-or-later // -#include "neon_radio_ctrl_impl.hpp" #include "neon_constants.hpp" -#include <uhd/utils/log.hpp> +#include "neon_radio_ctrl_impl.hpp" +#include <uhd/transport/chdr.hpp> #include <uhd/types/eeprom.hpp> #include <uhd/types/sensors.hpp> -#include <uhd/transport/chdr.hpp> +#include <uhd/utils/log.hpp> #include <boost/algorithm/string.hpp> -#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/case_conv.hpp> -#include <vector> +#include <boost/algorithm/string/split.hpp> #include <string> +#include <vector> using namespace uhd; using namespace uhd::rfnoc; @@ -25,32 +25,35 @@ using namespace uhd::rfnoc; // This function convert the format of attribute "Radio_N_M" // to a single value port number = N*number_of_port_per_radio + M -uint32_t _extract_port_number(std::string radio_src_string, uhd::property_tree::sptr ptree){ +uint32_t _extract_port_number( + std::string radio_src_string, uhd::property_tree::sptr ptree) +{ std::string s_val = "0"; std::vector<std::string> radio_strings; - boost::algorithm::split( - radio_strings, + boost::algorithm::split(radio_strings, radio_src_string, boost::is_any_of("_/"), boost::token_compress_on); boost::to_lower(radio_strings[0]); - if (radio_strings.size()<3) { - throw uhd::runtime_error(str(boost::format("%s is an invalid GPIO source string.") % radio_src_string)); + if (radio_strings.size() < 3) { + throw uhd::runtime_error(str( + boost::format("%s is an invalid GPIO source string.") % radio_src_string)); } size_t radio_num = std::stoi(radio_strings[1]); - size_t port_num = std::stoi(radio_strings[2]); + size_t port_num = std::stoi(radio_strings[2]); if (radio_strings[0] != "radio") { - throw uhd::runtime_error("Front panel GPIO bank can only accept a radio block as its driver."); + throw uhd::runtime_error( + "Front panel GPIO bank can only accept a radio block as its driver."); } - std::string radio_port_out = "Radio_"+ radio_strings[1] + "/ports/out"; - std::string radio_port_path = radio_port_out + "/"+ radio_strings[2]; - auto found = ptree->exists(fs_path("xbar")/ radio_port_path); - if (not found){ - throw uhd::runtime_error(str(boost::format( - "Could not find radio port %s.\n") % radio_port_path)); + std::string radio_port_out = "Radio_" + radio_strings[1] + "/ports/out"; + std::string radio_port_path = radio_port_out + "/" + radio_strings[2]; + auto found = ptree->exists(fs_path("xbar") / radio_port_path); + if (not found) { + throw uhd::runtime_error( + str(boost::format("Could not find radio port %s.\n") % radio_port_path)); } - size_t port_size = ptree->list(fs_path("xbar")/ radio_port_out).size(); - return radio_num*port_size + port_num; + size_t port_size = ptree->list(fs_path("xbar") / radio_port_out).size(); + return radio_num * port_size + port_num; } void neon_radio_ctrl_impl::_init_defaults() @@ -60,8 +63,7 @@ void neon_radio_ctrl_impl::_init_defaults() const size_t num_tx_chans = get_input_ports().size(); UHD_LOG_TRACE(unique_id(), - "Num TX chans: " << num_tx_chans - << " Num RX chans: " << num_rx_chans); + "Num TX chans: " << num_tx_chans << " Num RX chans: " << num_rx_chans); for (size_t chan = 0; chan < num_rx_chans; chan++) { radio_ctrl_impl::set_rx_frequency(NEON_DEFAULT_FREQ, chan); @@ -83,8 +85,7 @@ void neon_radio_ctrl_impl::_init_defaults() const size_t default_spp = (_tree->access<size_t>("mtu/recv").get() - max_bytes_header) / (2 * sizeof(int16_t)); - UHD_LOG_DEBUG(unique_id(), - "Setting default spp to " << default_spp); + UHD_LOG_DEBUG(unique_id(), "Setting default spp to " << default_spp); _tree->access<int>(get_arg_path("spp") / "value").set(default_spp); } @@ -92,255 +93,181 @@ void neon_radio_ctrl_impl::_init_peripherals() { UHD_LOG_TRACE(unique_id(), "Initializing peripherals..."); - _db_gpio.clear(); // Following the as-if rule, this can get optimized out + _db_gpio.clear(); // Following the as-if rule, this can get optimized out for (size_t radio_idx = 0; radio_idx < _get_num_radios(); radio_idx++) { - UHD_LOG_TRACE(unique_id(), - "Initializing GPIOs for channel " << radio_idx); - _db_gpio.emplace_back( - usrp::gpio_atr::gpio_atr_3000::make_write_only( - _get_ctrl(radio_idx), - regs::sr_addr(regs::GPIO) - ) - ); - _db_gpio[radio_idx]->set_atr_mode(usrp::gpio_atr::MODE_ATR, usrp::gpio_atr::gpio_atr_3000::MASK_SET_ALL); + UHD_LOG_TRACE(unique_id(), "Initializing GPIOs for channel " << radio_idx); + _db_gpio.emplace_back(usrp::gpio_atr::gpio_atr_3000::make_write_only( + _get_ctrl(radio_idx), regs::sr_addr(regs::GPIO))); + _db_gpio[radio_idx]->set_atr_mode( + usrp::gpio_atr::MODE_ATR, usrp::gpio_atr::gpio_atr_3000::MASK_SET_ALL); } - _leds_gpio.clear(); // Following the as-if rule, this can get optimized out + _leds_gpio.clear(); // Following the as-if rule, this can get optimized out for (size_t radio_idx = 0; radio_idx < _get_num_radios(); radio_idx++) { - UHD_LOG_TRACE(unique_id(), - "Initializing GPIOs for channel " << radio_idx); - _leds_gpio.emplace_back( - usrp::gpio_atr::gpio_atr_3000::make_write_only( - _get_ctrl(radio_idx), - regs::sr_addr(regs::LEDS) - ) - ); + UHD_LOG_TRACE(unique_id(), "Initializing GPIOs for channel " << radio_idx); + _leds_gpio.emplace_back(usrp::gpio_atr::gpio_atr_3000::make_write_only( + _get_ctrl(radio_idx), regs::sr_addr(regs::LEDS))); - _leds_gpio[radio_idx]->set_atr_mode(usrp::gpio_atr::MODE_ATR, usrp::gpio_atr::gpio_atr_3000::MASK_SET_ALL); + _leds_gpio[radio_idx]->set_atr_mode( + usrp::gpio_atr::MODE_ATR, usrp::gpio_atr::gpio_atr_3000::MASK_SET_ALL); } UHD_LOG_TRACE(unique_id(), "Initializing front-panel GPIO control...") _fp_gpio = usrp::gpio_atr::gpio_atr_3000::make( - _get_ctrl(0), - regs::sr_addr(regs::FP_GPIO), - regs::rb_addr(regs::RB_FP_GPIO) - ); + _get_ctrl(0), regs::sr_addr(regs::FP_GPIO), regs::rb_addr(regs::RB_FP_GPIO)); } void neon_radio_ctrl_impl::_init_frontend_subtree( - uhd::property_tree::sptr subtree, - const size_t chan_idx -) { + uhd::property_tree::sptr subtree, const size_t chan_idx) +{ const fs_path tx_fe_path = fs_path("tx_frontends") / chan_idx; const fs_path rx_fe_path = fs_path("rx_frontends") / chan_idx; UHD_LOG_TRACE(unique_id(), - "Adding non-RFNoC block properties for channel " << chan_idx << - " to prop tree path " << tx_fe_path << " and " << rx_fe_path); + "Adding non-RFNoC block properties for channel " + << chan_idx << " to prop tree path " << tx_fe_path << " and " << rx_fe_path); // TX Standard attributes - subtree->create<std::string>(tx_fe_path / "name") - .set(str(boost::format("Neon"))) - ; - subtree->create<std::string>(tx_fe_path / "connection") - .set("IQ") - ; + subtree->create<std::string>(tx_fe_path / "name").set(str(boost::format("Neon"))); + subtree->create<std::string>(tx_fe_path / "connection").set("IQ"); // RX Standard attributes - subtree->create<std::string>(rx_fe_path / "name") - .set(str(boost::format("Neon"))) - ; - subtree->create<std::string>(rx_fe_path / "connection") - .set("IQ") - ; + subtree->create<std::string>(rx_fe_path / "name").set(str(boost::format("Neon"))); + subtree->create<std::string>(rx_fe_path / "connection").set("IQ"); // TX Antenna subtree->create<std::string>(tx_fe_path / "antenna" / "value") - .add_coerced_subscriber([this, chan_idx](const std::string &ant){ + .add_coerced_subscriber([this, chan_idx](const std::string& ant) { this->set_tx_antenna(ant, chan_idx); }) - .set_publisher([this, chan_idx](){ - return this->get_tx_antenna(chan_idx); - }) - ; + .set_publisher([this, chan_idx]() { return this->get_tx_antenna(chan_idx); }); subtree->create<std::vector<std::string>>(tx_fe_path / "antenna" / "options") .set({NEON_DEFAULT_TX_ANTENNA}) - .add_coerced_subscriber([](const std::vector<std::string> &){ - throw uhd::runtime_error( - "Attempting to update antenna options!"); - }) - ; + .add_coerced_subscriber([](const std::vector<std::string>&) { + throw uhd::runtime_error("Attempting to update antenna options!"); + }); // RX Antenna subtree->create<std::string>(rx_fe_path / "antenna" / "value") - .add_coerced_subscriber([this, chan_idx](const std::string &ant){ + .add_coerced_subscriber([this, chan_idx](const std::string& ant) { this->set_rx_antenna(ant, chan_idx); }) - .set_publisher([this, chan_idx](){ - return this->get_rx_antenna(chan_idx); - }) - ; + .set_publisher([this, chan_idx]() { return this->get_rx_antenna(chan_idx); }); subtree->create<std::vector<std::string>>(rx_fe_path / "antenna" / "options") .set(NEON_RX_ANTENNAS) - .add_coerced_subscriber([](const std::vector<std::string> &){ - throw uhd::runtime_error( - "Attempting to update antenna options!"); - }) - ; + .add_coerced_subscriber([](const std::vector<std::string>&) { + throw uhd::runtime_error("Attempting to update antenna options!"); + }); // TX frequency subtree->create<double>(tx_fe_path / "freq" / "value") - .set_coercer([this, chan_idx](const double freq){ + .set_coercer([this, chan_idx](const double freq) { return this->set_tx_frequency(freq, chan_idx); }) - .set_publisher([this, chan_idx](){ - return this->get_tx_frequency(chan_idx); - }) - ; + .set_publisher([this, chan_idx]() { return this->get_tx_frequency(chan_idx); }); subtree->create<meta_range_t>(tx_fe_path / "freq" / "range") .set(meta_range_t(AD9361_TX_MIN_FREQ, AD9361_TX_MAX_FREQ, 1.0)) - .add_coerced_subscriber([](const meta_range_t &){ - throw uhd::runtime_error( - "Attempting to update freq range!"); - }) - ; + .add_coerced_subscriber([](const meta_range_t&) { + throw uhd::runtime_error("Attempting to update freq range!"); + }); // RX frequency subtree->create<double>(rx_fe_path / "freq" / "value") - .set_coercer([this, chan_idx](const double freq){ + .set_coercer([this, chan_idx](const double freq) { return this->set_rx_frequency(freq, chan_idx); }) - .set_publisher([this, chan_idx](){ - return this->get_rx_frequency(chan_idx); - }) - ; + .set_publisher([this, chan_idx]() { return this->get_rx_frequency(chan_idx); }); subtree->create<meta_range_t>(rx_fe_path / "freq" / "range") .set(meta_range_t(AD9361_RX_MIN_FREQ, AD9361_RX_MAX_FREQ, 1.0)) - .add_coerced_subscriber([](const meta_range_t &){ - throw uhd::runtime_error( - "Attempting to update freq range!"); - }) - ; + .add_coerced_subscriber([](const meta_range_t&) { + throw uhd::runtime_error("Attempting to update freq range!"); + }); // TX bandwidth subtree->create<double>(tx_fe_path / "bandwidth" / "value") .set(AD9361_TX_MAX_BANDWIDTH) - .set_coercer([this, chan_idx](const double bw){ + .set_coercer([this, chan_idx](const double bw) { return this->set_tx_bandwidth(bw, chan_idx); }) - .set_publisher([this, chan_idx](){ - return this->get_tx_bandwidth(chan_idx); - }) - ; + .set_publisher([this, chan_idx]() { return this->get_tx_bandwidth(chan_idx); }); subtree->create<meta_range_t>(tx_fe_path / "bandwidth" / "range") .set(meta_range_t(AD9361_TX_MIN_BANDWIDTH, AD9361_TX_MAX_BANDWIDTH)) - .add_coerced_subscriber([](const meta_range_t &){ - throw uhd::runtime_error( - "Attempting to update bandwidth range!"); - }) - ; + .add_coerced_subscriber([](const meta_range_t&) { + throw uhd::runtime_error("Attempting to update bandwidth range!"); + }); // RX bandwidth subtree->create<double>(rx_fe_path / "bandwidth" / "value") .set(AD9361_RX_MAX_BANDWIDTH) - .set_coercer([this, chan_idx](const double bw){ + .set_coercer([this, chan_idx](const double bw) { return this->set_rx_bandwidth(bw, chan_idx); - }) - ; + }); subtree->create<meta_range_t>(rx_fe_path / "bandwidth" / "range") .set(meta_range_t(AD9361_RX_MIN_BANDWIDTH, AD9361_RX_MAX_BANDWIDTH)) - .add_coerced_subscriber([](const meta_range_t &){ - throw uhd::runtime_error( - "Attempting to update bandwidth range!"); - }) - ; + .add_coerced_subscriber([](const meta_range_t&) { + throw uhd::runtime_error("Attempting to update bandwidth range!"); + }); // TX gains const std::vector<std::string> tx_gain_names = ad9361_ctrl::get_gain_names("TX1"); for (auto tx_gain_name : tx_gain_names) { subtree->create<double>(tx_fe_path / "gains" / tx_gain_name / "value") - .set_coercer([this, chan_idx](const double gain){ + .set_coercer([this, chan_idx](const double gain) { return this->set_tx_gain(gain, chan_idx); }) - .set_publisher([this, chan_idx](){ - return radio_ctrl_impl::get_tx_gain(chan_idx); - }) - ; + .set_publisher( + [this, chan_idx]() { return radio_ctrl_impl::get_tx_gain(chan_idx); }); subtree->create<meta_range_t>(tx_fe_path / "gains" / tx_gain_name / "range") - .add_coerced_subscriber([](const meta_range_t &){ - throw uhd::runtime_error( - "Attempting to update gain range!"); + .add_coerced_subscriber([](const meta_range_t&) { + throw uhd::runtime_error("Attempting to update gain range!"); }) - .set_publisher([this](){ - return meta_range_t( - AD9361_MIN_TX_GAIN, - AD9361_MAX_TX_GAIN, - AD9361_TX_GAIN_STEP - ); - }) - ; + .set_publisher([this]() { + return meta_range_t( + AD9361_MIN_TX_GAIN, AD9361_MAX_TX_GAIN, AD9361_TX_GAIN_STEP); + }); } // RX gains const std::vector<std::string> rx_gain_names = ad9361_ctrl::get_gain_names("RX1"); for (auto rx_gain_name : rx_gain_names) { subtree->create<double>(rx_fe_path / "gains" / rx_gain_name / "value") - .set_coercer([this, chan_idx](const double gain){ + .set_coercer([this, chan_idx](const double gain) { return this->set_rx_gain(gain, chan_idx); }) - .set_publisher([this, chan_idx](){ - return radio_ctrl_impl::get_rx_gain(chan_idx); - }) - ; + .set_publisher( + [this, chan_idx]() { return radio_ctrl_impl::get_rx_gain(chan_idx); }); subtree->create<meta_range_t>(rx_fe_path / "gains" / rx_gain_name / "range") - .add_coerced_subscriber([](const meta_range_t &){ - throw uhd::runtime_error( - "Attempting to update gain range!"); + .add_coerced_subscriber([](const meta_range_t&) { + throw uhd::runtime_error("Attempting to update gain range!"); }) - .set_publisher([this](){ + .set_publisher([this]() { return meta_range_t( - AD9361_MIN_RX_GAIN, - AD9361_MAX_RX_GAIN, - AD9361_RX_GAIN_STEP - ); - }) - ; + AD9361_MIN_RX_GAIN, AD9361_MAX_RX_GAIN, AD9361_RX_GAIN_STEP); + }); } // TX LO lock sensor ////////////////////////////////////////////////////// // Note: The AD9361 LO lock sensors are generated programmatically in // set_rpc_client(). The actual lo_locked publisher is also set there. subtree->create<sensor_value_t>(tx_fe_path / "sensors" / "lo_locked") - .set(sensor_value_t("all_los", false, "locked", "unlocked")) - .add_coerced_subscriber([](const sensor_value_t &){ - throw uhd::runtime_error( - "Attempting to write to sensor!"); + .set(sensor_value_t("all_los", false, "locked", "unlocked")) + .add_coerced_subscriber([](const sensor_value_t&) { + throw uhd::runtime_error("Attempting to write to sensor!"); }) - .set_publisher([this](){ + .set_publisher([this]() { return sensor_value_t( - "all_los", - this->get_lo_lock_status(TX_DIRECTION), - "locked", "unlocked" - ); - }) - ; + "all_los", this->get_lo_lock_status(TX_DIRECTION), "locked", "unlocked"); + }); // RX LO lock sensor (see not on TX LO lock sensor) subtree->create<sensor_value_t>(rx_fe_path / "sensors" / "lo_locked") - .set(sensor_value_t("all_los", false, "locked", "unlocked")) - .add_coerced_subscriber([](const sensor_value_t &){ - throw uhd::runtime_error( - "Attempting to write to sensor!"); + .set(sensor_value_t("all_los", false, "locked", "unlocked")) + .add_coerced_subscriber([](const sensor_value_t&) { + throw uhd::runtime_error("Attempting to write to sensor!"); }) - .set_publisher([this](){ + .set_publisher([this]() { return sensor_value_t( - "all_los", - this->get_lo_lock_status(RX_DIRECTION), - "locked", "unlocked" - ); - }) - ; + "all_los", this->get_lo_lock_status(RX_DIRECTION), "locked", "unlocked"); + }); } void neon_radio_ctrl_impl::_init_prop_tree() { const fs_path fe_base = fs_path("dboards") / _radio_slot; for (size_t chan_idx = 0; chan_idx < NEON_NUM_CHANS; chan_idx++) { - this->_init_frontend_subtree( - _tree->subtree(fe_base), chan_idx); + this->_init_frontend_subtree(_tree->subtree(fe_base), chan_idx); } - _tree->create<eeprom_map_t>(_root_path / "eeprom") - .set(eeprom_map_t()); + _tree->create<eeprom_map_t>(_root_path / "eeprom").set(eeprom_map_t()); _tree->create<int>("rx_codecs" / _radio_slot / "gains"); _tree->create<int>("tx_codecs" / _radio_slot / "gains"); @@ -349,98 +276,108 @@ void neon_radio_ctrl_impl::_init_prop_tree() if (not _tree->exists("tick_rate")) { _tree->create<double>("tick_rate") - .set_coercer([this](double tick_rate){ - return this->set_rate(tick_rate); - }) - .set_publisher([this](){ - return this->get_rate(); - }) - ; + .set_coercer([this](double tick_rate) { return this->set_rate(tick_rate); }) + .set_publisher([this]() { return this->get_rate(); }); } else { UHD_LOG_WARNING(unique_id(), "Cannot set tick_rate again"); } // *****FP_GPIO************************ - for(const auto& attr: usrp::gpio_atr::gpio_attr_map) { - if (not _tree->exists(fs_path("gpio") / "FP0" / attr.second)){ - switch (attr.first){ + for (const auto& attr : usrp::gpio_atr::gpio_attr_map) { + if (not _tree->exists(fs_path("gpio") / "FP0" / attr.second)) { + switch (attr.first) { case usrp::gpio_atr::GPIO_SRC: - //FIXME: move this creation of this branch of ptree out side of radio impl; - // since there's no data dependency between radio and SRC setting for FP0 - _tree->create<std::vector<std::string>>(fs_path("gpio") / "FP0" / attr.second) - .set(std::vector<std::string>( - 32, - usrp::gpio_atr::default_attr_value_map.at(attr.first))) - .add_coerced_subscriber([this, attr]( - const std::vector<std::string> str_val){ - uint32_t radio_src_value = 0; - uint32_t master_value = 0; - for(size_t i = 0 ; i<str_val.size(); i++){ - if(str_val[i] == "PS"){ - master_value += 1<<i;; - }else{ - auto port_num = _extract_port_number(str_val[i],_tree); - radio_src_value =(1<<(2*i))*port_num + radio_src_value; + // FIXME: move this creation of this branch of ptree out side of + // radio impl; + // since there's no data dependency between radio and SRC setting for + // FP0 + _tree + ->create<std::vector<std::string>>( + fs_path("gpio") / "FP0" / attr.second) + .set(std::vector<std::string>( + 32, usrp::gpio_atr::default_attr_value_map.at(attr.first))) + .add_coerced_subscriber( + [this, attr](const std::vector<std::string> str_val) { + uint32_t radio_src_value = 0; + uint32_t master_value = 0; + for (size_t i = 0; i < str_val.size(); i++) { + if (str_val[i] == "PS") { + master_value += 1 << i; + ; + } else { + auto port_num = + _extract_port_number(str_val[i], _tree); + radio_src_value = + (1 << (2 * i)) * port_num + radio_src_value; + } } - } - _rpcc->notify_with_token("set_fp_gpio_master", master_value); - _rpcc->notify_with_token("set_fp_gpio_radio_src", radio_src_value); - }); - break; + _rpcc->notify_with_token( + "set_fp_gpio_master", master_value); + _rpcc->notify_with_token( + "set_fp_gpio_radio_src", radio_src_value); + }); + break; case usrp::gpio_atr::GPIO_CTRL: case usrp::gpio_atr::GPIO_DDR: - _tree->create<std::vector<std::string>>(fs_path("gpio") / "FP0" / attr.second) - .set(std::vector<std::string>( - 32, - usrp::gpio_atr::default_attr_value_map.at(attr.first))) - .add_coerced_subscriber([this, attr]( - const std::vector<std::string> str_val){ - uint32_t val = 0; - for(size_t i = 0 ; i < str_val.size() ; i++){ - val += usrp::gpio_atr::gpio_attr_value_pair.at(attr.second).at(str_val[i])<<i; - } - _fp_gpio->set_gpio_attr(attr.first, val); - }); + _tree + ->create<std::vector<std::string>>( + fs_path("gpio") / "FP0" / attr.second) + .set(std::vector<std::string>( + 32, usrp::gpio_atr::default_attr_value_map.at(attr.first))) + .add_coerced_subscriber( + [this, attr](const std::vector<std::string> str_val) { + uint32_t val = 0; + for (size_t i = 0; i < str_val.size(); i++) { + val += usrp::gpio_atr::gpio_attr_value_pair + .at(attr.second) + .at(str_val[i]) + << i; + } + _fp_gpio->set_gpio_attr(attr.first, val); + }); break; - case usrp::gpio_atr::GPIO_READBACK:{ + case usrp::gpio_atr::GPIO_READBACK: { _tree->create<uint32_t>(fs_path("gpio") / "FP0" / attr.second) - .set_publisher([this](){ - return _fp_gpio->read_gpio(); - } - ); - } - break; + .set_publisher([this]() { return _fp_gpio->read_gpio(); }); + } break; default: _tree->create<uint32_t>(fs_path("gpio") / "FP0" / attr.second) - .set(0) - .add_coerced_subscriber([this, attr](const uint32_t val){ - _fp_gpio->set_gpio_attr(attr.first, val); - }); + .set(0) + .add_coerced_subscriber([this, attr](const uint32_t val) { + _fp_gpio->set_gpio_attr(attr.first, val); + }); } - }else{ - switch (attr.first){ + } else { + switch (attr.first) { case usrp::gpio_atr::GPIO_SRC: - break; + break; case usrp::gpio_atr::GPIO_CTRL: case usrp::gpio_atr::GPIO_DDR: - _tree->access<std::vector<std::string>>(fs_path("gpio") / "FP0" / attr.second) - .set(std::vector<std::string>(32, usrp::gpio_atr::default_attr_value_map.at(attr.first))) - .add_coerced_subscriber([this, attr](const std::vector<std::string> str_val){ - uint32_t val = 0; - for(size_t i = 0 ; i < str_val.size() ; i++){ - val += usrp::gpio_atr::gpio_attr_value_pair.at(attr.second).at(str_val[i])<<i; - } - _fp_gpio->set_gpio_attr(attr.first, val); - }); + _tree + ->access<std::vector<std::string>>( + fs_path("gpio") / "FP0" / attr.second) + .set(std::vector<std::string>( + 32, usrp::gpio_atr::default_attr_value_map.at(attr.first))) + .add_coerced_subscriber( + [this, attr](const std::vector<std::string> str_val) { + uint32_t val = 0; + for (size_t i = 0; i < str_val.size(); i++) { + val += usrp::gpio_atr::gpio_attr_value_pair + .at(attr.second) + .at(str_val[i]) + << i; + } + _fp_gpio->set_gpio_attr(attr.first, val); + }); break; case usrp::gpio_atr::GPIO_READBACK: break; default: _tree->access<uint32_t>(fs_path("gpio") / "FP0" / attr.second) - .set(0) - .add_coerced_subscriber([this, attr](const uint32_t val){ - _fp_gpio->set_gpio_attr(attr.first, val); - }); + .set(0) + .add_coerced_subscriber([this, attr](const uint32_t val) { + _fp_gpio->set_gpio_attr(attr.first, val); + }); } } } @@ -464,35 +401,27 @@ void neon_radio_ctrl_impl::_init_codec() } } -void neon_radio_ctrl_impl::_init_mpm_sensors( - const direction_t dir, - const size_t chan_idx -) { +void neon_radio_ctrl_impl::_init_mpm_sensors(const direction_t dir, const size_t chan_idx) +{ const std::string trx = (dir == RX_DIRECTION) ? "RX" : "TX"; - const fs_path fe_path = - fs_path("dboards") / _radio_slot / - (dir == RX_DIRECTION ? "rx_frontends" : "tx_frontends") / chan_idx; - auto sensor_list = - _rpcc->request_with_token<std::vector<std::string>>( - this->_rpc_prefix + "get_sensors", trx); + const fs_path fe_path = fs_path("dboards") / _radio_slot + / (dir == RX_DIRECTION ? "rx_frontends" : "tx_frontends") + / chan_idx; + auto sensor_list = _rpcc->request_with_token<std::vector<std::string>>( + this->_rpc_prefix + "get_sensors", trx); UHD_LOG_TRACE(unique_id(), - "Chan " << chan_idx << ": Found " - << sensor_list.size() << " " << trx << " sensors."); - for (const auto &sensor_name : sensor_list) { - UHD_LOG_TRACE(unique_id(), - "Adding " << trx << " sensor " << sensor_name); + "Chan " << chan_idx << ": Found " << sensor_list.size() << " " << trx + << " sensors."); + for (const auto& sensor_name : sensor_list) { + UHD_LOG_TRACE(unique_id(), "Adding " << trx << " sensor " << sensor_name); _tree->create<sensor_value_t>(fe_path / "sensors" / sensor_name) - .add_coerced_subscriber([](const sensor_value_t &){ - throw uhd::runtime_error( - "Attempting to write to sensor!"); + .add_coerced_subscriber([](const sensor_value_t&) { + throw uhd::runtime_error("Attempting to write to sensor!"); }) - .set_publisher([this, trx, sensor_name, chan_idx](){ + .set_publisher([this, trx, sensor_name, chan_idx]() { return sensor_value_t( this->_rpcc->request_with_token<sensor_value_t::sensor_map_t>( - this->_rpc_prefix + "get_sensor", - trx, sensor_name, chan_idx) - ); - }) - ; + this->_rpc_prefix + "get_sensor", trx, sensor_name, chan_idx)); + }); } } diff --git a/host/lib/usrp/dboard/neon/neon_regs.hpp b/host/lib/usrp/dboard/neon/neon_regs.hpp index 39ceca01c..d1ff940c6 100644 --- a/host/lib/usrp/dboard/neon/neon_regs.hpp +++ b/host/lib/usrp/dboard/neon/neon_regs.hpp @@ -10,17 +10,16 @@ #include <uhd/config.hpp> #include <cstdint> -static const uint32_t TX_AMP_SHIFT = 17; -static const uint32_t TRX_SW_SHIFT = 14; -static const uint32_t RX_SW1_SHIFT = 0; -static const uint32_t RX_SW2_SHIFT = 3; -static const uint32_t RX_SW3_SHIFT = 6; -static const uint32_t TX_SW1_SHIFT = 8; -static const uint32_t TX_SW2_SHIFT = 11; +static const uint32_t TX_AMP_SHIFT = 17; +static const uint32_t TRX_SW_SHIFT = 14; +static const uint32_t RX_SW1_SHIFT = 0; +static const uint32_t RX_SW2_SHIFT = 3; +static const uint32_t RX_SW3_SHIFT = 6; +static const uint32_t TX_SW1_SHIFT = 8; +static const uint32_t TX_SW2_SHIFT = 11; -static const uint32_t TRX_LED_GRN_SHIFT = 0; +static const uint32_t TRX_LED_GRN_SHIFT = 0; static const uint32_t TX_LED_RED_SHIFT = 1; static const uint32_t RX_LED_GRN_SHIFT = 2; #endif /* INCLUDED_NEON_REGS_HPP */ - |