From de35e125bc6e09fbe4da60f8f18390c137c77c43 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 22 Feb 2011 10:57:53 -0800 Subject: uhd: simplify dboard eeprom code by passing iface into load/store --- host/lib/usrp/dboard_eeprom.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'host/lib/usrp/dboard_eeprom.cpp') 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); } -- cgit v1.2.3