diff options
author | Nick Foster <nick@nerdnetworks.org> | 2010-11-11 14:06:56 -0800 |
---|---|---|
committer | Nick Foster <nick@nerdnetworks.org> | 2010-11-11 14:06:56 -0800 |
commit | 5a3b5a06082e90a68b993a765b91a7c288ab19c0 (patch) | |
tree | 5219c55ea239203514fc0a699f7f7ceb21c48781 /host/lib/usrp | |
parent | 6eef331543022efa5723e677cd3140e652ea67d7 (diff) | |
parent | 5da1e3e2d683eecce1f0e888d90caef40661e98e (diff) | |
download | uhd-5a3b5a06082e90a68b993a765b91a7c288ab19c0.tar.gz uhd-5a3b5a06082e90a68b993a765b91a7c288ab19c0.tar.bz2 uhd-5a3b5a06082e90a68b993a765b91a7c288ab19c0.zip |
Merge branch 'master' of ettus.sourcerepo.com:ettus/uhdpriv into usrp2p
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/dboard/db_basic_and_lf.cpp | 5 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_dbsrx.cpp | 19 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_dbsrx2.cpp | 12 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_rfx.cpp | 40 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_tvrx.cpp | 14 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_wbx.cpp | 23 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_xcvr2450.cpp | 28 | ||||
-rw-r--r-- | host/lib/usrp/mboard_eeprom.cpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/codec_ctrl.cpp | 8 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_iface.cpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/wrapper_utils.hpp | 2 |
11 files changed, 82 insertions, 79 deletions
diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp index f03dd43d1..73f894374 100644 --- a/host/lib/usrp/dboard/db_basic_and_lf.cpp +++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp @@ -106,6 +106,11 @@ UHD_STATIC_BLOCK(reg_basic_and_lf_dboards){ **********************************************************************/ basic_rx::basic_rx(ctor_args_t args, double max_freq) : rx_dboard_base(args){ _max_freq = max_freq; + + //set GPIOs to output 0x0000 to decrease noise pickup + this->get_iface()->set_pin_ctrl(dboard_iface::UNIT_RX, 0x0000); + this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_RX, 0xFFFF); + this->get_iface()->write_gpio(dboard_iface::UNIT_RX, 0x0000); } basic_rx::~basic_rx(void){ diff --git a/host/lib/usrp/dboard/db_dbsrx.cpp b/host/lib/usrp/dboard/db_dbsrx.cpp index 85251bdf9..7edc1822c 100644 --- a/host/lib/usrp/dboard/db_dbsrx.cpp +++ b/host/lib/usrp/dboard/db_dbsrx.cpp @@ -212,10 +212,10 @@ dbsrx::dbsrx(ctor_args_t args) : rx_dboard_base(args){ //set defaults for LO, gains, and filter bandwidth _bandwidth = 33e6; - set_lo_freq(dbsrx_freq_range.min); + set_lo_freq(dbsrx_freq_range.start()); BOOST_FOREACH(const std::string &name, dbsrx_gain_ranges.keys()){ - set_gain(dbsrx_gain_ranges[name].min, name); + set_gain(dbsrx_gain_ranges[name].start(), name); } set_bandwidth(33e6); // default bandwidth from datasheet @@ -229,7 +229,7 @@ dbsrx::~dbsrx(void){ * Tuning **********************************************************************/ void dbsrx::set_lo_freq(double target_freq){ - target_freq = std::clip(target_freq, dbsrx_freq_range.min, dbsrx_freq_range.max); + target_freq = dbsrx_freq_range.clip(target_freq); double actual_freq=0.0, pfd_freq=0.0, ref_clock=0.0; int R=0, N=0, r=0, m=0; @@ -261,7 +261,7 @@ void dbsrx::set_lo_freq(double target_freq){ pfd_freq = ref_clock / R; //constrain the PFD frequency to specified range - if ((pfd_freq < dbsrx_pfd_freq_range.min) or (pfd_freq > dbsrx_pfd_freq_range.max)) continue; + if ((pfd_freq < dbsrx_pfd_freq_range.start()) or (pfd_freq > dbsrx_pfd_freq_range.stop())) continue; //compute N N = int(std::floor(target_freq/pfd_freq)); @@ -278,7 +278,7 @@ void dbsrx::set_lo_freq(double target_freq){ //Assert because we failed to find a suitable combination of ref_clock, R and N UHD_ASSERT_THROW(ref_clock <= 27.0e6 and ref_clock >= 0.0); UHD_ASSERT_THROW(ref_clock/m >= 1e6 and ref_clock/m <= 2.5e6); - UHD_ASSERT_THROW((pfd_freq >= dbsrx_pfd_freq_range.min) and (pfd_freq <= dbsrx_pfd_freq_range.max)); + UHD_ASSERT_THROW((pfd_freq >= dbsrx_pfd_freq_range.start()) and (pfd_freq <= dbsrx_pfd_freq_range.stop())); UHD_ASSERT_THROW((N >= 256) and (N <= 32768)); if(dbsrx_debug) std::cerr << boost::format( @@ -374,6 +374,9 @@ void dbsrx::set_lo_freq(double target_freq){ //update vco selection and check vtune send_reg(0x2, 0x2); read_reg(0x0, 0x0); + + //allow for setup time before checking condition again + boost::this_thread::sleep(boost::posix_time::milliseconds(1)); } if(dbsrx_debug) std::cerr << boost::format( @@ -417,7 +420,7 @@ void dbsrx::set_lo_freq(double target_freq){ */ static int gain_to_gc2_vga_reg(float &gain){ int reg = 0; - gain = std::clip<float>(float(boost::math::iround(gain)), dbsrx_gain_ranges["GC2"].min, dbsrx_gain_ranges["GC2"].max); + gain = dbsrx_gain_ranges["GC2"].clip(gain); // Half dB steps from 0-5dB, 1dB steps from 5-24dB if (gain < 5) { @@ -443,11 +446,11 @@ static int gain_to_gc2_vga_reg(float &gain){ */ static float gain_to_gc1_rfvga_dac(float &gain){ //clip the input - gain = std::clip<float>(gain, dbsrx_gain_ranges["GC1"].min, dbsrx_gain_ranges["GC1"].max); + gain = dbsrx_gain_ranges["GC1"].clip(gain); //voltage level constants static const float max_volts = float(1.2), min_volts = float(2.7); - static const float slope = (max_volts-min_volts)/dbsrx_gain_ranges["GC1"].max; + static const float slope = (max_volts-min_volts)/dbsrx_gain_ranges["GC1"].stop(); //calculate the voltage for the aux dac float dac_volts = gain*slope + min_volts; diff --git a/host/lib/usrp/dboard/db_dbsrx2.cpp b/host/lib/usrp/dboard/db_dbsrx2.cpp index 5a65e6123..bf5528688 100644 --- a/host/lib/usrp/dboard/db_dbsrx2.cpp +++ b/host/lib/usrp/dboard/db_dbsrx2.cpp @@ -195,15 +195,15 @@ dbsrx2::dbsrx2(ctor_args_t args) : rx_dboard_base(args){ //for (boost::uint8_t addr=0; addr<=12; addr++) this->send_reg(addr, addr); //set defaults for LO, gains - set_lo_freq(dbsrx2_freq_range.min); + set_lo_freq(dbsrx2_freq_range.start()); BOOST_FOREACH(const std::string &name, dbsrx2_gain_ranges.keys()){ - set_gain(dbsrx2_gain_ranges[name].min, name); + set_gain(dbsrx2_gain_ranges[name].start(), name); } set_bandwidth(40e6); // default bandwidth from datasheet get_locked(); - _max2112_write_regs.bbg = boost::math::iround(std::clip<float>(0, dbsrx2_gain_ranges["BBG"].min, dbsrx2_gain_ranges["BBG"].max)); + _max2112_write_regs.bbg = dbsrx2_gain_ranges["BBG"].start(); send_reg(0x9, 0x9); } @@ -270,7 +270,7 @@ void dbsrx2::set_lo_freq(double target_freq){ * \return 4 bit the register value */ static int gain_to_bbg_vga_reg(float &gain){ - int reg = boost::math::iround(std::clip<float>(gain, dbsrx2_gain_ranges["BBG"].min, dbsrx2_gain_ranges["BBG"].max)); + int reg = boost::math::iround(dbsrx2_gain_ranges["BBG"].clip(gain)); gain = float(reg); @@ -290,11 +290,11 @@ static int gain_to_bbg_vga_reg(float &gain){ */ static float gain_to_gc1_rfvga_dac(float &gain){ //clip the input - gain = std::clip<float>(gain, dbsrx2_gain_ranges["GC1"].min, dbsrx2_gain_ranges["GC1"].max); + gain = dbsrx2_gain_ranges["GC1"].clip(gain); //voltage level constants static const float max_volts = float(0.5), min_volts = float(2.7); - static const float slope = (max_volts-min_volts)/dbsrx2_gain_ranges["GC1"].max; + static const float slope = (max_volts-min_volts)/dbsrx2_gain_ranges["GC1"].stop(); //calculate the voltage for the aux dac float dac_volts = gain*slope + min_volts; diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index 152198c3a..4e73fb3a3 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -93,9 +93,9 @@ public: void tx_set(const wax::obj &key, const wax::obj &val); private: - freq_range_t _freq_range; - uhd::dict<std::string, gain_range_t> _rx_gain_ranges; - uhd::dict<dboard_iface::unit_t, bool> _div2; + const freq_range_t _freq_range; + const uhd::dict<std::string, gain_range_t> _rx_gain_ranges; + const uhd::dict<dboard_iface::unit_t, bool> _div2; double _rx_lo_freq, _tx_lo_freq; std::string _rx_ant; uhd::dict<std::string, float> _rx_gains; @@ -168,19 +168,17 @@ rfx_xcvr::rfx_xcvr( ctor_args_t args, const freq_range_t &freq_range, bool rx_div2, bool tx_div2 -) : xcvr_dboard_base(args){ - _freq_range = freq_range; - _div2[dboard_iface::UNIT_RX] = rx_div2; - _div2[dboard_iface::UNIT_TX] = tx_div2; - - if(this->get_rx_id() == 0x0024) { //RFX400 - _rx_gain_ranges = rfx400_rx_gain_ranges; - } - else { - _rx_gain_ranges = rfx_rx_gain_ranges; - } - - +): + xcvr_dboard_base(args), + _freq_range(freq_range), + _rx_gain_ranges((this->get_rx_id() == 0x0024)? + rfx400_rx_gain_ranges : rfx_rx_gain_ranges + ), + _div2(map_list_of + (dboard_iface::UNIT_RX, rx_div2) + (dboard_iface::UNIT_TX, tx_div2) + ) +{ //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); @@ -204,12 +202,12 @@ rfx_xcvr::rfx_xcvr( this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_FULL_DUPLEX, POWER_UP | ANT_RX2| MIXER_ENB); //set some default values - set_rx_lo_freq((_freq_range.min + _freq_range.max)/2.0); - set_tx_lo_freq((_freq_range.min + _freq_range.max)/2.0); + set_rx_lo_freq((_freq_range.start() + _freq_range.stop())/2.0); + set_tx_lo_freq((_freq_range.start() + _freq_range.stop())/2.0); set_rx_ant("RX2"); BOOST_FOREACH(const std::string &name, _rx_gain_ranges.keys()){ - set_rx_gain(_rx_gain_ranges[name].min, name); + set_rx_gain(_rx_gain_ranges[name].start(), name); } } @@ -265,7 +263,7 @@ void rfx_xcvr::set_rx_gain(float gain, const std::string &name){ assert_has(_rx_gain_ranges.keys(), name, "rfx rx gain name"); if(name == "PGA0"){ float dac_volts = rx_pga0_gain_to_dac_volts(gain, - (_rx_gain_ranges["PGA0"].max - _rx_gain_ranges["PGA0"].min)); + (_rx_gain_ranges["PGA0"].stop() - _rx_gain_ranges["PGA0"].start())); _rx_gains[name] = gain; //write the new voltage to the aux dac @@ -294,7 +292,7 @@ double rfx_xcvr::set_lo_freq( ) % (target_freq/1e6) << std::endl; //clip the input - target_freq = std::clip(target_freq, _freq_range.min, _freq_range.max); + target_freq = _freq_range.clip(target_freq); if (_div2[unit]) target_freq *= 2; //map prescalers to the register enums diff --git a/host/lib/usrp/dboard/db_tvrx.cpp b/host/lib/usrp/dboard/db_tvrx.cpp index 2873e3d54..17fdad74a 100644 --- a/host/lib/usrp/dboard/db_tvrx.cpp +++ b/host/lib/usrp/dboard/db_tvrx.cpp @@ -200,12 +200,12 @@ tvrx::tvrx(ctor_args_t args) : rx_dboard_base(args){ //send initial register settings if necessary //set default freq - _lo_freq = tvrx_freq_range.min + tvrx_if_freq; //init _lo_freq to a sane default - set_freq(tvrx_freq_range.min); + _lo_freq = tvrx_freq_range.start() + tvrx_if_freq; //init _lo_freq to a sane default + set_freq(tvrx_freq_range.start()); //set default gains BOOST_FOREACH(const std::string &name, get_tvrx_gain_ranges().keys()){ - set_gain(get_tvrx_gain_ranges()[name].min, name); + set_gain(get_tvrx_gain_ranges()[name].start(), name); } } @@ -219,7 +219,7 @@ tvrx::~tvrx(void){ static std::string get_band(double freq) { BOOST_FOREACH(const std::string &band, tvrx_freq_ranges.keys()) { - if(freq >= tvrx_freq_ranges[band].min && freq <= tvrx_freq_ranges[band].max){ + if(freq >= tvrx_freq_ranges[band].start() && freq <= tvrx_freq_ranges[band].stop()){ if(tvrx_debug) std::cout << "Band: " << band << std::endl; return band; } @@ -277,7 +277,7 @@ static double gain_interp(double gain, boost::array<double, 17> db_vector, boost static float rf_gain_to_voltage(float gain, double lo_freq){ //clip the input - gain = std::clip<float>(gain, get_tvrx_gain_ranges()["RF"].min, get_tvrx_gain_ranges()["RF"].max); + gain = get_tvrx_gain_ranges()["RF"].clip(gain); //first we need to find out what band we're in, because gains are different across different bands std::string band = get_band(lo_freq + tvrx_if_freq); @@ -305,7 +305,7 @@ static float rf_gain_to_voltage(float gain, double lo_freq){ static float if_gain_to_voltage(float gain){ //clip the input - gain = std::clip<float>(gain, get_tvrx_gain_ranges()["IF"].min, get_tvrx_gain_ranges()["IF"].max); + gain = get_tvrx_gain_ranges()["IF"].clip(gain); double gain_volts = gain_interp(gain, tvrx_if_gains_db, tvrx_gains_volts); double dac_volts = gain_volts / opamp_gain; @@ -337,7 +337,7 @@ void tvrx::set_gain(float gain, const std::string &name){ */ void tvrx::set_freq(double freq) { - freq = std::clip<double>(freq, tvrx_freq_range.min, tvrx_freq_range.max); + freq = tvrx_freq_range.clip(freq); std::string prev_band = get_band(_lo_freq - tvrx_if_freq); std::string new_band = get_band(freq); diff --git a/host/lib/usrp/dboard/db_wbx.cpp b/host/lib/usrp/dboard/db_wbx.cpp index 572f5de97..dd5bd600b 100644 --- a/host/lib/usrp/dboard/db_wbx.cpp +++ b/host/lib/usrp/dboard/db_wbx.cpp @@ -177,15 +177,15 @@ wbx_xcvr::wbx_xcvr(ctor_args_t args) : xcvr_dboard_base(args){ ) % RXIO_MASK % TXIO_MASK << std::endl; //set some default values - set_rx_lo_freq((wbx_freq_range.min + wbx_freq_range.max)/2.0); - set_tx_lo_freq((wbx_freq_range.min + wbx_freq_range.max)/2.0); + set_rx_lo_freq((wbx_freq_range.start() + wbx_freq_range.stop())/2.0); + set_tx_lo_freq((wbx_freq_range.start() + wbx_freq_range.stop())/2.0); set_rx_ant("RX2"); BOOST_FOREACH(const std::string &name, wbx_tx_gain_ranges.keys()){ - set_tx_gain(wbx_tx_gain_ranges[name].min, name); + set_tx_gain(wbx_tx_gain_ranges[name].start(), name); } BOOST_FOREACH(const std::string &name, wbx_rx_gain_ranges.keys()){ - set_rx_gain(wbx_rx_gain_ranges[name].min, name); + set_rx_gain(wbx_rx_gain_ranges[name].start(), name); } } @@ -198,33 +198,32 @@ wbx_xcvr::~wbx_xcvr(void){ **********************************************************************/ static int rx_pga0_gain_to_iobits(float &gain){ //clip the input - gain = std::clip<float>(gain, wbx_rx_gain_ranges["PGA0"].min, wbx_rx_gain_ranges["PGA0"].max); + gain = wbx_rx_gain_ranges["PGA0"].clip(gain); //convert to attenuation and update iobits for atr - float attn = wbx_rx_gain_ranges["PGA0"].max - gain; + float attn = wbx_rx_gain_ranges["PGA0"].stop() - gain; //calculate the attenuation - int attn_code = int(floor(attn*2)); + int attn_code = boost::math::iround(attn*2); int iobits = ((~attn_code) << RX_ATTN_SHIFT) & RX_ATTN_MASK; - if (wbx_debug) std::cerr << boost::format( "WBX Attenuation: %f dB, Code: %d, IO Bits %x, Mask: %x" ) % attn % attn_code % (iobits & RX_ATTN_MASK) % RX_ATTN_MASK << std::endl; //the actual gain setting - gain = wbx_rx_gain_ranges["PGA0"].max - float(attn_code)/2; + gain = wbx_rx_gain_ranges["PGA0"].stop() - float(attn_code)/2; return iobits; } static float tx_pga0_gain_to_dac_volts(float &gain){ //clip the input - gain = std::clip<float>(gain, wbx_tx_gain_ranges["PGA0"].min, wbx_tx_gain_ranges["PGA0"].max); + gain = wbx_tx_gain_ranges["PGA0"].clip(gain); //voltage level constants static const float max_volts = float(0.5), min_volts = float(1.4); - static const float slope = (max_volts-min_volts)/wbx_tx_gain_ranges["PGA0"].max; + static const float slope = (max_volts-min_volts)/wbx_tx_gain_ranges["PGA0"].stop(); //calculate the voltage for the aux dac float dac_volts = gain*slope + min_volts; @@ -328,7 +327,7 @@ double wbx_xcvr::set_lo_freq( ) % (target_freq/1e6) << std::endl; //clip the input - target_freq = std::clip(target_freq, wbx_freq_range.min, wbx_freq_range.max); + target_freq = wbx_freq_range.clip(target_freq); //map prescaler setting to mininmum integer divider (N) values (pg.18 prescaler) static const uhd::dict<int, int> prescaler_to_min_int_div = map_list_of diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index be0e42b92..a3a1e6242 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -72,8 +72,10 @@ using namespace boost::assign; **********************************************************************/ static const bool xcvr2450_debug = false; -static const freq_range_t xcvr_freq_range(2.4e9, 6.0e9); -static const freq_range_t xcvr_freq_band_seperation(2.5e9, 4.9e9); +static const freq_range_t xcvr_freq_range = list_of + (range_t<double>(2.4e9, 2.5e9)) + (range_t<double>(4.9e9, 6.0e9)) +; static const prop_names_t xcvr_antennas = list_of("J1")("J2"); @@ -82,7 +84,11 @@ static const uhd::dict<std::string, gain_range_t> xcvr_tx_gain_ranges = map_list ("BB", gain_range_t(0, 5, 1.5)) ; static const uhd::dict<std::string, gain_range_t> xcvr_rx_gain_ranges = map_list_of - ("LNA", gain_range_t(0, 30.5, 15)) + ("LNA", gain_range_t(list_of + (range_t<float>(0)) + (range_t<float>(15)) + (range_t<float>(30.5)) + )) ("VGA", gain_range_t(0, 62, 2.0)) ; @@ -212,10 +218,10 @@ xcvr2450::xcvr2450(ctor_args_t args) : xcvr_dboard_base(args){ set_rx_ant(xcvr_antennas.at(0)); set_tx_ant(xcvr_antennas.at(1)); BOOST_FOREACH(const std::string &name, xcvr_tx_gain_ranges.keys()){ - set_tx_gain(xcvr_tx_gain_ranges[name].min, name); + set_tx_gain(xcvr_tx_gain_ranges[name].start(), name); } BOOST_FOREACH(const std::string &name, xcvr_rx_gain_ranges.keys()){ - set_rx_gain(xcvr_rx_gain_ranges[name].min, name); + set_rx_gain(xcvr_rx_gain_ranges[name].start(), name); } } @@ -259,17 +265,9 @@ void xcvr2450::update_atr(void){ * Tuning **********************************************************************/ void xcvr2450::set_lo_freq(double target_freq){ - //clip for highband and lowband - if((target_freq > xcvr_freq_band_seperation.min) and (target_freq < xcvr_freq_band_seperation.max)){ - if(target_freq - xcvr_freq_band_seperation.min < xcvr_freq_band_seperation.max - target_freq){ - target_freq = xcvr_freq_band_seperation.min; - }else{ - target_freq = xcvr_freq_band_seperation.max; - } - } - //clip for max and min - target_freq = std::clip(target_freq, xcvr_freq_range.min, xcvr_freq_range.max); + //clip the input to the range + target_freq = xcvr_freq_range.clip(target_freq); //variables used in the calculation below double scaler = xcvr2450::is_highband(target_freq)? (4.0/5.0) : (4.0/3.0); diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp index 661030aa7..1c2519291 100644 --- a/host/lib/usrp/mboard_eeprom.cpp +++ b/host/lib/usrp/mboard_eeprom.cpp @@ -139,7 +139,7 @@ static void store_n100(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ * Implementation of B000 load/store **********************************************************************/ static const boost::uint8_t B000_EEPROM_ADDR = 0x50; -static const size_t B000X_SERIAL_LEN = 8; +static const size_t B000_SERIAL_LEN = 8; static const uhd::dict<std::string, boost::uint8_t> USRP_B000_OFFSETS = boost::assign::map_list_of ("serial", 0xf8) @@ -149,7 +149,7 @@ static const uhd::dict<std::string, boost::uint8_t> USRP_B000_OFFSETS = boost::a static void load_b000(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ //extract the serial mb_eeprom["serial"] = bytes_to_string(iface.read_eeprom( - B000_EEPROM_ADDR, USRP_B000_OFFSETS["serial"], B000X_SERIAL_LEN + B000_EEPROM_ADDR, USRP_B000_OFFSETS["serial"], B000_SERIAL_LEN )); //extract the name @@ -162,7 +162,7 @@ static void store_b000(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ //store the serial if (mb_eeprom.has_key("serial")) iface.write_eeprom( B000_EEPROM_ADDR, USRP_B000_OFFSETS["serial"], - string_to_bytes(mb_eeprom["serial"], B000X_SERIAL_LEN) + string_to_bytes(mb_eeprom["serial"], B000_SERIAL_LEN) ); //store the name diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp index 4aa730573..18f794632 100644 --- a/host/lib/usrp/usrp1/codec_ctrl.cpp +++ b/host/lib/usrp/usrp1/codec_ctrl.cpp @@ -160,19 +160,19 @@ usrp1_codec_ctrl_impl::~usrp1_codec_ctrl_impl(void) static const int mtpgw = 255; //maximum tx pga gain word void usrp1_codec_ctrl_impl::set_tx_pga_gain(float gain){ - int gain_word = int(mtpgw*(gain - tx_pga_gain_range.min)/(tx_pga_gain_range.max - tx_pga_gain_range.min)); + int gain_word = int(mtpgw*(gain - tx_pga_gain_range.start())/(tx_pga_gain_range.stop() - tx_pga_gain_range.start())); _ad9862_regs.tx_pga_gain = std::clip(gain_word, 0, mtpgw); this->send_reg(16); } float usrp1_codec_ctrl_impl::get_tx_pga_gain(void){ - return (_ad9862_regs.tx_pga_gain*(tx_pga_gain_range.max - tx_pga_gain_range.min)/mtpgw) + tx_pga_gain_range.min; + return (_ad9862_regs.tx_pga_gain*(tx_pga_gain_range.stop() - tx_pga_gain_range.start())/mtpgw) + tx_pga_gain_range.start(); } static const int mrpgw = 0x14; //maximum rx pga gain word void usrp1_codec_ctrl_impl::set_rx_pga_gain(float gain, char which){ - int gain_word = int(mrpgw*(gain - rx_pga_gain_range.min)/(rx_pga_gain_range.max - rx_pga_gain_range.min)); + int gain_word = int(mrpgw*(gain - rx_pga_gain_range.start())/(rx_pga_gain_range.stop() - rx_pga_gain_range.start())); gain_word = std::clip(gain_word, 0, mrpgw); switch(which){ case 'A': @@ -194,7 +194,7 @@ float usrp1_codec_ctrl_impl::get_rx_pga_gain(char which){ case 'B': gain_word = _ad9862_regs.rx_pga_b; break; default: UHD_THROW_INVALID_CODE_PATH(); } - return (gain_word*(rx_pga_gain_range.max - rx_pga_gain_range.min)/mrpgw) + rx_pga_gain_range.min; + return (gain_word*(rx_pga_gain_range.stop() - rx_pga_gain_range.start())/mrpgw) + rx_pga_gain_range.start(); } /*********************************************************************** diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index 147b968b4..10cb86962 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -42,7 +42,7 @@ using namespace uhd::transport; * This will be fixed when host-based flow control is implemented, * along with larger incoming send buffers using the on-board SRAM. */ -static const size_t CONTROL_TIMEOUT_MS = 3000; //3 seconds +static const double CONTROL_TIMEOUT = 3.0; //seconds class usrp2_iface_impl : public usrp2_iface{ public: @@ -244,7 +244,7 @@ public: boost::uint8_t usrp2_ctrl_data_in_mem[udp_simple::mtu]; //allocate max bytes for recv const usrp2_ctrl_data_t *ctrl_data_in = reinterpret_cast<const usrp2_ctrl_data_t *>(usrp2_ctrl_data_in_mem); while(true){ - size_t len = _ctrl_transport->recv(boost::asio::buffer(usrp2_ctrl_data_in_mem), CONTROL_TIMEOUT_MS); + size_t len = _ctrl_transport->recv(boost::asio::buffer(usrp2_ctrl_data_in_mem), CONTROL_TIMEOUT); if(len >= sizeof(boost::uint32_t) and ntohl(ctrl_data_in->proto_ver) != USRP2_FW_COMPAT_NUM){ throw std::runtime_error(str(boost::format( "Expected protocol compatibility number %d, but got %d:\n" diff --git a/host/lib/usrp/wrapper_utils.hpp b/host/lib/usrp/wrapper_utils.hpp index 6f9fdbfca..a7b5c5da6 100644 --- a/host/lib/usrp/wrapper_utils.hpp +++ b/host/lib/usrp/wrapper_utils.hpp @@ -30,7 +30,7 @@ static inline uhd::freq_range_t add_dsp_shift( wax::obj dsp ){ double codec_rate = dsp[uhd::usrp::DSP_PROP_CODEC_RATE].as<double>(); - return uhd::freq_range_t(range.min - codec_rate/2.0, range.max + codec_rate/2.0); + return uhd::freq_range_t(range.start() - codec_rate/2.0, range.stop() + codec_rate/2.0); } static inline void do_samp_rate_warning_message( |