diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-01-16 18:51:03 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-01-16 18:51:03 -0800 |
commit | 4c47498e2e5d0417a39313c74a7eb56d1b5b625b (patch) | |
tree | e0883e0af07765c9ced2e459eb7e48dcce830eb9 /host/lib | |
parent | ccb09ba68bc11f110c0ed73cf211c1b168da820d (diff) | |
download | uhd-4c47498e2e5d0417a39313c74a7eb56d1b5b625b.tar.gz uhd-4c47498e2e5d0417a39313c74a7eb56d1b5b625b.tar.bz2 uhd-4c47498e2e5d0417a39313c74a7eb56d1b5b625b.zip |
mg: Fix various compiler warnings
- Made const constexpr where sensible
- Moved non-global constants to their local scope
- Changed const char * to const char[] where they should
Diffstat (limited to 'host/lib')
3 files changed, 48 insertions, 47 deletions
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_constants.hpp b/host/lib/usrp/dboard/magnesium/magnesium_constants.hpp index 0d914636e..dda2aea44 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_constants.hpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_constants.hpp @@ -11,66 +11,59 @@ #include <string> #include <cstddef> -static const size_t FPGPIO_MASTER_RADIO = 0; +static constexpr size_t FPGPIO_MASTER_RADIO = 0; -static const double AD9371_MIN_FREQ = 300.0e6; // Hz -static const double AD9371_MAX_FREQ = 6.0e9; // Hz +static constexpr double AD9371_MIN_FREQ = 300.0e6; // Hz +static constexpr double AD9371_MAX_FREQ = 6.0e9; // Hz -static const double ADF4351_MIN_FREQ = 35.0e6; -static const double ADF4351_MAX_FREQ = 4.4e9; +static constexpr double ADF4351_MIN_FREQ = 35.0e6; +static constexpr double ADF4351_MAX_FREQ = 4.4e9; -static const double MAGNESIUM_RADIO_RATE = 125e6; // Hz -static const double MAGNESIUM_MIN_FREQ = 1e6; // Hz -static const double MAGNESIUM_MAX_FREQ = 6e9; // Hz +static constexpr double MAGNESIUM_RADIO_RATE = 125e6; // Hz +static constexpr double MAGNESIUM_MIN_FREQ = 1e6; // Hz +static constexpr double MAGNESIUM_MAX_FREQ = 6e9; // Hz static constexpr double MAGNESIUM_LOWBAND_FREQ = 300e6; -static const double AD9371_MIN_RX_GAIN = 0.0; // dB -static const double AD9371_MAX_RX_GAIN = 30.0; // dB -static const double AD9371_RX_GAIN_STEP = 0.5; -static const double DSA_MIN_GAIN = 0; // dB -static const double DSA_MAX_GAIN = 31.5; // dB -static const double DSA_GAIN_STEP = 0.5; // db -static const double AMP_MIN_GAIN = 0; // dB -static const double AMP_MAX_GAIN = 10; // dB -static const double AMP_GAIN_STEP = 10;// dB -static const double AD9371_MIN_TX_GAIN = 0.0; // dB -static const double AD9371_MAX_TX_GAIN = 41.95; // dB -static const double AD9371_TX_GAIN_STEP = 0.05; -static const double ALL_RX_MIN_GAIN = 0.0; -static const double ALL_RX_MAX_GAIN = 75.0; -static const double ALL_RX_GAIN_STEP = 0.5; -static const double ALL_TX_MIN_GAIN = 0.0; -static const double ALL_TX_MAX_GAIN = 65.0; -static const double ALL_TX_GAIN_STEP = 0.5; +static constexpr double AD9371_MIN_RX_GAIN = 0.0; // dB +static constexpr double AD9371_MAX_RX_GAIN = 30.0; // dB +static constexpr double AD9371_RX_GAIN_STEP = 0.5; +static constexpr double DSA_MIN_GAIN = 0; // dB +static constexpr double DSA_MAX_GAIN = 31.5; // dB +static constexpr double DSA_GAIN_STEP = 0.5; // db +static constexpr double AMP_MIN_GAIN = 0; // dB +static constexpr double AMP_MAX_GAIN = 10; // dB +static constexpr double AMP_GAIN_STEP = 10;// dB +static constexpr double AD9371_MIN_TX_GAIN = 0.0; // dB +static constexpr double AD9371_MAX_TX_GAIN = 41.95; // dB +static constexpr double AD9371_TX_GAIN_STEP = 0.05; +static constexpr double ALL_RX_MIN_GAIN = 0.0; +static constexpr double ALL_RX_MAX_GAIN = 75.0; +static constexpr double ALL_RX_GAIN_STEP = 0.5; +static constexpr double ALL_TX_MIN_GAIN = 0.0; +static constexpr double ALL_TX_MAX_GAIN = 65.0; +static constexpr double ALL_TX_GAIN_STEP = 0.5; -static const double MAGNESIUM_CENTER_FREQ = 2.5e9; // Hz static const std::vector<std::string> MAGNESIUM_RX_ANTENNAS = { "TX/RX", "RX2", "CAL", "LOCAL" }; //! AD9371 LO (for direct conversion) -static const char* MAGNESIUM_LO1 = "rfic"; +static constexpr char MAGNESIUM_LO1[] = "rfic"; //! Low-band LO (for IF conversion) -static const char* MAGNESIUM_LO2 = "lowband"; -//! Magnesium gain profile options -static const std::vector<std::string> MAGNESIUM_GP_OPTIONS = { - "manual", - "default" -}; +static constexpr char MAGNESIUM_LO2[] = "lowband"; //! AD9371 attenuation -static const char* MAGNESIUM_GAIN1 = "rfic"; +static constexpr char MAGNESIUM_GAIN1[] = "rfic"; //! DSA attenuation -static const char* MAGNESIUM_GAIN2 = "dsa"; +static constexpr char MAGNESIUM_GAIN2[] = "dsa"; //! Amplifier gain -static const char* MAGNESIUM_AMP = "amp"; +static constexpr char MAGNESIUM_AMP[] = "amp"; -static const double MAGNESIUM_DEFAULT_BANDWIDTH = 40e6; // Hz TODO: fix // Note: MAGNESIUM_NUM_CHANS is independent of the number of chans per // RFNoC block. TODO: When we go to one radio per dboard, this comment can // be deleted. -static const size_t MAGNESIUM_NUM_CHANS = 2; -static const double MAGNESIUM_RX_IF_FREQ = 2.44e9; -static const double MAGNESIUM_TX_IF_FREQ = 1.95e9; +static constexpr size_t MAGNESIUM_NUM_CHANS = 2; +static constexpr double MAGNESIUM_RX_IF_FREQ = 2.44e9; +static constexpr double MAGNESIUM_TX_IF_FREQ = 1.95e9; #endif /* INCLUDED_LIBUHD_MAGNESIUM_CONSTANTS_HPP */ diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp index 2d61ef1ff..51010ac1f 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp @@ -449,7 +449,7 @@ double magnesium_radio_ctrl_impl::_set_tx_gain( double magnesium_radio_ctrl_impl::_get_tx_gain( const std::string &name, - const size_t chan + const size_t /*chan*/ ) { std::lock_guard<std::mutex> l(_set_lock); if (name == MAGNESIUM_GAIN1){ @@ -514,7 +514,7 @@ double magnesium_radio_ctrl_impl::_set_rx_gain( double magnesium_radio_ctrl_impl::_get_rx_gain( const std::string &name, - const size_t chan + const size_t /*chan*/ ) { std::lock_guard<std::mutex> l(_set_lock); diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_init.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_init.cpp index 5eb3cacd0..85e4a5e30 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_init.cpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_init.cpp @@ -25,8 +25,16 @@ namespace { SEN_PHASE_DAC = 8 }; - const char* MAGNESIUM_DEFAULT_RX_ANTENNA = "RX2"; - const char* MAGNESIUM_DEFAULT_TX_ANTENNA = "TX/RX"; + constexpr double MAGNESIUM_DEFAULT_FREQ = 2.5e9; // Hz + constexpr double MAGNESIUM_DEFAULT_BANDWIDTH = 40e6; // Hz + constexpr char MAGNESIUM_DEFAULT_RX_ANTENNA[] = "RX2"; + constexpr char MAGNESIUM_DEFAULT_TX_ANTENNA[] = "TX/RX"; + + //! Magnesium gain profile options + const std::vector<std::string> MAGNESIUM_GP_OPTIONS = { + "manual", + "default" + }; } void magnesium_radio_ctrl_impl::_init_defaults() @@ -40,14 +48,14 @@ void magnesium_radio_ctrl_impl::_init_defaults() << " Num RX chans: " << num_rx_chans); for (size_t chan = 0; chan < num_rx_chans; chan++) { - radio_ctrl_impl::set_rx_frequency(MAGNESIUM_CENTER_FREQ, chan); + radio_ctrl_impl::set_rx_frequency(MAGNESIUM_DEFAULT_FREQ, chan); radio_ctrl_impl::set_rx_gain(0, chan); radio_ctrl_impl::set_rx_antenna(MAGNESIUM_DEFAULT_RX_ANTENNA, chan); radio_ctrl_impl::set_rx_bandwidth(MAGNESIUM_DEFAULT_BANDWIDTH, chan); } for (size_t chan = 0; chan < num_tx_chans; chan++) { - radio_ctrl_impl::set_tx_frequency(MAGNESIUM_CENTER_FREQ, chan); + radio_ctrl_impl::set_tx_frequency(MAGNESIUM_DEFAULT_FREQ, chan); radio_ctrl_impl::set_tx_gain(0, chan); radio_ctrl_impl::set_tx_antenna(MAGNESIUM_DEFAULT_TX_ANTENNA, chan); } |