aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/mboard_eeprom.cpp
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/usrp/mboard_eeprom.cpp
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/usrp/mboard_eeprom.cpp')
-rw-r--r--host/lib/usrp/mboard_eeprom.cpp91
1 files changed, 66 insertions, 25 deletions
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;
}
}