aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/b200/b200_mb_eeprom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/b200/b200_mb_eeprom.cpp')
-rw-r--r--host/lib/usrp/b200/b200_mb_eeprom.cpp56
1 files changed, 25 insertions, 31 deletions
diff --git a/host/lib/usrp/b200/b200_mb_eeprom.cpp b/host/lib/usrp/b200/b200_mb_eeprom.cpp
index 5a37cc9c1..a83dce189 100644
--- a/host/lib/usrp/b200/b200_mb_eeprom.cpp
+++ b/host/lib/usrp/b200/b200_mb_eeprom.cpp
@@ -7,7 +7,6 @@
#include "b200_impl.hpp"
#include <uhd/usrp/mboard_eeprom.hpp>
#include <uhdlib/utils/eeprom_utils.hpp>
-
#include <unordered_map>
using namespace uhd;
@@ -27,7 +26,7 @@ struct eeprom_field_t
// firmware and bootloader code.
// EEPROM map information is duplicated in b2xx_fx3_utils.cpp
-constexpr uint16_t SIGNATURE_ADDR = 0x0000;
+constexpr uint16_t SIGNATURE_ADDR = 0x0000;
constexpr size_t SIGNATURE_LENGTH = 4;
constexpr auto EXPECTED_MAGIC = "45568"; // 0xB200
@@ -38,15 +37,15 @@ constexpr uint16_t REV1_BASE_ADDR = 0x7F00;
constexpr size_t REV1_LENGTH = 46;
const std::unordered_map<std::string, eeprom_field_t> B200_REV1_MAP = {
- {"magic", {0, 2}},
- {"eeprom_revision", {2, 2}},
- {"eeprom_compat", {4, 2}},
- {"vendor_id", {6, 2}},
- {"product_id", {8, 2}},
- {"revision", {10, 2}},
- {"product", {12, 2}},
- {"name", {14, NAME_MAX_LEN}},
- {"serial", {14 + NAME_MAX_LEN, SERIAL_LEN}},
+ {"magic", {0, 2}},
+ {"eeprom_revision", {2, 2}},
+ {"eeprom_compat", {4, 2}},
+ {"vendor_id", {6, 2}},
+ {"product_id", {8, 2}},
+ {"revision", {10, 2}},
+ {"product", {12, 2}},
+ {"name", {14, NAME_MAX_LEN}},
+ {"serial", {14 + NAME_MAX_LEN, SERIAL_LEN}},
// pad of 210 bytes
};
@@ -56,10 +55,10 @@ constexpr size_t REV0_LENGTH = 36;
const std::unordered_map<std::string, eeprom_field_t> B200_REV0_MAP = {
// front pad of 220 bytes
- {"revision", {0, 2}},
- {"product", {2, 2}},
- {"name", {4, NAME_MAX_LEN}},
- {"serial", {4 + NAME_MAX_LEN, SERIAL_LEN}},
+ {"revision", {0, 2}},
+ {"product", {2, 2}},
+ {"name", {4, NAME_MAX_LEN}},
+ {"serial", {4 + NAME_MAX_LEN, SERIAL_LEN}},
};
constexpr int UNKNOWN_REV = -1;
@@ -82,8 +81,7 @@ int _get_rev(uhd::i2c_iface::sptr iface)
byte_vector_t _get_eeprom(uhd::i2c_iface::sptr iface)
{
const auto rev = _get_rev(iface);
- if (rev == UNKNOWN_REV)
- {
+ if (rev == UNKNOWN_REV) {
return byte_vector_t();
}
@@ -93,7 +91,7 @@ byte_vector_t _get_eeprom(uhd::i2c_iface::sptr iface)
return iface->read_eeprom(addr >> 8, addr & 0xFF, length);
}
-}
+} // namespace
mboard_eeprom_t b200_impl::get_mb_eeprom(uhd::i2c_iface::sptr iface)
{
@@ -106,8 +104,7 @@ mboard_eeprom_t b200_impl::get_mb_eeprom(uhd::i2c_iface::sptr iface)
auto eeprom_map = (rev == 0) ? B200_REV0_MAP : B200_REV1_MAP;
- for (const auto &element : eeprom_map)
- {
+ for (const auto& element : eeprom_map) {
// There is an assumption here that fields of length 2 are uint16's and
// lengths other than 2 are strings. Update this code if that
// assumption changes.
@@ -115,23 +112,22 @@ mboard_eeprom_t b200_impl::get_mb_eeprom(uhd::i2c_iface::sptr iface)
bytes.begin() + element.second.offset + element.second.length);
mb_eeprom[element.first] = (element.second.length == 2)
- ? uint16_bytes_to_string(element_bytes)
- : bytes_to_string(element_bytes);
+ ? uint16_bytes_to_string(element_bytes)
+ : bytes_to_string(element_bytes);
}
if (rev > 0) {
- if (mb_eeprom["magic"] != EXPECTED_MAGIC)
- {
+ if (mb_eeprom["magic"] != EXPECTED_MAGIC) {
throw uhd::runtime_error(
str(boost::format("EEPROM magic value mismatch. Device returns %s, but "
"should have been %s.")
- % mb_eeprom["magic"] % EXPECTED_MAGIC));
+ % mb_eeprom["magic"] % EXPECTED_MAGIC));
}
if (mb_eeprom["eeprom_compat"] != EXPECTED_COMPAT) {
throw uhd::runtime_error(
str(boost::format("EEPROM compat value mismatch. Device returns %s, but "
"should have been %s.")
- % mb_eeprom["eeprom_compat"] % EXPECTED_COMPAT));
+ % mb_eeprom["eeprom_compat"] % EXPECTED_COMPAT));
}
}
@@ -140,13 +136,11 @@ mboard_eeprom_t b200_impl::get_mb_eeprom(uhd::i2c_iface::sptr iface)
void b200_impl::set_mb_eeprom(const mboard_eeprom_t& mb_eeprom)
{
- const auto rev = _get_rev(_iface);
+ const auto rev = _get_rev(_iface);
auto eeprom_map = (rev == 0) ? B200_REV0_MAP : B200_REV1_MAP;
auto base_addr = (rev == 0) ? REV0_BASE_ADDR : REV1_BASE_ADDR;
- for (const auto& key : mb_eeprom.keys())
- {
- if (eeprom_map.find(key) == eeprom_map.end())
- {
+ for (const auto& key : mb_eeprom.keys()) {
+ if (eeprom_map.find(key) == eeprom_map.end()) {
UHD_LOG_WARNING(
LOG_ID, "Unknown key in mb_eeprom during set_mb_eeprom: " << key);
continue;