aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-10-10 17:18:14 -0700
committerJosh Blum <josh@joshknows.com>2011-10-10 17:18:14 -0700
commitda8a6ff1ee9ac9eb14cb290a8fed9a95f5232a21 (patch)
tree1d5f0a6eacc8f6ae9c0f7a7a4188bd7bb3d5c90d
parentee917d28ff0d0cb42941651fc2d074ad8866dd7a (diff)
downloaduhd-da8a6ff1ee9ac9eb14cb290a8fed9a95f5232a21.tar.gz
uhd-da8a6ff1ee9ac9eb14cb290a8fed9a95f5232a21.tar.bz2
uhd-da8a6ff1ee9ac9eb14cb290a8fed9a95f5232a21.zip
usrp: added revision field to the dboard id class
-rw-r--r--host/include/uhd/usrp/dboard_eeprom.hpp3
-rw-r--r--host/lib/usrp/dboard_eeprom.cpp21
-rw-r--r--host/utils/usrp_burn_db_eeprom.cpp8
3 files changed, 30 insertions, 2 deletions
diff --git a/host/include/uhd/usrp/dboard_eeprom.hpp b/host/include/uhd/usrp/dboard_eeprom.hpp
index f0190e233..93fc5ac7d 100644
--- a/host/include/uhd/usrp/dboard_eeprom.hpp
+++ b/host/include/uhd/usrp/dboard_eeprom.hpp
@@ -33,6 +33,9 @@ struct UHD_API dboard_eeprom_t{
//! The unique serial number
std::string serial;
+ //! A hardware revision number
+ std::string revision;
+
/*!
* Create an empty dboard eeprom struct.
*/
diff --git a/host/lib/usrp/dboard_eeprom.cpp b/host/lib/usrp/dboard_eeprom.cpp
index b3cb54c1c..f2bee47a9 100644
--- a/host/lib/usrp/dboard_eeprom.cpp
+++ b/host/lib/usrp/dboard_eeprom.cpp
@@ -20,6 +20,7 @@
#include <uhd/utils/log.hpp>
#include <boost/foreach.hpp>
#include <boost/format.hpp>
+#include <boost/lexical_cast.hpp>
#include <algorithm>
#include <sstream>
@@ -68,8 +69,8 @@ static const byte_vector_t string_to_bytes(const std::string &string, size_t max
#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_REV_LSB 0x03
+#define DB_EEPROM_REV_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
@@ -127,6 +128,15 @@ void dboard_eeprom_t::load(i2c_iface &iface, boost::uint8_t addr){
&bytes.at(DB_EEPROM_SERIAL+DB_EEPROM_SERIAL_LEN))
);
+ //parse the revision
+ const boost::uint16_t rev_num = 0
+ | (boost::uint16_t(bytes[DB_EEPROM_REV_LSB]) << 0)
+ | (boost::uint16_t(bytes[DB_EEPROM_REV_MSB]) << 8)
+ ;
+ if (rev_num != 0 and rev_num != 0xffff){
+ revision = boost::lexical_cast<std::string>(rev_num);
+ }
+
}catch(const uhd::assertion_error &){
id = dboard_id_t::none();
serial = "";
@@ -145,6 +155,13 @@ void dboard_eeprom_t::store(i2c_iface &iface, boost::uint8_t addr) const{
byte_vector_t ser_bytes = string_to_bytes(serial, DB_EEPROM_SERIAL_LEN);
std::copy(ser_bytes.begin(), ser_bytes.end(), &bytes.at(DB_EEPROM_SERIAL));
+ //load the revision bytes
+ if (not revision.empty()){
+ const boost::uint16_t rev_num = boost::lexical_cast<boost::uint16_t>(revision);
+ bytes[DB_EEPROM_REV_LSB] = boost::uint8_t(rev_num >> 0);
+ bytes[DB_EEPROM_REV_MSB] = boost::uint8_t(rev_num >> 8);
+ }
+
//load the checksum
bytes[DB_EEPROM_CHKSUM] = checksum(bytes);
diff --git a/host/utils/usrp_burn_db_eeprom.cpp b/host/utils/usrp_burn_db_eeprom.cpp
index 253b73262..b6b2dc4d6 100644
--- a/host/utils/usrp_burn_db_eeprom.cpp
+++ b/host/utils/usrp_burn_db_eeprom.cpp
@@ -44,6 +44,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
("unit", po::value<std::string>(&unit)->default_value(""), "which unit [RX, TX, or GDB]")
("id", po::value<std::string>(), "dboard id to burn, omit for readback")
("ser", po::value<std::string>(), "serial to burn, omit for readback")
+ ("rev", po::value<std::string>(), "revision to burn, omit for readback")
;
po::variables_map vm;
@@ -87,6 +88,13 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
}
std::cout << boost::format(" Current serial: \"%s\"") % db_eeprom.serial << std::endl;
+ //------------- handle the dboard revision------------------------//
+ if (vm.count("rev")){
+ db_eeprom.revision = vm["rev"].as<std::string>();
+ tree->access<dboard_eeprom_t>(db_path).set(db_eeprom);
+ }
+ std::cout << boost::format(" Current revision: \"%s\"") % db_eeprom.revision << std::endl;
+
std::cout << " Done" << std::endl << std::endl;
return 0;
}