From 039eceb4b208b2ca5a3465d2f16c8d5a7c7276c7 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 23 Apr 2010 19:21:47 -0700 Subject: Moved reading the eeprom (dboard ids) onto the host. Created a eeprom parser for the format in the dboard. Removed the support from the microblaze code. --- host/lib/usrp/dboard_eeprom.cpp | 78 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 host/lib/usrp/dboard_eeprom.cpp (limited to 'host/lib/usrp/dboard_eeprom.cpp') diff --git a/host/lib/usrp/dboard_eeprom.cpp b/host/lib/usrp/dboard_eeprom.cpp new file mode 100644 index 000000000..a8fac602a --- /dev/null +++ b/host/lib/usrp/dboard_eeprom.cpp @@ -0,0 +1,78 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include +#include + +using namespace uhd; +using namespace uhd::usrp; + +//////////////////////////////////////////////////////////////////////// +// format of daughterboard EEPROM +// 00: 0xDB code for ``I'm a daughterboard'' +// 01: .. Daughterboard ID (LSB) +// 02: .. Daughterboard ID (MSB) +// 03: .. io bits 7-0 direction (bit set if it's an output from m'board) +// 04: .. io bits 15-8 direction (bit set if it's an output from m'board) +// 05: .. ADC0 DC offset correction (LSB) +// 06: .. ADC0 DC offset correction (MSB) +// 07: .. ADC1 DC offset correction (LSB) +// 08: .. ADC1 DC offset correction (MSB) +// ... +// 1f: .. negative of the sum of bytes [0x00, 0x1e] + +#define DB_EEPROM_MAGIC 0x00 +#define DB_EEPROM_MAGIC_VALUE 0xDB +#define DB_EEPROM_ID_LSB 0x01 +#define DB_EEPROM_ID_MSB 0x02 +#define DB_EEPROM_OE_LSB 0x03 +#define DB_EEPROM_OE_MSB 0x04 +#define DB_EEPROM_OFFSET_0_LSB 0x05 // offset correction for ADC or DAC 0 +#define DB_EEPROM_OFFSET_0_MSB 0x06 +#define DB_EEPROM_OFFSET_1_LSB 0x07 // offset correction for ADC or DAC 1 +#define DB_EEPROM_OFFSET_1_MSB 0x08 +#define DB_EEPROM_CHKSUM 0x1f + +#define DB_EEPROM_CLEN 0x20 // length of common portion of eeprom + +#define DB_EEPROM_CUSTOM_BASE DB_EEPROM_CLEN // first avail offset for + // daughterboard specific use +//////////////////////////////////////////////////////////////////////// + +dboard_eeprom_t::dboard_eeprom_t(const byte_vector_t &buf){ + try{ + ASSERT_THROW(buf.size() >= num_bytes()); + ASSERT_THROW(buf[DB_EEPROM_MAGIC] == DB_EEPROM_MAGIC_VALUE); + id = \ + (boost::uint16_t(buf[DB_EEPROM_ID_LSB]) << 0) | + (boost::uint16_t(buf[DB_EEPROM_ID_MSB]) << 8) ; + }catch(const uhd::assert_error &e){ + id = dboard_id::NONE; + } +} + +byte_vector_t dboard_eeprom_t::get_eeprom_bytes(void){ + byte_vector_t bytes(3); + bytes[DB_EEPROM_MAGIC] = DB_EEPROM_MAGIC_VALUE; + bytes[DB_EEPROM_ID_LSB] = boost::uint8_t(id >> 0); + bytes[DB_EEPROM_ID_MSB] = boost::uint8_t(id >> 8); + return bytes; +} + +size_t dboard_eeprom_t::num_bytes(void){ + return 3; +} -- cgit v1.2.3 From 300ddf7807e5dd7662b09023ab80da26dd878626 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 24 Apr 2010 10:46:12 -0700 Subject: set dboard eeprom from dboard properties --- host/include/uhd/usrp/dboard_eeprom.hpp | 17 ++++++++----- host/include/uhd/usrp/dboard_iface.hpp | 10 ++++---- host/include/uhd/usrp/dboard_manager.hpp | 1 - host/include/uhd/usrp/dboard_props.hpp | 3 ++- host/lib/usrp/dboard_eeprom.cpp | 25 +++++++++++++------ host/lib/usrp/usrp2/dboard_iface.cpp | 12 +++++----- host/lib/usrp/usrp2/dboard_impl.cpp | 41 +++++++++++++++++++++++--------- host/lib/usrp/usrp2/usrp2_iface.cpp | 14 +++++++---- host/lib/usrp/usrp2/usrp2_impl.hpp | 3 +++ 9 files changed, 84 insertions(+), 42 deletions(-) (limited to 'host/lib/usrp/dboard_eeprom.cpp') diff --git a/host/include/uhd/usrp/dboard_eeprom.hpp b/host/include/uhd/usrp/dboard_eeprom.hpp index 6be88c85a..108027b46 100644 --- a/host/include/uhd/usrp/dboard_eeprom.hpp +++ b/host/include/uhd/usrp/dboard_eeprom.hpp @@ -32,20 +32,25 @@ struct UHD_API dboard_eeprom_t{ dboard_id_t id; /*! - * Create a dboard eeprom struct from the bytes read out of eeprom - * \param buf the vector of bytes + * Create a dboard eeprom struct from the bytes read out of eeprom. + * The constructor will parse out the dboard id from a vector of bytes. + * To be valid, the bytes vector should be at least num_bytes() long. + * If the parsing fails due to bad checksum or incomplete length, + * the dboard id in this struct will be set to dboard_id::NONE. + * \param bytes the vector of bytes */ - dboard_eeprom_t(const uhd::byte_vector_t &buf = uhd::byte_vector_t(0)); + dboard_eeprom_t(const uhd::byte_vector_t &bytes = uhd::byte_vector_t(0)); /*! - * Get the bytes that would be written to dboard eeprom + * Get the bytes that would be written to dboard eeprom. * \return a vector of bytes */ uhd::byte_vector_t get_eeprom_bytes(void); /*! - * Get the number of bytes to read out of eeprom. - * \return the number of bytes we are interested in + * Get the number of bytes in the dboard eeprom segment. + * Use this value when reading out of the dboard eeprom. + * \return the number of bytes used by dboard eeprom */ static size_t num_bytes(void); }; diff --git a/host/include/uhd/usrp/dboard_iface.hpp b/host/include/uhd/usrp/dboard_iface.hpp index 79b8ee664..1214a1a2f 100644 --- a/host/include/uhd/usrp/dboard_iface.hpp +++ b/host/include/uhd/usrp/dboard_iface.hpp @@ -95,19 +95,19 @@ public: /*! * Write to an I2C peripheral. * - * \param i2c_addr I2C bus address (7-bits) - * \param buf the data to write + * \param addr I2C bus address (7-bits) + * \param bytes the data to write */ - virtual void write_i2c(int i2c_addr, const byte_vector_t &buf) = 0; + virtual void write_i2c(boost::uint8_t addr, const byte_vector_t &bytes) = 0; /*! * Read from an I2C peripheral. * - * \param i2c_addr I2C bus address (7-bits) + * \param addr I2C bus address (7-bits) * \param num_bytes number of bytes to read * \return the data read if successful, else a zero length string. */ - virtual byte_vector_t read_i2c(int i2c_addr, size_t num_bytes) = 0; + virtual byte_vector_t read_i2c(boost::uint8_t addr, size_t num_bytes) = 0; /*! * Write data to SPI bus peripheral. diff --git a/host/include/uhd/usrp/dboard_manager.hpp b/host/include/uhd/usrp/dboard_manager.hpp index 6de64b02d..007d85bb4 100644 --- a/host/include/uhd/usrp/dboard_manager.hpp +++ b/host/include/uhd/usrp/dboard_manager.hpp @@ -33,7 +33,6 @@ namespace uhd{ namespace usrp{ * Provide wax::obj access to the subdevs inside. */ class UHD_API dboard_manager : boost::noncopyable{ - public: typedef boost::shared_ptr sptr; diff --git a/host/include/uhd/usrp/dboard_props.hpp b/host/include/uhd/usrp/dboard_props.hpp index 3b290319f..0208a6c2c 100644 --- a/host/include/uhd/usrp/dboard_props.hpp +++ b/host/include/uhd/usrp/dboard_props.hpp @@ -29,7 +29,8 @@ namespace uhd{ namespace usrp{ DBOARD_PROP_NAME = 'n', //ro, std::string DBOARD_PROP_SUBDEV = 's', //ro, wax::obj DBOARD_PROP_SUBDEV_NAMES = 'S', //ro, prop_names_t - DBOARD_PROP_USED_SUBDEVS = 'u' //ro, prop_names_t + DBOARD_PROP_USED_SUBDEVS = 'u', //ro, prop_names_t + DBOARD_PROP_DBOARD_ID = 'i' //rw, dboard_id_t //DBOARD_PROP_CODEC //ro, wax::obj //----> not sure, dont have to deal with yet }; diff --git a/host/lib/usrp/dboard_eeprom.cpp b/host/lib/usrp/dboard_eeprom.cpp index a8fac602a..5ce0b2328 100644 --- a/host/lib/usrp/dboard_eeprom.cpp +++ b/host/lib/usrp/dboard_eeprom.cpp @@ -53,26 +53,37 @@ using namespace uhd::usrp; // daughterboard specific use //////////////////////////////////////////////////////////////////////// -dboard_eeprom_t::dboard_eeprom_t(const byte_vector_t &buf){ +//negative sum of bytes excluding checksum byte +static boost::uint8_t checksum(const byte_vector_t &bytes){ + int sum; + for (size_t i = 0; i < DB_EEPROM_CHKSUM; i++){ + sum += int(bytes.at(i)); + } + return (-sum) & 0xff; +} + +dboard_eeprom_t::dboard_eeprom_t(const byte_vector_t &bytes){ try{ - ASSERT_THROW(buf.size() >= num_bytes()); - ASSERT_THROW(buf[DB_EEPROM_MAGIC] == DB_EEPROM_MAGIC_VALUE); + ASSERT_THROW(bytes.size() >= DB_EEPROM_CLEN); + ASSERT_THROW(bytes[DB_EEPROM_MAGIC] == DB_EEPROM_MAGIC_VALUE); + ASSERT_THROW(bytes[DB_EEPROM_CHKSUM] == checksum(bytes)); id = \ - (boost::uint16_t(buf[DB_EEPROM_ID_LSB]) << 0) | - (boost::uint16_t(buf[DB_EEPROM_ID_MSB]) << 8) ; + (boost::uint16_t(bytes[DB_EEPROM_ID_LSB]) << 0) | + (boost::uint16_t(bytes[DB_EEPROM_ID_MSB]) << 8) ; }catch(const uhd::assert_error &e){ id = dboard_id::NONE; } } byte_vector_t dboard_eeprom_t::get_eeprom_bytes(void){ - byte_vector_t bytes(3); + byte_vector_t bytes(DB_EEPROM_CLEN, 0); //defaults to all zeros bytes[DB_EEPROM_MAGIC] = DB_EEPROM_MAGIC_VALUE; bytes[DB_EEPROM_ID_LSB] = boost::uint8_t(id >> 0); bytes[DB_EEPROM_ID_MSB] = boost::uint8_t(id >> 8); + bytes[DB_EEPROM_CHKSUM] = checksum(bytes); return bytes; } size_t dboard_eeprom_t::num_bytes(void){ - return 3; + return DB_EEPROM_CLEN; } diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp index 9d9b745ae..9503c329b 100644 --- a/host/lib/usrp/usrp2/dboard_iface.cpp +++ b/host/lib/usrp/usrp2/dboard_iface.cpp @@ -42,8 +42,8 @@ public: void set_gpio_ddr(unit_t, boost::uint16_t); boost::uint16_t read_gpio(unit_t); - void write_i2c(int, const byte_vector_t &); - byte_vector_t read_i2c(int, size_t); + void write_i2c(boost::uint8_t, const byte_vector_t &); + byte_vector_t read_i2c(boost::uint8_t, size_t); double get_clock_rate(unit_t); void set_clock_enabled(unit_t, bool); @@ -212,12 +212,12 @@ boost::uint32_t usrp2_dboard_iface::read_write_spi( /*********************************************************************** * I2C **********************************************************************/ -void usrp2_dboard_iface::write_i2c(int i2c_addr, const byte_vector_t &buf){ - return _iface->write_i2c(i2c_addr, buf); +void usrp2_dboard_iface::write_i2c(boost::uint8_t addr, const byte_vector_t &bytes){ + return _iface->write_i2c(addr, bytes); } -byte_vector_t usrp2_dboard_iface::read_i2c(int i2c_addr, size_t num_bytes){ - return _iface->read_i2c(i2c_addr, num_bytes); +byte_vector_t usrp2_dboard_iface::read_i2c(boost::uint8_t addr, size_t num_bytes){ + return _iface->read_i2c(addr, num_bytes); } /*********************************************************************** diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp index d697f11f0..8952a9f75 100644 --- a/host/lib/usrp/usrp2/dboard_impl.cpp +++ b/host/lib/usrp/usrp2/dboard_impl.cpp @@ -18,7 +18,6 @@ #include "usrp2_impl.hpp" #include "usrp2_regs.hpp" -#include #include #include #include @@ -34,16 +33,16 @@ using namespace uhd::usrp; * Helper Methods **********************************************************************/ void usrp2_impl::dboard_init(void){ - //extract the dboard ids - dboard_eeprom_t db_rx_eeprom(_iface->read_eeprom(I2C_ADDR_RX_DB, 0, dboard_eeprom_t::num_bytes())); - dboard_eeprom_t db_tx_eeprom(_iface->read_eeprom(I2C_ADDR_TX_DB, 0, dboard_eeprom_t::num_bytes())); + //read the dboard eeprom to extract the dboard ids + _rx_db_eeprom = dboard_eeprom_t(_iface->read_eeprom(I2C_ADDR_RX_DB, 0, dboard_eeprom_t::num_bytes())); + _tx_db_eeprom = dboard_eeprom_t(_iface->read_eeprom(I2C_ADDR_TX_DB, 0, dboard_eeprom_t::num_bytes())); //create a new dboard interface and manager dboard_iface::sptr _dboard_iface( make_usrp2_dboard_iface(_iface, _clk_ctrl) ); _dboard_manager = dboard_manager::make( - db_rx_eeprom.id, db_tx_eeprom.id, _dboard_iface + _rx_db_eeprom.id, _tx_db_eeprom.id, _dboard_iface ); //load dboards @@ -120,19 +119,29 @@ void usrp2_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){ val = _rx_subdevs_in_use; return; + case DBOARD_PROP_DBOARD_ID: + val = _rx_db_eeprom.id; + return; + //case DBOARD_PROP_CODEC: // throw std::runtime_error("unhandled prop in usrp2 dboard"); } } void usrp2_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val){ - if (key.as() == DBOARD_PROP_USED_SUBDEVS){ + switch(key.as()){ + case DBOARD_PROP_USED_SUBDEVS: _rx_subdevs_in_use = val.as(); update_rx_mux_config(); //if the val is bad, this will throw return; - } - throw std::runtime_error("Cannot set on usrp2 dboard"); + case DBOARD_PROP_DBOARD_ID: + _rx_db_eeprom.id = val.as(); + _iface->write_eeprom(I2C_ADDR_RX_DB, 0, _tx_db_eeprom.get_eeprom_bytes()); + return; + + default: throw std::runtime_error("Cannot set read-only property on usrp2 dboard"); + } } /*********************************************************************** @@ -160,17 +169,27 @@ void usrp2_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){ val = _tx_subdevs_in_use; return; + case DBOARD_PROP_DBOARD_ID: + val = _tx_db_eeprom.id; + return; + //case DBOARD_PROP_CODEC: // throw std::runtime_error("unhandled prop in usrp2 dboard"); } } void usrp2_impl::tx_dboard_set(const wax::obj &key, const wax::obj &val){ - if (key.as() == DBOARD_PROP_USED_SUBDEVS){ + switch(key.as()){ + case DBOARD_PROP_USED_SUBDEVS: _tx_subdevs_in_use = val.as(); update_tx_mux_config(); //if the val is bad, this will throw return; - } - throw std::runtime_error("Cannot set on usrp2 dboard"); + case DBOARD_PROP_DBOARD_ID: + _tx_db_eeprom.id = val.as(); + _iface->write_eeprom(I2C_ADDR_TX_DB, 0, _tx_db_eeprom.get_eeprom_bytes()); + return; + + default: throw std::runtime_error("Cannot set read-only property on usrp2 dboard"); + } } diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index c639c0dfe..76ee5d6fe 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -136,8 +136,8 @@ public: /*********************************************************************** * EEPROM **********************************************************************/ - void write_eeprom(boost::uint8_t addr, boost::uint8_t offset, const byte_vector_t &buf){ - BOOST_FOREACH(boost::uint8_t byte, buf){ + void write_eeprom(boost::uint8_t addr, boost::uint8_t offset, const byte_vector_t &bytes){ + BOOST_FOREACH(boost::uint8_t byte, bytes){ //write a byte at a time, its easy that way byte_vector_t cmd = boost::assign::list_of(offset)(byte); this->write_i2c(addr, cmd); @@ -145,9 +145,13 @@ public: } byte_vector_t read_eeprom(boost::uint8_t addr, boost::uint8_t offset, size_t num_bytes){ - //do a zero byte write to start read cycle - write_i2c(addr, byte_vector_t(1, offset)); - return read_i2c(addr, num_bytes); + byte_vector_t bytes; + for (size_t i = 0; i < num_bytes; i++){ + //do a zero byte write to start read cycle + write_i2c(addr, byte_vector_t(1, offset)); + bytes.push_back(read_i2c(addr, 1).at(0)); + } + return bytes; } /*********************************************************************** diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp index dbcee367b..1c9387744 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.hpp +++ b/host/lib/usrp/usrp2/usrp2_impl.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -161,12 +162,14 @@ private: void rx_dboard_set(const wax::obj &, const wax::obj &); wax_obj_proxy::sptr _rx_dboard_proxy; uhd::prop_names_t _rx_subdevs_in_use; + uhd::usrp::dboard_eeprom_t _rx_db_eeprom; //properties interface for tx dboard void tx_dboard_get(const wax::obj &, wax::obj &); void tx_dboard_set(const wax::obj &, const wax::obj &); wax_obj_proxy::sptr _tx_dboard_proxy; uhd::prop_names_t _tx_subdevs_in_use; + uhd::usrp::dboard_eeprom_t _tx_db_eeprom; void update_rx_mux_config(void); void update_tx_mux_config(void); -- cgit v1.2.3 From 1217b8d67c3bef98195836fe10ab39576642b340 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 26 Apr 2010 12:16:37 -0700 Subject: Got eeprom read/write dboard ids working. Moved named prop implementation into cpp, and made named prop a struct (tuples are trouble). --- host/include/uhd/utils/props.hpp | 29 ++++++++++++++++-------- host/lib/CMakeLists.txt | 1 + host/lib/types.cpp | 8 ++++--- host/lib/usrp/dboard_eeprom.cpp | 21 ++++++++++++++---- host/lib/usrp/dboard_manager.cpp | 5 +++-- host/lib/usrp/usrp2/dboard_impl.cpp | 2 +- host/lib/utils.cpp | 44 +++++++++++++++++++++++++++++++++++++ 7 files changed, 91 insertions(+), 19 deletions(-) create mode 100644 host/lib/utils.cpp (limited to 'host/lib/usrp/dboard_eeprom.cpp') diff --git a/host/include/uhd/utils/props.hpp b/host/include/uhd/utils/props.hpp index bfbca4273..768655e36 100644 --- a/host/include/uhd/utils/props.hpp +++ b/host/include/uhd/utils/props.hpp @@ -29,24 +29,35 @@ namespace uhd{ - //typedef for handling named properties + //! The type for a vector of property names typedef std::vector prop_names_t; - typedef boost::tuple named_prop_t; + + /*! + * A named prop struct holds a key and a name. + * Allows properties to be sub-sectioned by name. + */ + struct UHD_API named_prop_t{ + wax::obj key; + std::string name; + + /*! + * Create a new named prop from key and name. + * \param key the property key + * \param name the string name + */ + named_prop_t(const wax::obj &key, const std::string &name); + }; /*! * Utility function to separate a named property into its components. * \param key a reference to the prop object * \param name a reference to the name object + * \return a tuple that can be used with boost::tie */ - inline UHD_API named_prop_t extract_named_prop( + UHD_API boost::tuple extract_named_prop( const wax::obj &key, const std::string &name = "" - ){ - if (key.type() == typeid(named_prop_t)){ - return key.as(); - } - return named_prop_t(key, name); - } + ); //! The exception to throw for property errors struct UHD_API prop_error : virtual std::exception, virtual boost::exception{}; diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index ffbf15484..5252eda8f 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -50,6 +50,7 @@ SET(libuhd_sources gain_handler.cpp load_modules.cpp types.cpp + utils.cpp wax.cpp transport/convert_types.cpp transport/if_addrs.cpp diff --git a/host/lib/types.cpp b/host/lib/types.cpp index a1b9b21a9..08e41b62f 100644 --- a/host/lib/types.cpp +++ b/host/lib/types.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -257,10 +258,11 @@ void i2c_iface::write_eeprom( boost::uint8_t offset, const byte_vector_t &bytes ){ - BOOST_FOREACH(boost::uint8_t byte, bytes){ + for (size_t i = 0; i < bytes.size(); i++){ //write a byte at a time, its easy that way - byte_vector_t cmd = boost::assign::list_of(offset)(byte); + byte_vector_t cmd = boost::assign::list_of(offset+i)(bytes[i]); this->write_i2c(addr, cmd); + boost::this_thread::sleep(boost::posix_time::milliseconds(10)); //worst case write } } @@ -272,7 +274,7 @@ byte_vector_t i2c_iface::read_eeprom( byte_vector_t bytes; for (size_t i = 0; i < num_bytes; i++){ //do a zero byte write to start read cycle - this->write_i2c(addr, byte_vector_t(1, offset)); + this->write_i2c(addr, byte_vector_t(1, offset+i)); bytes.push_back(this->read_i2c(addr, 1).at(0)); } return bytes; diff --git a/host/lib/usrp/dboard_eeprom.cpp b/host/lib/usrp/dboard_eeprom.cpp index 5ce0b2328..00236c337 100644 --- a/host/lib/usrp/dboard_eeprom.cpp +++ b/host/lib/usrp/dboard_eeprom.cpp @@ -17,10 +17,14 @@ #include #include +#include +#include using namespace uhd; using namespace uhd::usrp; +static const bool _dboard_eeprom_debug = false; + //////////////////////////////////////////////////////////////////////// // format of daughterboard EEPROM // 00: 0xDB code for ``I'm a daughterboard'' @@ -55,14 +59,23 @@ using namespace uhd::usrp; //negative sum of bytes excluding checksum byte static boost::uint8_t checksum(const byte_vector_t &bytes){ - int sum; - for (size_t i = 0; i < DB_EEPROM_CHKSUM; i++){ - sum += int(bytes.at(i)); + int sum = 0; + for (size_t i = 0; i < std::min(bytes.size(), size_t(DB_EEPROM_CHKSUM)); i++){ + sum -= int(bytes.at(i)); } - return (-sum) & 0xff; + if (_dboard_eeprom_debug) + std::cout << boost::format("sum: 0x%02x") % sum << std::endl; + return boost::uint8_t(sum); } dboard_eeprom_t::dboard_eeprom_t(const byte_vector_t &bytes){ + if (_dboard_eeprom_debug){ + for (size_t i = 0; i < bytes.size(); i++){ + std::cout << boost::format( + "eeprom byte[0x%02x] = 0x%02x") % i % int(bytes.at(i) + ) << std::endl; + } + } try{ ASSERT_THROW(bytes.size() >= DB_EEPROM_CLEN); ASSERT_THROW(bytes[DB_EEPROM_MAGIC] == DB_EEPROM_MAGIC_VALUE); diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index 06f8c55b6..34b635934 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -177,10 +177,11 @@ static args_t get_dboard_args( //verify that there is a registered constructor for this id if (not get_id_to_args_map().has_key(dboard_id)){ - throw std::runtime_error(str( + /*throw std::runtime_error(str( boost::format("Unregistered %s dboard id: %s") % xx_type % dboard_id::to_string(dboard_id) - )); + ));*/ + return get_dboard_args(dboard_id::NONE, xx_type); } //return the dboard args for this id diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp index 043609458..a68ae240e 100644 --- a/host/lib/usrp/usrp2/dboard_impl.cpp +++ b/host/lib/usrp/usrp2/dboard_impl.cpp @@ -136,7 +136,7 @@ void usrp2_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val){ case DBOARD_PROP_DBOARD_ID: _rx_db_eeprom.id = val.as(); - _iface->write_eeprom(I2C_ADDR_RX_DB, 0, _tx_db_eeprom.get_eeprom_bytes()); + _iface->write_eeprom(I2C_ADDR_RX_DB, 0, _rx_db_eeprom.get_eeprom_bytes()); return; default: UHD_THROW_PROP_READ_ONLY(); diff --git a/host/lib/utils.cpp b/host/lib/utils.cpp new file mode 100644 index 000000000..3a1e5aa3f --- /dev/null +++ b/host/lib/utils.cpp @@ -0,0 +1,44 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include + +using namespace uhd; + +/*********************************************************************** + * Props + **********************************************************************/ +named_prop_t::named_prop_t( + const wax::obj &key_, + const std::string &name_ +){ + key = key_; + name = name_; +} + +typedef boost::tuple named_prop_tuple; + +named_prop_tuple uhd::extract_named_prop( + const wax::obj &key, + const std::string &name +){ + if (key.type() == typeid(named_prop_t)){ + named_prop_t np = key.as(); + return named_prop_tuple(np.key, np.name); + } + return named_prop_tuple(key, name); +} -- cgit v1.2.3 From 90ed2e3a80eef0be3a7270364335f0e82f004cc1 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 26 Apr 2010 14:42:32 -0700 Subject: prefixed the ASSERT_THROW macro with UHD for the sake of namespace --- host/include/uhd/utils/assert.hpp | 2 +- host/lib/device.cpp | 4 ++-- host/lib/transport/convert_types.cpp | 4 ++-- host/lib/usrp/dboard/db_basic_and_lf.cpp | 8 ++++---- host/lib/usrp/dboard/db_rfx.cpp | 10 +++++----- host/lib/usrp/dboard/db_xcvr2450.cpp | 4 ++-- host/lib/usrp/dboard_eeprom.cpp | 6 +++--- host/lib/usrp/dboard_manager.cpp | 2 +- host/lib/usrp/usrp2/dboard_impl.cpp | 4 ++-- host/lib/usrp/usrp2/dsp_impl.cpp | 2 +- host/lib/usrp/usrp2/mboard_impl.cpp | 18 +++++++++--------- host/lib/usrp/usrp2/usrp2_iface.cpp | 16 ++++++++-------- host/lib/usrp/usrp2/usrp2_impl.cpp | 2 +- 13 files changed, 41 insertions(+), 41 deletions(-) (limited to 'host/lib/usrp/dboard_eeprom.cpp') diff --git a/host/include/uhd/utils/assert.hpp b/host/include/uhd/utils/assert.hpp index 773acd634..01beed757 100644 --- a/host/include/uhd/utils/assert.hpp +++ b/host/include/uhd/utils/assert.hpp @@ -37,7 +37,7 @@ namespace uhd{ typedef boost::error_info assert_info; //! Throw an assert error with throw-site information - #define ASSERT_THROW(_x) if (not (_x)) \ + #define UHD_ASSERT_THROW(_x) if (not (_x)) \ BOOST_THROW_EXCEPTION(uhd::assert_error() << uhd::assert_info(#_x)) /*! diff --git a/host/lib/device.cpp b/host/lib/device.cpp index 0197a6232..706f64951 100644 --- a/host/lib/device.cpp +++ b/host/lib/device.cpp @@ -132,8 +132,8 @@ device::sptr device::make(const device_addr_t &hint, size_t which){ //try to find an existing device try{ - ASSERT_THROW(hash_to_device.has_key(dev_hash)); - ASSERT_THROW(not hash_to_device[dev_hash].expired()); + UHD_ASSERT_THROW(hash_to_device.has_key(dev_hash)); + UHD_ASSERT_THROW(not hash_to_device[dev_hash].expired()); return hash_to_device[dev_hash].lock(); } //create and register a new device diff --git a/host/lib/transport/convert_types.cpp b/host/lib/transport/convert_types.cpp index d7602c049..8c3d6b17a 100644 --- a/host/lib/transport/convert_types.cpp +++ b/host/lib/transport/convert_types.cpp @@ -110,7 +110,7 @@ void transport::convert_io_type_to_otw_type( size_t num_samps ){ //all we handle for now: - ASSERT_THROW(otw_type.width == 16 and otw_type.byteorder == otw_type_t::BO_BIG_ENDIAN); + UHD_ASSERT_THROW(otw_type.width == 16 and otw_type.byteorder == otw_type_t::BO_BIG_ENDIAN); switch(io_type.tid){ case io_type_t::COMPLEX_FLOAT32: @@ -130,7 +130,7 @@ void transport::convert_otw_type_to_io_type( size_t num_samps ){ //all we handle for now: - ASSERT_THROW(otw_type.width == 16 and otw_type.byteorder == otw_type_t::BO_BIG_ENDIAN); + UHD_ASSERT_THROW(otw_type.width == 16 and otw_type.byteorder == otw_type_t::BO_BIG_ENDIAN); switch(io_type.tid){ case io_type_t::COMPLEX_FLOAT32: diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp index c7b841efb..4ca2ef9b1 100644 --- a/host/lib/usrp/dboard/db_basic_and_lf.cpp +++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp @@ -166,11 +166,11 @@ void basic_rx::rx_set(const wax::obj &key_, const wax::obj &val){ switch(key.as()){ case SUBDEV_PROP_GAIN: - ASSERT_THROW(val.as() == float(0)); + UHD_ASSERT_THROW(val.as() == float(0)); return; case SUBDEV_PROP_ANTENNA: - ASSERT_THROW(val.as() == std::string("")); + UHD_ASSERT_THROW(val.as() == std::string("")); return; case SUBDEV_PROP_FREQ: @@ -261,11 +261,11 @@ void basic_tx::tx_set(const wax::obj &key_, const wax::obj &val){ switch(key.as()){ case SUBDEV_PROP_GAIN: - ASSERT_THROW(val.as() == float(0)); + UHD_ASSERT_THROW(val.as() == float(0)); return; case SUBDEV_PROP_ANTENNA: - ASSERT_THROW(val.as() == std::string("")); + UHD_ASSERT_THROW(val.as() == std::string("")); return; case SUBDEV_PROP_FREQ: diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index 49ec9412c..14879dbed 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -192,7 +192,7 @@ void rfx_xcvr::set_tx_lo_freq(double freq){ void rfx_xcvr::set_rx_ant(const std::string &ant){ //validate input - ASSERT_THROW(ant == "TX/RX" or ant == "RX2"); + UHD_ASSERT_THROW(ant == "TX/RX" or ant == "RX2"); //set the rx atr regs that change with antenna setting this->get_iface()->set_atr_reg( @@ -350,12 +350,12 @@ void rfx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN: - ASSERT_THROW(name == "PGA0"); + UHD_ASSERT_THROW(name == "PGA0"); val = _rx_pga0_gain; return; case SUBDEV_PROP_GAIN_RANGE: - ASSERT_THROW(name == "PGA0"); + UHD_ASSERT_THROW(name == "PGA0"); val = gain_range_t(0, _max_rx_pga0_gain, float(0.022)); return; @@ -413,7 +413,7 @@ void rfx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_GAIN: - ASSERT_THROW(name == "PGA0"); + UHD_ASSERT_THROW(name == "PGA0"); set_rx_pga0_gain(val.as()); return; @@ -507,7 +507,7 @@ void rfx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){ case SUBDEV_PROP_ANTENNA: //its always set to tx/rx, so we only allow this value - ASSERT_THROW(val.as() == "TX/RX"); + UHD_ASSERT_THROW(val.as() == "TX/RX"); return; default: UHD_THROW_PROP_READ_ONLY(); diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index 2052511f8..576d08848 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -395,7 +395,7 @@ void xcvr2450::set_tx_gain(float gain, const std::string &name){ _max2829_regs.tx_baseband_gain = gain_to_tx_bb_reg(gain); send_reg(0x9); } - else ASSERT_THROW(false); + else UHD_ASSERT_THROW(false); _tx_gains[name] = gain; } @@ -409,7 +409,7 @@ void xcvr2450::set_rx_gain(float gain, const std::string &name){ _max2829_regs.rx_lna_gain = gain_to_rx_lna_reg(gain); send_reg(0xB); } - else ASSERT_THROW(false); + else UHD_ASSERT_THROW(false); _rx_gains[name] = gain; } diff --git a/host/lib/usrp/dboard_eeprom.cpp b/host/lib/usrp/dboard_eeprom.cpp index 00236c337..1404ed1e6 100644 --- a/host/lib/usrp/dboard_eeprom.cpp +++ b/host/lib/usrp/dboard_eeprom.cpp @@ -77,9 +77,9 @@ dboard_eeprom_t::dboard_eeprom_t(const byte_vector_t &bytes){ } } try{ - ASSERT_THROW(bytes.size() >= DB_EEPROM_CLEN); - ASSERT_THROW(bytes[DB_EEPROM_MAGIC] == DB_EEPROM_MAGIC_VALUE); - ASSERT_THROW(bytes[DB_EEPROM_CHKSUM] == checksum(bytes)); + UHD_ASSERT_THROW(bytes.size() >= DB_EEPROM_CLEN); + UHD_ASSERT_THROW(bytes[DB_EEPROM_MAGIC] == DB_EEPROM_MAGIC_VALUE); + UHD_ASSERT_THROW(bytes[DB_EEPROM_CHKSUM] == checksum(bytes)); id = \ (boost::uint16_t(bytes[DB_EEPROM_ID_LSB]) << 0) | (boost::uint16_t(bytes[DB_EEPROM_ID_MSB]) << 8) ; diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index 34b635934..390c1d3c9 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -206,7 +206,7 @@ dboard_manager_impl::dboard_manager_impl( //make xcvr subdevs (make one subdev for both rx and tx dboards) if (rx_dboard_ctor == tx_dboard_ctor){ - ASSERT_THROW(rx_subdevs == tx_subdevs); + UHD_ASSERT_THROW(rx_subdevs == tx_subdevs); BOOST_FOREACH(const std::string &subdev, rx_subdevs){ dboard_base::sptr xcvr_dboard = rx_dboard_ctor( dboard_base::ctor_args_t(subdev, iface, rx_dboard_id, tx_dboard_id) diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp index a68ae240e..226a7950d 100644 --- a/host/lib/usrp/usrp2/dboard_impl.cpp +++ b/host/lib/usrp/usrp2/dboard_impl.cpp @@ -66,7 +66,7 @@ void usrp2_impl::dboard_init(void){ void usrp2_impl::update_rx_mux_config(void){ //calculate the rx mux boost::uint32_t rx_mux = 0; - ASSERT_THROW(_rx_subdevs_in_use.size() == 1); + UHD_ASSERT_THROW(_rx_subdevs_in_use.size() == 1); wax::obj rx_subdev = _dboard_manager->get_rx_subdev(_rx_subdevs_in_use.at(0)); std::cout << "Using: " << rx_subdev[SUBDEV_PROP_NAME].as() << std::endl; if (rx_subdev[SUBDEV_PROP_QUADRATURE].as()){ @@ -84,7 +84,7 @@ void usrp2_impl::update_rx_mux_config(void){ void usrp2_impl::update_tx_mux_config(void){ //calculate the tx mux boost::uint32_t tx_mux = 0x10; - ASSERT_THROW(_tx_subdevs_in_use.size() == 1); + UHD_ASSERT_THROW(_tx_subdevs_in_use.size() == 1); wax::obj tx_subdev = _dboard_manager->get_tx_subdev(_tx_subdevs_in_use.at(0)); std::cout << "Using: " << tx_subdev[SUBDEV_PROP_NAME].as() << std::endl; if (tx_subdev[SUBDEV_PROP_IQ_SWAPPED].as()){ diff --git a/host/lib/usrp/usrp2/dsp_impl.cpp b/host/lib/usrp/usrp2/dsp_impl.cpp index 379276f7d..84c50ac0d 100644 --- a/host/lib/usrp/usrp2/dsp_impl.cpp +++ b/host/lib/usrp/usrp2/dsp_impl.cpp @@ -40,7 +40,7 @@ template T log2(T num){ * DDC Helper Methods **********************************************************************/ static boost::uint32_t calculate_freq_word_and_update_actual_freq(double &freq, double clock_freq){ - ASSERT_THROW(std::abs(freq) < clock_freq/2.0); + UHD_ASSERT_THROW(std::abs(freq) < clock_freq/2.0); static const double scale_factor = std::pow(2.0, 32); //calculate the freq register word diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 2c185ec53..684cf245d 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -152,7 +152,7 @@ void usrp2_impl::issue_ddc_stream_cmd(const stream_cmd_t &stream_cmd){ //send and recv usrp2_ctrl_data_t in_data = _iface->ctrl_send_and_recv(out_data); - ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_GOT_THAT_STREAM_COMMAND_DUDE); + UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_GOT_THAT_STREAM_COMMAND_DUDE); } /*********************************************************************** @@ -171,7 +171,7 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){ //send and recv usrp2_ctrl_data_t in_data = _iface->ctrl_send_and_recv(out_data); - ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_THIS_IS_MY_MAC_ADDR_DUDE); + UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_THIS_IS_MY_MAC_ADDR_DUDE); //extract the address val = mac_addr_t::from_bytes(in_data.data.mac_addr).to_string(); @@ -185,7 +185,7 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){ //send and recv usrp2_ctrl_data_t in_data = _iface->ctrl_send_and_recv(out_data); - ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_THIS_IS_MY_IP_ADDR_DUDE); + UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_THIS_IS_MY_IP_ADDR_DUDE); //extract the address val = boost::asio::ip::address_v4(ntohl(in_data.data.ip_addr)).to_string(); @@ -209,7 +209,7 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){ return; case MBOARD_PROP_RX_DBOARD: - ASSERT_THROW(name == ""); + UHD_ASSERT_THROW(name == ""); val = _rx_dboard_proxy->get_link(); return; @@ -218,7 +218,7 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){ return; case MBOARD_PROP_TX_DBOARD: - ASSERT_THROW(name == ""); + UHD_ASSERT_THROW(name == ""); val = _tx_dboard_proxy->get_link(); return; @@ -227,7 +227,7 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){ return; case MBOARD_PROP_RX_DSP: - ASSERT_THROW(name == ""); + UHD_ASSERT_THROW(name == ""); val = _rx_dsp_proxy->get_link(); return; @@ -236,7 +236,7 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){ return; case MBOARD_PROP_TX_DSP: - ASSERT_THROW(name == ""); + UHD_ASSERT_THROW(name == ""); val = _tx_dsp_proxy->get_link(); return; @@ -267,7 +267,7 @@ void usrp2_impl::mboard_set(const wax::obj &key, const wax::obj &val){ //send and recv usrp2_ctrl_data_t in_data = _iface->ctrl_send_and_recv(out_data); - ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_THIS_IS_MY_MAC_ADDR_DUDE); + UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_THIS_IS_MY_MAC_ADDR_DUDE); return; } @@ -279,7 +279,7 @@ void usrp2_impl::mboard_set(const wax::obj &key, const wax::obj &val){ //send and recv usrp2_ctrl_data_t in_data = _iface->ctrl_send_and_recv(out_data); - ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_THIS_IS_MY_IP_ADDR_DUDE); + UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_THIS_IS_MY_IP_ADDR_DUDE); return; } } diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index 27b6f8907..5bca2c95b 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -86,7 +86,7 @@ public: //send and recv usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data); - ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_OMG_TRANSACTED_SPI_DUDE); + UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_OMG_TRANSACTED_SPI_DUDE); return ntohl(out_data.data.spi_args.data); } @@ -102,14 +102,14 @@ public: out_data.data.i2c_args.bytes = buf.size(); //limitation of i2c transaction size - ASSERT_THROW(buf.size() <= sizeof(out_data.data.i2c_args.data)); + UHD_ASSERT_THROW(buf.size() <= sizeof(out_data.data.i2c_args.data)); //copy in the data std::copy(buf.begin(), buf.end(), out_data.data.i2c_args.data); //send and recv usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data); - ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_COOL_IM_DONE_I2C_WRITE_DUDE); + UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_COOL_IM_DONE_I2C_WRITE_DUDE); } byte_vector_t read_i2c(boost::uint8_t addr, size_t num_bytes){ @@ -120,12 +120,12 @@ public: out_data.data.i2c_args.bytes = num_bytes; //limitation of i2c transaction size - ASSERT_THROW(num_bytes <= sizeof(out_data.data.i2c_args.data)); + UHD_ASSERT_THROW(num_bytes <= sizeof(out_data.data.i2c_args.data)); //send and recv usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data); - ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_HERES_THE_I2C_DATA_DUDE); - ASSERT_THROW(in_data.data.i2c_args.addr = num_bytes); + UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_HERES_THE_I2C_DATA_DUDE); + UHD_ASSERT_THROW(in_data.data.i2c_args.addr = num_bytes); //copy out the data byte_vector_t result(num_bytes); @@ -193,7 +193,7 @@ private: //send and recv usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data); - ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_OMG_POKED_REGISTER_SO_BAD_DUDE); + UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_OMG_POKED_REGISTER_SO_BAD_DUDE); } template T peek(boost::uint32_t addr){ @@ -205,7 +205,7 @@ private: //send and recv usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data); - ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE); + UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE); return T(ntohl(out_data.data.poke_args.data)); } diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 11ad812e1..d9b2248ff 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -186,7 +186,7 @@ void usrp2_impl::get(const wax::obj &key_, wax::obj &val){ return; case DEVICE_PROP_MBOARD: - ASSERT_THROW(name == ""); + UHD_ASSERT_THROW(name == ""); val = _mboard_proxy->get_link(); return; -- cgit v1.2.3 From 1ba93e70a6a79dc06bd9ba09a72e2798debede9b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 26 Apr 2010 21:25:00 -0700 Subject: fixed windows warnings --- host/lib/usrp/dboard/db_xcvr2450.cpp | 8 ++++---- host/lib/usrp/dboard_eeprom.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'host/lib/usrp/dboard_eeprom.cpp') diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index efe7687c2..0dfef2a0a 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -263,7 +263,7 @@ void xcvr2450::set_lo_freq(double target_freq){ for(R = 1; R <= 7; R++){ double N = (target_freq*scaler*R*_ad9515div)/ref_freq; intdiv = int(std::floor(N)); - fracdiv = (N - intdiv)*double(1 << 16); + fracdiv = boost::math::iround((N - intdiv)*double(1 << 16)); //actual minimum is 128, but most chips seems to require higher to lock if (intdiv < 131 or intdiv > 255) continue; //constraints met: exit loop @@ -344,8 +344,8 @@ static int gain_to_tx_vga_reg(float &gain){ //calculate the actual gain value if (reg < 4) gain = 0; - else if (reg < 48) gain = reg/2 - 1; - else gain = reg/2.0 - 1.5; + else if (reg < 48) gain = float(reg/2 - 1); + else gain = float(reg/2.0 - 1.5); //return register value return reg; @@ -385,7 +385,7 @@ static max2829_regs_t::tx_baseband_gain_t gain_to_tx_bb_reg(float &gain){ */ static int gain_to_rx_vga_reg(float &gain){ int reg = std::clip(boost::math::iround(gain/2.0), 0, 31); - gain = reg*2; + gain = float(reg*2); return reg; } diff --git a/host/lib/usrp/dboard_eeprom.cpp b/host/lib/usrp/dboard_eeprom.cpp index 1404ed1e6..54e7a4fd9 100644 --- a/host/lib/usrp/dboard_eeprom.cpp +++ b/host/lib/usrp/dboard_eeprom.cpp @@ -83,7 +83,7 @@ dboard_eeprom_t::dboard_eeprom_t(const byte_vector_t &bytes){ id = \ (boost::uint16_t(bytes[DB_EEPROM_ID_LSB]) << 0) | (boost::uint16_t(bytes[DB_EEPROM_ID_MSB]) << 8) ; - }catch(const uhd::assert_error &e){ + }catch(const uhd::assert_error &){ id = dboard_id::NONE; } } -- cgit v1.2.3