diff options
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/usrp/mboard_eeprom.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp index 444057ad9..842ee01e3 100644 --- a/host/lib/usrp/mboard_eeprom.cpp +++ b/host/lib/usrp/mboard_eeprom.cpp @@ -178,10 +178,11 @@ static void store_b000(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ static const boost::uint8_t E100_EEPROM_ADDR = 0x51; struct e100_eeprom_map{ - unsigned int device_vendor; + boost::uint16_t vendor; + boost::uint16_t device; unsigned char revision; unsigned char content; - unsigned char fab_revision[8]; + unsigned char model[8]; unsigned char env_var[16]; unsigned char env_setting[64]; unsigned char serial[10]; @@ -196,41 +197,46 @@ template <typename T> static const byte_vector_t to_bytes(const T &item){ } static void load_e100(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ - const size_t num_bytes = offsetof(e100_eeprom_map, fab_revision); + const size_t num_bytes = offsetof(e100_eeprom_map, model); byte_vector_t map_bytes = iface.read_eeprom(E100_EEPROM_ADDR, 0, num_bytes); e100_eeprom_map map; std::memcpy(&map, &map_bytes[0], map_bytes.size()); - mb_eeprom["device_vendor"] = boost::lexical_cast<std::string>(map.device_vendor); - mb_eeprom["revision"] = boost::lexical_cast<std::string>(map.revision); - mb_eeprom["content"] = boost::lexical_cast<std::string>(map.content); + mb_eeprom["vendor"] = boost::lexical_cast<std::string>(map.vendor); + mb_eeprom["device"] = boost::lexical_cast<std::string>(map.device); + mb_eeprom["revision"] = boost::lexical_cast<std::string>(unsigned(map.revision)); + mb_eeprom["content"] = boost::lexical_cast<std::string>(unsigned(map.content)); #define load_e100_string_xx(key) mb_eeprom[#key] = bytes_to_string(iface.read_eeprom( \ E100_EEPROM_ADDR, offsetof(e100_eeprom_map, key), sizeof(e100_eeprom_map::key) \ )); - load_e100_string_xx(fab_revision); + load_e100_string_xx(model); load_e100_string_xx(env_var); load_e100_string_xx(env_setting); load_e100_string_xx(serial); - load_e100_string_xx(fab_revision); load_e100_string_xx(name); } static void store_e100(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ - if (mb_eeprom.has_key("device_vendor")) iface.write_eeprom( - E100_EEPROM_ADDR, offsetof(e100_eeprom_map, device_vendor), - to_bytes(boost::lexical_cast<unsigned int>(mb_eeprom["device_vendor"])) + if (mb_eeprom.has_key("vendor")) iface.write_eeprom( + E100_EEPROM_ADDR, offsetof(e100_eeprom_map, vendor), + to_bytes(boost::lexical_cast<boost::uint16_t>(mb_eeprom["vendor"])) + ); + + if (mb_eeprom.has_key("device")) iface.write_eeprom( + E100_EEPROM_ADDR, offsetof(e100_eeprom_map, device), + to_bytes(boost::lexical_cast<boost::uint16_t>(mb_eeprom["device"])) ); if (mb_eeprom.has_key("revision")) iface.write_eeprom( E100_EEPROM_ADDR, offsetof(e100_eeprom_map, revision), - to_bytes(boost::lexical_cast<unsigned char>(mb_eeprom["revision"])) + byte_vector_t(1, boost::lexical_cast<unsigned>(mb_eeprom["revision"])) ); if (mb_eeprom.has_key("content")) iface.write_eeprom( E100_EEPROM_ADDR, offsetof(e100_eeprom_map, content), - to_bytes(boost::lexical_cast<unsigned char>(mb_eeprom["content"])) + byte_vector_t(1, boost::lexical_cast<unsigned>(mb_eeprom["content"])) ); #define store_e100_string_xx(key) if (mb_eeprom.has_key(#key)) iface.write_eeprom( \ @@ -238,11 +244,10 @@ static void store_e100(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ string_to_bytes(mb_eeprom[#key], sizeof(e100_eeprom_map::key)) \ ); - store_e100_string_xx(fab_revision); + store_e100_string_xx(model); store_e100_string_xx(env_var); store_e100_string_xx(env_setting); store_e100_string_xx(serial); - store_e100_string_xx(fab_revision); store_e100_string_xx(name); } |