diff options
author | Martin Braun <martin.braun@ettus.com> | 2020-03-02 15:25:13 -0800 |
---|---|---|
committer | atrnati <54334261+atrnati@users.noreply.github.com> | 2020-03-03 08:51:32 -0600 |
commit | 876d4150aa3da531ddd687b48afada6e43f79146 (patch) | |
tree | fd72a71419f4cd800d4e500cfcaded4dfc8dc367 /host/lib/usrp/usrp1/mb_eeprom.cpp | |
parent | 1393553d623bdf4ba40d5435c9719b6ce990d9ac (diff) | |
download | uhd-876d4150aa3da531ddd687b48afada6e43f79146.tar.gz uhd-876d4150aa3da531ddd687b48afada6e43f79146.tar.bz2 uhd-876d4150aa3da531ddd687b48afada6e43f79146.zip |
uhd: Apply clang-format against all .cpp and .hpp files in host/
Note: template_lvbitx.{cpp,hpp} need to be excluded from the list of
files that clang-format gets applied against.
Diffstat (limited to 'host/lib/usrp/usrp1/mb_eeprom.cpp')
-rw-r--r-- | host/lib/usrp/usrp1/mb_eeprom.cpp | 93 |
1 files changed, 44 insertions, 49 deletions
diff --git a/host/lib/usrp/usrp1/mb_eeprom.cpp b/host/lib/usrp/usrp1/mb_eeprom.cpp index 9b868fd4e..756a10395 100644 --- a/host/lib/usrp/usrp1/mb_eeprom.cpp +++ b/host/lib/usrp/usrp1/mb_eeprom.cpp @@ -5,22 +5,23 @@ // #include "usrp1_impl.hpp" -#include <uhdlib/utils/eeprom_utils.hpp> -#include <uhd/usrp/mboard_eeprom.hpp> #include <uhd/types/byte_vector.hpp> +#include <uhd/usrp/mboard_eeprom.hpp> +#include <uhdlib/utils/eeprom_utils.hpp> namespace { - const uint8_t USRP1_EEPROM_ADDR = 0x50; - const size_t USRP1_SERIAL_LEN = 8; +const uint8_t USRP1_EEPROM_ADDR = 0x50; +const size_t USRP1_SERIAL_LEN = 8; - //use char array so we dont need to attribute packed - struct usrp1_eeprom_map{ - unsigned char _r[221]; - unsigned char mcr[4]; - unsigned char name[NAME_MAX_LEN]; - unsigned char serial[USRP1_SERIAL_LEN]; - }; -} +// use char array so we dont need to attribute packed +struct usrp1_eeprom_map +{ + unsigned char _r[221]; + unsigned char mcr[4]; + unsigned char name[NAME_MAX_LEN]; + unsigned char serial[USRP1_SERIAL_LEN]; +}; +} // namespace using namespace uhd; using uhd::usrp::mboard_eeprom_t; @@ -29,62 +30,56 @@ mboard_eeprom_t usrp1_impl::get_mb_eeprom(uhd::i2c_iface::sptr iface) { mboard_eeprom_t mb_eeprom; - //extract the serial + // extract the serial mb_eeprom["serial"] = uhd::bytes_to_string(iface->read_eeprom( - USRP1_EEPROM_ADDR, offsetof(usrp1_eeprom_map, serial), USRP1_SERIAL_LEN - )); + USRP1_EEPROM_ADDR, offsetof(usrp1_eeprom_map, serial), USRP1_SERIAL_LEN)); - //extract the name + // extract the name mb_eeprom["name"] = uhd::bytes_to_string(iface->read_eeprom( - USRP1_EEPROM_ADDR, offsetof(usrp1_eeprom_map, name), NAME_MAX_LEN - )); + USRP1_EEPROM_ADDR, offsetof(usrp1_eeprom_map, name), NAME_MAX_LEN)); - //extract master clock rate as a 32-bit uint in Hz + // extract master clock rate as a 32-bit uint in Hz uint32_t master_clock_rate; const byte_vector_t rate_bytes = iface->read_eeprom( - USRP1_EEPROM_ADDR, offsetof(usrp1_eeprom_map, mcr), sizeof(master_clock_rate) - ); - std::copy( - rate_bytes.begin(), rate_bytes.end(), //input - reinterpret_cast<uint8_t *>(&master_clock_rate) //output + USRP1_EEPROM_ADDR, offsetof(usrp1_eeprom_map, mcr), sizeof(master_clock_rate)); + std::copy(rate_bytes.begin(), + rate_bytes.end(), // input + reinterpret_cast<uint8_t*>(&master_clock_rate) // output ); master_clock_rate = ntohl(master_clock_rate); - if (master_clock_rate > 1e6 and master_clock_rate < 1e9){ + if (master_clock_rate > 1e6 and master_clock_rate < 1e9) { mb_eeprom["mcr"] = std::to_string(master_clock_rate); - } - else mb_eeprom["mcr"] = ""; + } else + mb_eeprom["mcr"] = ""; return mb_eeprom; } -void usrp1_impl::set_mb_eeprom(const mboard_eeprom_t &mb_eeprom) +void usrp1_impl::set_mb_eeprom(const mboard_eeprom_t& mb_eeprom) { - auto &iface = _fx2_ctrl; + auto& iface = _fx2_ctrl; - //store the serial - if (mb_eeprom.has_key("serial")) iface->write_eeprom( - USRP1_EEPROM_ADDR, offsetof(usrp1_eeprom_map, serial), - string_to_bytes(mb_eeprom["serial"], USRP1_SERIAL_LEN) - ); + // store the serial + if (mb_eeprom.has_key("serial")) + iface->write_eeprom(USRP1_EEPROM_ADDR, + offsetof(usrp1_eeprom_map, serial), + string_to_bytes(mb_eeprom["serial"], USRP1_SERIAL_LEN)); - //store the name - if (mb_eeprom.has_key("name")) iface->write_eeprom( - USRP1_EEPROM_ADDR, offsetof(usrp1_eeprom_map, name), - string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN) - ); + // store the name + if (mb_eeprom.has_key("name")) + iface->write_eeprom(USRP1_EEPROM_ADDR, + offsetof(usrp1_eeprom_map, name), + string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN)); - //store the master clock rate as a 32-bit uint in Hz - if (mb_eeprom.has_key("mcr")){ + // store the master clock rate as a 32-bit uint in Hz + if (mb_eeprom.has_key("mcr")) { uint32_t master_clock_rate = uint32_t(std::stod(mb_eeprom["mcr"])); - master_clock_rate = htonl(master_clock_rate); + master_clock_rate = htonl(master_clock_rate); const byte_vector_t rate_bytes( - reinterpret_cast<const uint8_t *>(&master_clock_rate), - reinterpret_cast<const uint8_t *>(&master_clock_rate) - + sizeof(master_clock_rate) - ); + reinterpret_cast<const uint8_t*>(&master_clock_rate), + reinterpret_cast<const uint8_t*>(&master_clock_rate) + + sizeof(master_clock_rate)); iface->write_eeprom( - USRP1_EEPROM_ADDR, offsetof(usrp1_eeprom_map, mcr), rate_bytes - ); + USRP1_EEPROM_ADDR, offsetof(usrp1_eeprom_map, mcr), rate_bytes); } } - |