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/magnesium/magnesium_cpld_ctrl.cpp | |
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/magnesium/magnesium_cpld_ctrl.cpp')
-rw-r--r-- | host/lib/usrp/dboard/magnesium/magnesium_cpld_ctrl.cpp | 183 |
1 files changed, 83 insertions, 100 deletions
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_cpld_ctrl.cpp b/host/lib/usrp/dboard/magnesium/magnesium_cpld_ctrl.cpp index 3e68e2011..172f26390 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_cpld_ctrl.cpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_cpld_ctrl.cpp @@ -11,35 +11,26 @@ #include <chrono> namespace { - //! Address of the CPLD scratch register - const uint8_t CPLD_REGS_SCRATCH = 0x0040; +//! Address of the CPLD scratch register +const uint8_t CPLD_REGS_SCRATCH = 0x0040; - //! Address of the CPLD reset register - const uint8_t CPLD_REGS_RESET = 0x0041; -} +//! Address of the CPLD reset register +const uint8_t CPLD_REGS_RESET = 0x0041; +} // namespace -magnesium_cpld_ctrl::magnesium_cpld_ctrl( - write_spi_t write_fn, - read_spi_t read_fn -) +magnesium_cpld_ctrl::magnesium_cpld_ctrl(write_spi_t write_fn, read_spi_t read_fn) { - _write_fn = [write_fn](const uint8_t addr, const uint32_t data){ + _write_fn = [write_fn](const uint8_t addr, const uint32_t data) { UHD_LOG_TRACE("MG_CPLD", - str(boost::format("Writing to CPLD: 0x%02X -> 0x%04X") - % uint32_t(addr) % data)); - const uint32_t spi_transaction = 0 - | ((addr & 0x7F) << 16) - | data - ; + str(boost::format("Writing to CPLD: 0x%02X -> 0x%04X") % uint32_t(addr) + % data)); + const uint32_t spi_transaction = 0 | ((addr & 0x7F) << 16) | data; write_fn(spi_transaction); }; - _read_fn = [read_fn](const uint8_t addr){ + _read_fn = [read_fn](const uint8_t addr) { UHD_LOG_TRACE("MG_CPLD", - str(boost::format("Reading from CPLD address 0x%02X") - % uint32_t(addr))); - const uint32_t spi_transaction = (1<<23) - | ((addr & 0x7F) << 16) - ; + str(boost::format("Reading from CPLD address 0x%02X") % uint32_t(addr))); + const uint32_t spi_transaction = (1 << 23) | ((addr & 0x7F) << 16); return read_fn(spi_transaction); }; @@ -82,23 +73,24 @@ uint16_t magnesium_cpld_ctrl::get_scratch() return get_reg(CPLD_REGS_SCRATCH); } -void magnesium_cpld_ctrl::set_tx_switches( - const chan_sel_t chan, +void magnesium_cpld_ctrl::set_tx_switches(const chan_sel_t chan, const tx_sw1_t tx_sw1, const tx_sw2_t tx_sw2, const tx_sw3_t tx_sw3, const lowband_mixer_path_sel_t select_lowband_mixer_path, const bool enb_lowband_mixer, const atr_state_t atr_state, - const bool defer_commit -) { + const bool defer_commit) +{ std::lock_guard<std::mutex> l(_set_mutex); if (chan == CHAN1 or chan == BOTH) { if (atr_state == IDLE or atr_state == ANY) { _regs.ch1_idle_tx_sw1 = magnesium_cpld_regs_t::ch1_idle_tx_sw1_t(tx_sw1); _regs.ch1_idle_tx_sw2 = magnesium_cpld_regs_t::ch1_idle_tx_sw2_t(tx_sw2); _regs.ch1_idle_tx_sw3 = magnesium_cpld_regs_t::ch1_idle_tx_sw3_t(tx_sw3); - _regs.ch1_idle_tx_lowband_mixer_path_select = magnesium_cpld_regs_t::ch1_idle_tx_lowband_mixer_path_select_t(select_lowband_mixer_path); + _regs.ch1_idle_tx_lowband_mixer_path_select = + magnesium_cpld_regs_t::ch1_idle_tx_lowband_mixer_path_select_t( + select_lowband_mixer_path); _regs.ch1_idle_tx_mixer_en = enb_lowband_mixer; } if (atr_state == ON or atr_state == ANY) { @@ -106,7 +98,8 @@ void magnesium_cpld_ctrl::set_tx_switches( _regs.ch1_on_tx_sw2 = magnesium_cpld_regs_t::ch1_on_tx_sw2_t(tx_sw2); _regs.ch1_on_tx_sw3 = magnesium_cpld_regs_t::ch1_on_tx_sw3_t(tx_sw3); _regs.ch1_on_tx_lowband_mixer_path_select = - magnesium_cpld_regs_t::ch1_on_tx_lowband_mixer_path_select_t(select_lowband_mixer_path); + magnesium_cpld_regs_t::ch1_on_tx_lowband_mixer_path_select_t( + select_lowband_mixer_path); _regs.ch1_on_tx_mixer_en = enb_lowband_mixer; } } @@ -116,7 +109,8 @@ void magnesium_cpld_ctrl::set_tx_switches( _regs.ch2_idle_tx_sw2 = magnesium_cpld_regs_t::ch2_idle_tx_sw2_t(tx_sw1); _regs.ch2_idle_tx_sw3 = magnesium_cpld_regs_t::ch2_idle_tx_sw3_t(tx_sw1); _regs.ch2_idle_tx_lowband_mixer_path_select = - magnesium_cpld_regs_t::ch2_idle_tx_lowband_mixer_path_select_t(select_lowband_mixer_path); + magnesium_cpld_regs_t::ch2_idle_tx_lowband_mixer_path_select_t( + select_lowband_mixer_path); _regs.ch2_idle_tx_mixer_en = enb_lowband_mixer; } if (atr_state == ON or atr_state == ANY) { @@ -124,7 +118,8 @@ void magnesium_cpld_ctrl::set_tx_switches( _regs.ch2_on_tx_sw2 = magnesium_cpld_regs_t::ch2_on_tx_sw2_t(tx_sw2); _regs.ch2_on_tx_sw3 = magnesium_cpld_regs_t::ch2_on_tx_sw3_t(tx_sw3); _regs.ch2_on_tx_lowband_mixer_path_select = - magnesium_cpld_regs_t::ch2_on_tx_lowband_mixer_path_select_t(select_lowband_mixer_path); + magnesium_cpld_regs_t::ch2_on_tx_lowband_mixer_path_select_t( + select_lowband_mixer_path); _regs.ch2_on_tx_mixer_en = enb_lowband_mixer; } } @@ -134,8 +129,7 @@ void magnesium_cpld_ctrl::set_tx_switches( } } -void magnesium_cpld_ctrl::set_rx_switches( - const chan_sel_t chan, +void magnesium_cpld_ctrl::set_rx_switches(const chan_sel_t chan, const rx_sw2_t rx_sw2, const rx_sw3_t rx_sw3, const rx_sw4_t rx_sw4, @@ -144,8 +138,8 @@ void magnesium_cpld_ctrl::set_rx_switches( const lowband_mixer_path_sel_t select_lowband_mixer_path, const bool enb_lowband_mixer, const atr_state_t atr_state, - const bool defer_commit -) { + const bool defer_commit) +{ std::lock_guard<std::mutex> l(_set_mutex); if (chan == CHAN1 or chan == BOTH) { if (atr_state == IDLE or atr_state == ANY) { @@ -154,7 +148,9 @@ void magnesium_cpld_ctrl::set_rx_switches( _regs.ch1_idle_rx_sw4 = magnesium_cpld_regs_t::ch1_idle_rx_sw4_t(rx_sw4); _regs.ch1_idle_rx_sw5 = magnesium_cpld_regs_t::ch1_idle_rx_sw5_t(rx_sw5); _regs.ch1_idle_rx_sw6 = magnesium_cpld_regs_t::ch1_idle_rx_sw6_t(rx_sw6); - _regs.ch1_idle_rx_loband_mixer_path_sel = magnesium_cpld_regs_t::ch1_idle_rx_loband_mixer_path_sel_t(select_lowband_mixer_path); + _regs.ch1_idle_rx_loband_mixer_path_sel = + magnesium_cpld_regs_t::ch1_idle_rx_loband_mixer_path_sel_t( + select_lowband_mixer_path); _regs.ch1_idle_rx_mixer_en = enb_lowband_mixer; } if (atr_state == ON or atr_state == ANY) { @@ -163,7 +159,9 @@ void magnesium_cpld_ctrl::set_rx_switches( _regs.ch1_on_rx_sw4 = magnesium_cpld_regs_t::ch1_on_rx_sw4_t(rx_sw4); _regs.ch1_on_rx_sw5 = magnesium_cpld_regs_t::ch1_on_rx_sw5_t(rx_sw5); _regs.ch1_on_rx_sw6 = magnesium_cpld_regs_t::ch1_on_rx_sw6_t(rx_sw6); - _regs.ch1_on_rx_loband_mixer_path_sel = magnesium_cpld_regs_t::ch1_on_rx_loband_mixer_path_sel_t(select_lowband_mixer_path); + _regs.ch1_on_rx_loband_mixer_path_sel = + magnesium_cpld_regs_t::ch1_on_rx_loband_mixer_path_sel_t( + select_lowband_mixer_path); _regs.ch1_on_rx_mixer_en = enb_lowband_mixer; } } @@ -175,7 +173,8 @@ void magnesium_cpld_ctrl::set_rx_switches( _regs.ch2_idle_rx_sw5 = magnesium_cpld_regs_t::ch2_idle_rx_sw5_t(rx_sw5); _regs.ch2_idle_rx_sw6 = magnesium_cpld_regs_t::ch2_idle_rx_sw6_t(rx_sw6); _regs.ch2_idle_rx_loband_mixer_path_sel = - magnesium_cpld_regs_t::ch2_idle_rx_loband_mixer_path_sel_t(select_lowband_mixer_path); + magnesium_cpld_regs_t::ch2_idle_rx_loband_mixer_path_sel_t( + select_lowband_mixer_path); _regs.ch2_idle_rx_mixer_en = enb_lowband_mixer; } if (atr_state == ON or atr_state == ANY) { @@ -184,7 +183,9 @@ void magnesium_cpld_ctrl::set_rx_switches( _regs.ch2_on_rx_sw4 = magnesium_cpld_regs_t::ch2_on_rx_sw4_t(rx_sw4); _regs.ch2_on_rx_sw5 = magnesium_cpld_regs_t::ch2_on_rx_sw5_t(rx_sw5); _regs.ch2_on_rx_sw6 = magnesium_cpld_regs_t::ch2_on_rx_sw6_t(rx_sw6); - _regs.ch2_on_rx_loband_mixer_path_sel = magnesium_cpld_regs_t::ch2_on_rx_loband_mixer_path_sel_t(select_lowband_mixer_path); + _regs.ch2_on_rx_loband_mixer_path_sel = + magnesium_cpld_regs_t::ch2_on_rx_loband_mixer_path_sel_t( + select_lowband_mixer_path); _regs.ch2_on_rx_mixer_en = enb_lowband_mixer; } } @@ -193,40 +194,39 @@ void magnesium_cpld_ctrl::set_rx_switches( } } -void magnesium_cpld_ctrl::set_tx_atr_bits( - const chan_sel_t chan, +void magnesium_cpld_ctrl::set_tx_atr_bits(const chan_sel_t chan, const atr_state_t atr_state, const bool tx_led, const bool tx_pa_enb, const bool tx_amp_enb, const bool tx_myk_en, - const bool defer_commit -) { + const bool defer_commit) +{ std::lock_guard<std::mutex> l(_set_mutex); if (chan == CHAN1 or chan == BOTH) { if (atr_state == IDLE or atr_state == ANY) { - _regs.ch1_idle_tx_led = tx_led; - _regs.ch1_idle_tx_pa_en = tx_pa_enb; + _regs.ch1_idle_tx_led = tx_led; + _regs.ch1_idle_tx_pa_en = tx_pa_enb; _regs.ch1_idle_tx_amp_en = tx_amp_enb; _regs.ch1_idle_tx_myk_en = tx_myk_en; } if (atr_state == ON or atr_state == ANY) { - _regs.ch1_on_tx_led = tx_led; - _regs.ch1_on_tx_pa_en = tx_pa_enb; + _regs.ch1_on_tx_led = tx_led; + _regs.ch1_on_tx_pa_en = tx_pa_enb; _regs.ch1_on_tx_amp_en = tx_amp_enb; _regs.ch1_on_tx_myk_en = tx_myk_en; } } if (chan == CHAN2 or chan == BOTH) { if (atr_state == IDLE or atr_state == ANY) { - _regs.ch2_idle_tx_led = tx_led; - _regs.ch2_idle_tx_pa_en = tx_pa_enb; + _regs.ch2_idle_tx_led = tx_led; + _regs.ch2_idle_tx_pa_en = tx_pa_enb; _regs.ch2_idle_tx_amp_en = tx_amp_enb; _regs.ch2_idle_tx_myk_en = tx_myk_en; } if (atr_state == ON or atr_state == ANY) { - _regs.ch2_on_tx_led = tx_led; - _regs.ch2_on_tx_pa_en = tx_pa_enb; + _regs.ch2_on_tx_led = tx_led; + _regs.ch2_on_tx_pa_en = tx_pa_enb; _regs.ch2_on_tx_amp_en = tx_amp_enb; _regs.ch2_on_tx_myk_en = tx_myk_en; } @@ -236,31 +236,26 @@ void magnesium_cpld_ctrl::set_tx_atr_bits( } } -void magnesium_cpld_ctrl::set_trx_sw_atr_bits( - const chan_sel_t chan, +void magnesium_cpld_ctrl::set_trx_sw_atr_bits(const chan_sel_t chan, const atr_state_t atr_state, const sw_trx_t trx_sw, - const bool defer_commit -) { + const bool defer_commit) +{ std::lock_guard<std::mutex> l(_set_mutex); if (chan == CHAN1 or chan == BOTH) { if (atr_state == IDLE or atr_state == ANY) { - _regs.ch1_idle_sw_trx = - magnesium_cpld_regs_t::ch1_idle_sw_trx_t(trx_sw); + _regs.ch1_idle_sw_trx = magnesium_cpld_regs_t::ch1_idle_sw_trx_t(trx_sw); } if (atr_state == ON or atr_state == ANY) { - _regs.ch1_on_sw_trx = - magnesium_cpld_regs_t::ch1_on_sw_trx_t(trx_sw); + _regs.ch1_on_sw_trx = magnesium_cpld_regs_t::ch1_on_sw_trx_t(trx_sw); } } if (chan == CHAN2 or chan == BOTH) { if (atr_state == IDLE or atr_state == ANY) { - _regs.ch2_idle_sw_trx = - magnesium_cpld_regs_t::ch2_idle_sw_trx_t(trx_sw); + _regs.ch2_idle_sw_trx = magnesium_cpld_regs_t::ch2_idle_sw_trx_t(trx_sw); } if (atr_state == ON or atr_state == ANY) { - _regs.ch2_on_sw_trx = - magnesium_cpld_regs_t::ch2_on_sw_trx_t(trx_sw); + _regs.ch2_on_sw_trx = magnesium_cpld_regs_t::ch2_on_sw_trx_t(trx_sw); } } if (not defer_commit) { @@ -268,40 +263,35 @@ void magnesium_cpld_ctrl::set_trx_sw_atr_bits( } } -void magnesium_cpld_ctrl::set_rx_input_atr_bits( - const chan_sel_t chan, +void magnesium_cpld_ctrl::set_rx_input_atr_bits(const chan_sel_t chan, const atr_state_t atr_state, const rx_sw1_t rx_sw1, const bool rx_led, const bool rx2_led, - const bool defer_commit -) { + const bool defer_commit) +{ std::lock_guard<std::mutex> l(_set_mutex); if (chan == CHAN1 or chan == BOTH) { if (atr_state == IDLE or atr_state == ANY) { - _regs.ch1_idle_rx_sw1 = - magnesium_cpld_regs_t::ch1_idle_rx_sw1_t(rx_sw1); - _regs.ch1_idle_rx_led = rx_led; + _regs.ch1_idle_rx_sw1 = magnesium_cpld_regs_t::ch1_idle_rx_sw1_t(rx_sw1); + _regs.ch1_idle_rx_led = rx_led; _regs.ch1_idle_rx2_led = rx2_led; } if (atr_state == ON or atr_state == ANY) { - _regs.ch1_on_rx_sw1 = - magnesium_cpld_regs_t::ch1_on_rx_sw1_t(rx_sw1); - _regs.ch1_on_rx_led = rx_led; + _regs.ch1_on_rx_sw1 = magnesium_cpld_regs_t::ch1_on_rx_sw1_t(rx_sw1); + _regs.ch1_on_rx_led = rx_led; _regs.ch1_on_rx2_led = rx2_led; } } if (chan == CHAN2 or chan == BOTH) { if (atr_state == IDLE or atr_state == ANY) { - _regs.ch2_idle_rx_sw1 = - magnesium_cpld_regs_t::ch2_idle_rx_sw1_t(rx_sw1); - _regs.ch2_idle_rx_led = rx_led; + _regs.ch2_idle_rx_sw1 = magnesium_cpld_regs_t::ch2_idle_rx_sw1_t(rx_sw1); + _regs.ch2_idle_rx_led = rx_led; _regs.ch2_idle_rx2_led = rx2_led; } if (atr_state == ON or atr_state == ANY) { - _regs.ch2_on_rx_sw1 = - magnesium_cpld_regs_t::ch2_on_rx_sw1_t(rx_sw1); - _regs.ch2_on_rx_led = rx_led; + _regs.ch2_on_rx_sw1 = magnesium_cpld_regs_t::ch2_on_rx_sw1_t(rx_sw1); + _regs.ch2_on_rx_led = rx_led; _regs.ch2_on_rx2_led = rx2_led; } } @@ -311,13 +301,12 @@ void magnesium_cpld_ctrl::set_rx_input_atr_bits( } } -void magnesium_cpld_ctrl::set_rx_atr_bits( - const chan_sel_t chan, +void magnesium_cpld_ctrl::set_rx_atr_bits(const chan_sel_t chan, const atr_state_t atr_state, const bool rx_amp_enb, const bool rx_myk_en, - const bool defer_commit -) { + const bool defer_commit) +{ std::lock_guard<std::mutex> l(_set_mutex); if (chan == CHAN1 or chan == BOTH) { if (atr_state == IDLE or atr_state == ANY) { @@ -345,13 +334,12 @@ void magnesium_cpld_ctrl::set_rx_atr_bits( } } -void magnesium_cpld_ctrl::set_rx_lna_atr_bits( - const chan_sel_t chan, +void magnesium_cpld_ctrl::set_rx_lna_atr_bits(const chan_sel_t chan, const atr_state_t atr_state, const bool rx_lna1_enb, const bool rx_lna2_enb, - const bool defer_commit -) { + const bool defer_commit) +{ std::lock_guard<std::mutex> l(_set_mutex); if (chan == CHAN1 or chan == BOTH) { if (atr_state == IDLE or atr_state == ANY) { @@ -394,9 +382,7 @@ void magnesium_cpld_ctrl::_loopback_test() if (actual != random_number) { UHD_LOGGER_ERROR("MG_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("MG_CPLD", "CPLD scratch loopback test passed!"); @@ -406,19 +392,16 @@ void magnesium_cpld_ctrl::_loopback_test() void magnesium_cpld_ctrl::commit(const bool save_all) { UHD_LOGGER_TRACE("MG_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_fn(addr, _regs.get_reg(addr)); } _regs.save_state(); UHD_LOG_TRACE("MG_CPLD", - "Storing cache complete: " \ - "Updated " << changed_addrs.size() << " registers."); + "Storing cache complete: " + "Updated " + << changed_addrs.size() << " registers."); } - |