diff options
author | Martin Braun <martin.braun@ettus.com> | 2020-03-02 15:25:13 -0800 |
---|---|---|
committer | atrnati <54334261+atrnati@users.noreply.github.com> | 2020-03-03 08:51:32 -0600 |
commit | 876d4150aa3da531ddd687b48afada6e43f79146 (patch) | |
tree | fd72a71419f4cd800d4e500cfcaded4dfc8dc367 /host/lib/usrp/dboard/db_wbx_common.cpp | |
parent | 1393553d623bdf4ba40d5435c9719b6ce990d9ac (diff) | |
download | uhd-876d4150aa3da531ddd687b48afada6e43f79146.tar.gz uhd-876d4150aa3da531ddd687b48afada6e43f79146.tar.bz2 uhd-876d4150aa3da531ddd687b48afada6e43f79146.zip |
uhd: Apply clang-format against all .cpp and .hpp files in host/
Note: template_lvbitx.{cpp,hpp} need to be excluded from the list of
files that clang-format gets applied against.
Diffstat (limited to 'host/lib/usrp/dboard/db_wbx_common.cpp')
-rw-r--r-- | host/lib/usrp/dboard/db_wbx_common.cpp | 107 |
1 files changed, 61 insertions, 46 deletions
diff --git a/host/lib/usrp/dboard/db_wbx_common.cpp b/host/lib/usrp/dboard/db_wbx_common.cpp index 4651de76a..df89e3779 100644 --- a/host/lib/usrp/dboard/db_wbx_common.cpp +++ b/host/lib/usrp/dboard/db_wbx_common.cpp @@ -22,23 +22,24 @@ using namespace boost::assign; /*********************************************************************** * Gain-related functions **********************************************************************/ -static int rx_pga0_gain_to_iobits(double &gain){ - //clip the input +static int rx_pga0_gain_to_iobits(double& gain) +{ + // clip the input gain = wbx_rx_gain_ranges["PGA0"].clip(gain); - //convert to attenuation + // convert to attenuation double attn = wbx_rx_gain_ranges["PGA0"].stop() - gain; - //calculate the attenuation - int attn_code = boost::math::iround(attn*2); - int iobits = ((~attn_code) << RX_ATTN_SHIFT) & RX_ATTN_MASK; + // calculate the attenuation + int attn_code = boost::math::iround(attn * 2); + int iobits = ((~attn_code) << RX_ATTN_SHIFT) & RX_ATTN_MASK; - UHD_LOGGER_TRACE("WBX") << boost::format( - "WBX RX Attenuation: %f dB, Code: %d, IO Bits %x, Mask: %x" - ) % attn % attn_code % (iobits & RX_ATTN_MASK) % RX_ATTN_MASK ; + UHD_LOGGER_TRACE("WBX") + << boost::format("WBX RX Attenuation: %f dB, Code: %d, IO Bits %x, Mask: %x") + % attn % attn_code % (iobits & RX_ATTN_MASK) % RX_ATTN_MASK; - //the actual gain setting - gain = wbx_rx_gain_ranges["PGA0"].stop() - double(attn_code)/2; + // the actual gain setting + gain = wbx_rx_gain_ranges["PGA0"].stop() - double(attn_code) / 2; return iobits; } @@ -47,9 +48,9 @@ static int rx_pga0_gain_to_iobits(double &gain){ /*********************************************************************** * WBX Common Implementation **********************************************************************/ -wbx_base::wbx_base(ctor_args_t args) : xcvr_dboard_base(args){ - - //enable the clocks that we need +wbx_base::wbx_base(ctor_args_t args) : xcvr_dboard_base(args) +{ + // enable the clocks that we need this->get_iface()->set_clock_enabled(dboard_iface::UNIT_TX, true); this->get_iface()->set_clock_enabled(dboard_iface::UNIT_RX, true); @@ -59,38 +60,47 @@ wbx_base::wbx_base(ctor_args_t args) : xcvr_dboard_base(args){ uint16_t rx_id = this->get_rx_id().to_uint16(); this->get_rx_subtree()->create<device_addr_t>("tune_args").set(device_addr_t()); - this->get_rx_subtree()->create<sensor_value_t>("sensors/lo_locked") + this->get_rx_subtree() + ->create<sensor_value_t>("sensors/lo_locked") .set_publisher(std::bind(&wbx_base::get_locked, this, dboard_iface::UNIT_RX)); - for(const std::string &name: wbx_rx_gain_ranges.keys()){ - this->get_rx_subtree()->create<double>("gains/"+name+"/value") - .set_coercer(std::bind(&wbx_base::set_rx_gain, this, std::placeholders::_1, name)) + for (const std::string& name : wbx_rx_gain_ranges.keys()) { + this->get_rx_subtree() + ->create<double>("gains/" + name + "/value") + .set_coercer( + std::bind(&wbx_base::set_rx_gain, this, std::placeholders::_1, name)) .set(wbx_rx_gain_ranges[name].start()); - this->get_rx_subtree()->create<meta_range_t>("gains/"+name+"/range") + this->get_rx_subtree() + ->create<meta_range_t>("gains/" + name + "/range") .set(wbx_rx_gain_ranges[name]); } this->get_rx_subtree()->create<std::string>("connection").set("IQ"); - this->get_rx_subtree()->create<bool>("enabled") - .add_coerced_subscriber(std::bind(&wbx_base::set_rx_enabled, this, std::placeholders::_1)) - .set(true); //start enabled + this->get_rx_subtree() + ->create<bool>("enabled") + .add_coerced_subscriber( + std::bind(&wbx_base::set_rx_enabled, this, std::placeholders::_1)) + .set(true); // start enabled this->get_rx_subtree()->create<bool>("use_lo_offset").set(false); - //Value of bw low-pass dependent on board, we want complex double-sided + // Value of bw low-pass dependent on board, we want complex double-sided double bw = (rx_id != 0x0081) ? 20.0e6 : 60.0e6; - this->get_rx_subtree()->create<double>("bandwidth/value").set(2*bw); - this->get_rx_subtree()->create<meta_range_t>("bandwidth/range") - .set(freq_range_t(2*bw, 2*bw)); - this->get_tx_subtree()->create<double>("bandwidth/value").set(2*bw); - this->get_tx_subtree()->create<meta_range_t>("bandwidth/range") - .set(freq_range_t(2*bw, 2*bw)); + this->get_rx_subtree()->create<double>("bandwidth/value").set(2 * bw); + this->get_rx_subtree() + ->create<meta_range_t>("bandwidth/range") + .set(freq_range_t(2 * bw, 2 * bw)); + this->get_tx_subtree()->create<double>("bandwidth/value").set(2 * bw); + this->get_tx_subtree() + ->create<meta_range_t>("bandwidth/range") + .set(freq_range_t(2 * bw, 2 * bw)); this->get_tx_subtree()->create<device_addr_t>("tune_args").set(device_addr_t()); - this->get_tx_subtree()->create<sensor_value_t>("sensors/lo_locked") + this->get_tx_subtree() + ->create<sensor_value_t>("sensors/lo_locked") .set_publisher(std::bind(&wbx_base::get_locked, this, dboard_iface::UNIT_TX)); this->get_tx_subtree()->create<std::string>("connection").set("IQ"); this->get_tx_subtree()->create<bool>("use_lo_offset").set(false); // instantiate subclass foo - switch(rx_id) { + switch (rx_id) { case 0x0053: db_actual = wbx_versionx_sptr(new wbx_version2(this)); return; @@ -107,49 +117,54 @@ wbx_base::wbx_base(ctor_args_t args) : xcvr_dboard_base(args){ /* We didn't recognize the version of the board... */ UHD_THROW_INVALID_CODE_PATH(); } - } -wbx_base::~wbx_base(void){ +wbx_base::~wbx_base(void) +{ /* NOP */ } /*********************************************************************** * Enables **********************************************************************/ -void wbx_base::set_rx_enabled(bool enb){ +void wbx_base::set_rx_enabled(bool enb) +{ this->get_iface()->set_gpio_out(dboard_iface::UNIT_RX, - (enb)? RX_POWER_UP : RX_POWER_DOWN, RX_POWER_UP | RX_POWER_DOWN - ); + (enb) ? RX_POWER_UP : RX_POWER_DOWN, + RX_POWER_UP | RX_POWER_DOWN); } /*********************************************************************** * Gain Handling **********************************************************************/ -double wbx_base::set_rx_gain(double gain, const std::string &name){ +double wbx_base::set_rx_gain(double gain, const std::string& name) +{ assert_has(wbx_rx_gain_ranges.keys(), name, "wbx rx gain name"); - if(name == "PGA0"){ + if (name == "PGA0") { uint16_t io_bits = rx_pga0_gain_to_iobits(gain); - _rx_gains[name] = gain; + _rx_gains[name] = gain; - //write the new gain to rx gpio outputs + // write the new gain to rx gpio outputs this->get_iface()->set_gpio_out(dboard_iface::UNIT_RX, io_bits, RX_ATTN_MASK); - } - else UHD_THROW_INVALID_CODE_PATH(); - return _rx_gains[name]; //returned shadowed + } else + UHD_THROW_INVALID_CODE_PATH(); + return _rx_gains[name]; // returned shadowed } /*********************************************************************** * Tuning **********************************************************************/ -sensor_value_t wbx_base::get_locked(dboard_iface::unit_t unit){ +sensor_value_t wbx_base::get_locked(dboard_iface::unit_t unit) +{ const bool locked = (this->get_iface()->read_gpio(unit) & LOCKDET_MASK) != 0; return sensor_value_t("LO", locked, "locked", "unlocked"); } -void wbx_base::wbx_versionx::write_lo_regs(dboard_iface::unit_t unit, const std::vector<uint32_t> ®s) { - for(uint32_t reg: regs) { +void wbx_base::wbx_versionx::write_lo_regs( + dboard_iface::unit_t unit, const std::vector<uint32_t>& regs) +{ + for (uint32_t reg : regs) { self_base->get_iface()->write_spi(unit, spi_config_t::EDGE_RISE, reg, 32); } } |