aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-10-11 18:09:45 -0700
committerJosh Blum <josh@joshknows.com>2011-10-12 10:16:48 -0700
commit1a695f94849644773deda18f84a07ef1a206481b (patch)
tree5fa3699ec69792bf01251fac3ef670a771bed915 /host/lib
parent08b23bf3c6fcd0aaa84be74b4890687491e561bb (diff)
downloaduhd-1a695f94849644773deda18f84a07ef1a206481b.tar.gz
uhd-1a695f94849644773deda18f84a07ef1a206481b.tar.bz2
uhd-1a695f94849644773deda18f84a07ef1a206481b.zip
b100: new eeprom map for special 9 byte serial
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/b100/b100_impl.cpp6
-rw-r--r--host/lib/usrp/mboard_eeprom.cpp91
2 files changed, 69 insertions, 28 deletions
diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp
index 591a8b49f..7d5876449 100644
--- a/host/lib/usrp/b100/b100_impl.cpp
+++ b/host/lib/usrp/b100/b100_impl.cpp
@@ -110,7 +110,7 @@ static device_addrs_t b100_find(const device_addr_t &hint)
try{
usb_control::sptr control = usb_control::make(handle, 0);
fx2_ctrl::sptr fx2_ctrl = fx2_ctrl::make(control);
- const mboard_eeprom_t mb_eeprom = mboard_eeprom_t(*fx2_ctrl, mboard_eeprom_t::MAP_B000);
+ const mboard_eeprom_t mb_eeprom = mboard_eeprom_t(*fx2_ctrl, mboard_eeprom_t::MAP_B100);
new_addr["name"] = mb_eeprom["name"];
}
catch(const uhd::exception &){
@@ -243,7 +243,7 @@ b100_impl::b100_impl(const device_addr_t &device_addr){
////////////////////////////////////////////////////////////////////
// setup the mboard eeprom
////////////////////////////////////////////////////////////////////
- const mboard_eeprom_t mb_eeprom(*_fx2_ctrl, mboard_eeprom_t::MAP_B000);
+ const mboard_eeprom_t mb_eeprom(*_fx2_ctrl, mboard_eeprom_t::MAP_B100);
_tree->create<mboard_eeprom_t>(mb_path / "eeprom")
.set(mb_eeprom)
.subscribe(boost::bind(&b100_impl::set_mb_eeprom, this, _1));
@@ -463,7 +463,7 @@ double b100_impl::update_rx_codec_gain(const double gain){
}
void b100_impl::set_mb_eeprom(const uhd::usrp::mboard_eeprom_t &mb_eeprom){
- mb_eeprom.commit(*_fx2_ctrl, mboard_eeprom_t::MAP_B000);
+ mb_eeprom.commit(*_fx2_ctrl, mboard_eeprom_t::MAP_B100);
}
void b100_impl::set_db_eeprom(const std::string &type, const uhd::usrp::dboard_eeprom_t &db_eeprom){
diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp
index 467b4289d..785d30296 100644
--- a/host/lib/usrp/mboard_eeprom.cpp
+++ b/host/lib/usrp/mboard_eeprom.cpp
@@ -215,25 +215,13 @@ static const size_t B000_SERIAL_LEN = 8;
//use char array so we dont need to attribute packed
struct b000_eeprom_map{
- unsigned char _r[217];
- unsigned char revision[2];
- unsigned char product[2];
+ unsigned char _r[221];
unsigned char mcr[4];
unsigned char name[NAME_MAX_LEN];
unsigned char serial[B000_SERIAL_LEN];
};
static void load_b000(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
- //extract the revision number
- mb_eeprom["revision"] = uint16_bytes_to_string(
- iface.read_eeprom(B000_EEPROM_ADDR, offsetof(b000_eeprom_map, revision), 2)
- );
-
- //extract the product code
- mb_eeprom["product"] = uint16_bytes_to_string(
- iface.read_eeprom(B000_EEPROM_ADDR, offsetof(b000_eeprom_map, product), 2)
- );
-
//extract the serial
mb_eeprom["serial"] = bytes_to_string(iface.read_eeprom(
B000_EEPROM_ADDR, offsetof(b000_eeprom_map, serial), B000_SERIAL_LEN
@@ -261,18 +249,6 @@ static void load_b000(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
}
static void store_b000(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
- //parse the revision number
- if (mb_eeprom.has_key("revision")) iface.write_eeprom(
- B000_EEPROM_ADDR, offsetof(b000_eeprom_map, revision),
- string_to_uint16_bytes(mb_eeprom["revision"])
- );
-
- //parse the product code
- if (mb_eeprom.has_key("product")) iface.write_eeprom(
- B000_EEPROM_ADDR, offsetof(b000_eeprom_map, product),
- string_to_uint16_bytes(mb_eeprom["product"])
- );
-
//store the serial
if (mb_eeprom.has_key("serial")) iface.write_eeprom(
B000_EEPROM_ADDR, offsetof(b000_eeprom_map, serial),
@@ -298,6 +274,69 @@ static void store_b000(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
);
}
}
+
+/***********************************************************************
+ * Implementation of B100 load/store
+ **********************************************************************/
+static const boost::uint8_t B100_EEPROM_ADDR = 0x50;
+
+//use char array so we dont need to attribute packed
+struct b100_eeprom_map{
+ unsigned char _r[220];
+ unsigned char revision[2];
+ unsigned char product[2];
+ unsigned char name[NAME_MAX_LEN];
+ unsigned char serial[SERIAL_LEN];
+};
+
+static void load_b100(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
+ //extract the revision number
+ mb_eeprom["revision"] = uint16_bytes_to_string(
+ iface.read_eeprom(B100_EEPROM_ADDR, offsetof(b100_eeprom_map, revision), 2)
+ );
+
+ //extract the product code
+ mb_eeprom["product"] = uint16_bytes_to_string(
+ iface.read_eeprom(B100_EEPROM_ADDR, offsetof(b100_eeprom_map, product), 2)
+ );
+
+ //extract the serial
+ mb_eeprom["serial"] = bytes_to_string(iface.read_eeprom(
+ B100_EEPROM_ADDR, offsetof(b100_eeprom_map, serial), SERIAL_LEN
+ ));
+
+ //extract the name
+ mb_eeprom["name"] = bytes_to_string(iface.read_eeprom(
+ B100_EEPROM_ADDR, offsetof(b100_eeprom_map, name), NAME_MAX_LEN
+ ));
+}
+
+static void store_b100(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
+ //parse the revision number
+ if (mb_eeprom.has_key("revision")) iface.write_eeprom(
+ B100_EEPROM_ADDR, offsetof(b100_eeprom_map, revision),
+ string_to_uint16_bytes(mb_eeprom["revision"])
+ );
+
+ //parse the product code
+ if (mb_eeprom.has_key("product")) iface.write_eeprom(
+ B100_EEPROM_ADDR, offsetof(b100_eeprom_map, product),
+ string_to_uint16_bytes(mb_eeprom["product"])
+ );
+
+ //store the serial
+ if (mb_eeprom.has_key("serial")) iface.write_eeprom(
+ B100_EEPROM_ADDR, offsetof(b100_eeprom_map, serial),
+ string_to_bytes(mb_eeprom["serial"], SERIAL_LEN)
+ );
+
+ //store the name
+ if (mb_eeprom.has_key("name")) iface.write_eeprom(
+ B100_EEPROM_ADDR, offsetof(b100_eeprom_map, name),
+ string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN)
+ );
+}
+
/***********************************************************************
* Implementation of E100 load/store
**********************************************************************/
@@ -391,6 +430,7 @@ mboard_eeprom_t::mboard_eeprom_t(i2c_iface &iface, map_type map){
switch(map){
case MAP_N100: load_n100(*this, iface); break;
case MAP_B000: load_b000(*this, iface); break;
+ case MAP_B100: load_b100(*this, iface); break;
case MAP_E100: load_e100(*this, iface); break;
}
}
@@ -399,6 +439,7 @@ void mboard_eeprom_t::commit(i2c_iface &iface, map_type map) const{
switch(map){
case MAP_N100: store_n100(*this, iface); break;
case MAP_B000: store_b000(*this, iface); break;
+ case MAP_B100: store_b100(*this, iface); break;
case MAP_E100: store_e100(*this, iface); break;
}
}