aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/dboard_eeprom.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-02-22 10:57:53 -0800
committerJosh Blum <josh@joshknows.com>2011-02-22 10:57:53 -0800
commitde35e125bc6e09fbe4da60f8f18390c137c77c43 (patch)
tree733f6d4411388f45a1dce6e79e556a14f439213a /host/lib/usrp/dboard_eeprom.cpp
parent814a5c40c6fbaedba3dafabbe30d00a05af6a274 (diff)
downloaduhd-de35e125bc6e09fbe4da60f8f18390c137c77c43.tar.gz
uhd-de35e125bc6e09fbe4da60f8f18390c137c77c43.tar.bz2
uhd-de35e125bc6e09fbe4da60f8f18390c137c77c43.zip
uhd: simplify dboard eeprom code by passing iface into load/store
Diffstat (limited to 'host/lib/usrp/dboard_eeprom.cpp')
-rw-r--r--host/lib/usrp/dboard_eeprom.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/host/lib/usrp/dboard_eeprom.cpp b/host/lib/usrp/dboard_eeprom.cpp
index 60d13548a..c47390bf8 100644
--- a/host/lib/usrp/dboard_eeprom.cpp
+++ b/host/lib/usrp/dboard_eeprom.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -95,7 +95,14 @@ static boost::uint8_t checksum(const byte_vector_t &bytes){
return boost::uint8_t(sum);
}
-dboard_eeprom_t::dboard_eeprom_t(const byte_vector_t &bytes){
+dboard_eeprom_t::dboard_eeprom_t(void){
+ id = dboard_id_t::none();
+ serial = "";
+}
+
+void dboard_eeprom_t::load(i2c_iface &iface, boost::uint8_t addr){
+ byte_vector_t bytes = iface.read_eeprom(addr, 0, DB_EEPROM_CLEN);
+
if (_dboard_eeprom_debug){
for (size_t i = 0; i < bytes.size(); i++){
std::cout << boost::format(
@@ -127,7 +134,7 @@ dboard_eeprom_t::dboard_eeprom_t(const byte_vector_t &bytes){
}
}
-byte_vector_t dboard_eeprom_t::get_eeprom_bytes(void){
+void dboard_eeprom_t::store(i2c_iface &iface, boost::uint8_t addr){
byte_vector_t bytes(DB_EEPROM_CLEN, 0); //defaults to all zeros
bytes[DB_EEPROM_MAGIC] = DB_EEPROM_MAGIC_VALUE;
@@ -141,9 +148,6 @@ byte_vector_t dboard_eeprom_t::get_eeprom_bytes(void){
//load the checksum
bytes[DB_EEPROM_CHKSUM] = checksum(bytes);
- return bytes;
-}
-size_t dboard_eeprom_t::num_bytes(void){
- return DB_EEPROM_CLEN;
+ iface.write_eeprom(addr, 0, bytes);
}