diff options
author | Josh Blum <josh@joshknows.com> | 2010-11-10 11:27:42 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-11-10 11:27:42 -0800 |
commit | 123de6dad521ca3dbc44a5d9fc70ff754f1196e3 (patch) | |
tree | 53f03bfd7a33e85646c5c21ad685e48202789eb5 /host/lib/usrp/mboard_eeprom.cpp | |
parent | 793519d66aa569f45bbda25ba7f36c1534a451bb (diff) | |
parent | 8c434f7d63aca25b55d6d13dffcc1d7037261d4f (diff) | |
download | uhd-123de6dad521ca3dbc44a5d9fc70ff754f1196e3.tar.gz uhd-123de6dad521ca3dbc44a5d9fc70ff754f1196e3.tar.bz2 uhd-123de6dad521ca3dbc44a5d9fc70ff754f1196e3.zip |
Merge branch 'master' into usrp_e100_i2c
Conflicts:
host/utils/CMakeLists.txt
Diffstat (limited to 'host/lib/usrp/mboard_eeprom.cpp')
-rw-r--r-- | host/lib/usrp/mboard_eeprom.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp index 076d0b279..661030aa7 100644 --- a/host/lib/usrp/mboard_eeprom.cpp +++ b/host/lib/usrp/mboard_eeprom.cpp @@ -57,11 +57,11 @@ static const byte_vector_t string_to_bytes(const std::string &string, size_t max } /*********************************************************************** - * Implementation of NXXX load/store + * Implementation of N100 load/store **********************************************************************/ -static const boost::uint8_t NXXX_EEPROM_ADDR = 0x50; +static const boost::uint8_t N100_EEPROM_ADDR = 0x50; -static const uhd::dict<std::string, boost::uint8_t> USRP_NXXX_OFFSETS = boost::assign::map_list_of +static const uhd::dict<std::string, boost::uint8_t> USRP_N100_OFFSETS = boost::assign::map_list_of ("rev-lsb-msb", 0x00) ("mac-addr", 0x02) ("ip-addr", 0x08) @@ -70,36 +70,36 @@ static const uhd::dict<std::string, boost::uint8_t> USRP_NXXX_OFFSETS = boost::a ("name", 0x18 + SERIAL_LEN) ; -static void load_nxxx(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ +static void load_n100(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ //extract the revision number - byte_vector_t rev_lsb_msb = iface.read_eeprom(NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["rev-lsb-msb"], 2); + byte_vector_t rev_lsb_msb = iface.read_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["rev-lsb-msb"], 2); boost::uint16_t rev = (boost::uint16_t(rev_lsb_msb.at(0)) << 0) | (boost::uint16_t(rev_lsb_msb.at(1)) << 8); mb_eeprom["rev"] = boost::lexical_cast<std::string>(rev); //extract the addresses mb_eeprom["mac-addr"] = mac_addr_t::from_bytes(iface.read_eeprom( - NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["mac-addr"], 6 + N100_EEPROM_ADDR, USRP_N100_OFFSETS["mac-addr"], 6 )).to_string(); boost::asio::ip::address_v4::bytes_type ip_addr_bytes; - std::copy(iface.read_eeprom(NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["ip-addr"], 4), ip_addr_bytes); + std::copy(iface.read_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["ip-addr"], 4), ip_addr_bytes); mb_eeprom["ip-addr"] = boost::asio::ip::address_v4(ip_addr_bytes).to_string(); //extract the serial mb_eeprom["serial"] = bytes_to_string(iface.read_eeprom( - NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["serial"], SERIAL_LEN + N100_EEPROM_ADDR, USRP_N100_OFFSETS["serial"], SERIAL_LEN )); //extract the name mb_eeprom["name"] = bytes_to_string(iface.read_eeprom( - NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["name"], NAME_MAX_LEN + N100_EEPROM_ADDR, USRP_N100_OFFSETS["name"], NAME_MAX_LEN )); //empty serial correction: use the mac address if (mb_eeprom["serial"].empty()) mb_eeprom["serial"] = mb_eeprom["mac-addr"]; } -static void store_nxxx(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ +static void store_n100(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ //parse the revision number if (mb_eeprom.has_key("rev")){ boost::uint16_t rev = boost::lexical_cast<boost::uint16_t>(mb_eeprom["rev"]); @@ -107,67 +107,67 @@ static void store_nxxx(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ (boost::uint8_t(rev >> 0)) (boost::uint8_t(rev >> 8)) ; - iface.write_eeprom(NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["rev-lsb-msb"], rev_lsb_msb); + iface.write_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["rev-lsb-msb"], rev_lsb_msb); } //store the addresses if (mb_eeprom.has_key("mac-addr")) iface.write_eeprom( - NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["mac-addr"], + N100_EEPROM_ADDR, USRP_N100_OFFSETS["mac-addr"], mac_addr_t::from_string(mb_eeprom["mac-addr"]).to_bytes() ); if (mb_eeprom.has_key("ip-addr")){ byte_vector_t ip_addr_bytes(4); std::copy(boost::asio::ip::address_v4::from_string(mb_eeprom["ip-addr"]).to_bytes(), ip_addr_bytes); - iface.write_eeprom(NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["ip-addr"], ip_addr_bytes); + iface.write_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["ip-addr"], ip_addr_bytes); } //store the serial if (mb_eeprom.has_key("serial")) iface.write_eeprom( - NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["serial"], + N100_EEPROM_ADDR, USRP_N100_OFFSETS["serial"], string_to_bytes(mb_eeprom["serial"], SERIAL_LEN) ); //store the name if (mb_eeprom.has_key("name")) iface.write_eeprom( - NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["name"], + N100_EEPROM_ADDR, USRP_N100_OFFSETS["name"], string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN) ); } /*********************************************************************** - * Implementation of B1XX load/store + * Implementation of B000 load/store **********************************************************************/ -static const boost::uint8_t B1XX_EEPROM_ADDR = 0x50; -static const size_t B1XXX_SERIAL_LEN = 8; +static const boost::uint8_t B000_EEPROM_ADDR = 0x50; +static const size_t B000X_SERIAL_LEN = 8; -static const uhd::dict<std::string, boost::uint8_t> USRP_B1XX_OFFSETS = boost::assign::map_list_of +static const uhd::dict<std::string, boost::uint8_t> USRP_B000_OFFSETS = boost::assign::map_list_of ("serial", 0xf8) ("name", 0xf8 - NAME_MAX_LEN) ; -static void load_b1xx(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ +static void load_b000(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ //extract the serial mb_eeprom["serial"] = bytes_to_string(iface.read_eeprom( - B1XX_EEPROM_ADDR, USRP_B1XX_OFFSETS["serial"], B1XXX_SERIAL_LEN + B000_EEPROM_ADDR, USRP_B000_OFFSETS["serial"], B000X_SERIAL_LEN )); //extract the name mb_eeprom["name"] = bytes_to_string(iface.read_eeprom( - B1XX_EEPROM_ADDR, USRP_B1XX_OFFSETS["name"], NAME_MAX_LEN + B000_EEPROM_ADDR, USRP_B000_OFFSETS["name"], NAME_MAX_LEN )); } -static void store_b1xx(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ +static void store_b000(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ //store the serial if (mb_eeprom.has_key("serial")) iface.write_eeprom( - B1XX_EEPROM_ADDR, USRP_B1XX_OFFSETS["serial"], - string_to_bytes(mb_eeprom["serial"], B1XXX_SERIAL_LEN) + B000_EEPROM_ADDR, USRP_B000_OFFSETS["serial"], + string_to_bytes(mb_eeprom["serial"], B000X_SERIAL_LEN) ); //store the name if (mb_eeprom.has_key("name")) iface.write_eeprom( - B1XX_EEPROM_ADDR, USRP_B1XX_OFFSETS["name"], + B000_EEPROM_ADDR, USRP_B000_OFFSETS["name"], string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN) ); } @@ -181,14 +181,14 @@ mboard_eeprom_t::mboard_eeprom_t(void){ mboard_eeprom_t::mboard_eeprom_t(i2c_iface &iface, map_type map){ switch(map){ - case MAP_NXXX: load_nxxx(*this, iface); break; - case MAP_B1XX: load_b1xx(*this, iface); break; + case MAP_N100: load_n100(*this, iface); break; + case MAP_B000: load_b000(*this, iface); break; } } void mboard_eeprom_t::commit(i2c_iface &iface, map_type map){ switch(map){ - case MAP_NXXX: store_nxxx(*this, iface); break; - case MAP_B1XX: store_b1xx(*this, iface); break; + case MAP_N100: store_n100(*this, iface); break; + case MAP_B000: store_b000(*this, iface); break; } } |