From 0aeac60394420de1952ebc230a6fa2f8593df80a Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 24 Jul 2013 17:46:04 -0700 Subject: uhd: allow for 16 bit i2c and eeprom addrs --- host/lib/usrp/cores/i2c_core_100.cpp | 4 ++-- host/lib/usrp/cores/i2c_core_100_wb32.cpp | 12 ++++++++++-- host/lib/usrp/cores/i2c_core_200.cpp | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'host/lib/usrp/cores') diff --git a/host/lib/usrp/cores/i2c_core_100.cpp b/host/lib/usrp/cores/i2c_core_100.cpp index ceeb3f518..9e8a226f2 100644 --- a/host/lib/usrp/cores/i2c_core_100.cpp +++ b/host/lib/usrp/cores/i2c_core_100.cpp @@ -70,7 +70,7 @@ public: } void write_i2c( - boost::uint8_t addr, + boost::uint16_t addr, const byte_vector_t &bytes ){ _iface->poke16(REG_I2C_DATA, (addr << 1) | 0); //addr and read bit (0) @@ -93,7 +93,7 @@ public: } byte_vector_t read_i2c( - boost::uint8_t addr, + boost::uint16_t addr, size_t num_bytes ){ byte_vector_t bytes; diff --git a/host/lib/usrp/cores/i2c_core_100_wb32.cpp b/host/lib/usrp/cores/i2c_core_100_wb32.cpp index b38d5b4bc..df6e6ff72 100644 --- a/host/lib/usrp/cores/i2c_core_100_wb32.cpp +++ b/host/lib/usrp/cores/i2c_core_100_wb32.cpp @@ -72,7 +72,7 @@ public: } void write_i2c( - boost::uint8_t addr, + boost::uint16_t addr, const byte_vector_t &bytes ){ _iface->poke32(REG_I2C_DATA, (addr << 1) | 0); //addr and read bit (0) @@ -95,7 +95,7 @@ public: } byte_vector_t read_i2c( - boost::uint8_t addr, + boost::uint16_t addr, size_t num_bytes ){ byte_vector_t bytes; @@ -119,6 +119,14 @@ public: return bytes; } + //override read_eeprom so we can write once, read all N bytes + //the default implementation calls read i2c once per byte + byte_vector_t read_eeprom(boost::uint16_t addr, boost::uint16_t offset, size_t num_bytes) + { + this->write_i2c(addr, byte_vector_t(1, offset)); + return this->read_i2c(addr, num_bytes); + } + private: void i2c_wait(void) { for (size_t i = 0; i < 10; i++) diff --git a/host/lib/usrp/cores/i2c_core_200.cpp b/host/lib/usrp/cores/i2c_core_200.cpp index 1b882c54a..6010ac5a2 100644 --- a/host/lib/usrp/cores/i2c_core_200.cpp +++ b/host/lib/usrp/cores/i2c_core_200.cpp @@ -73,7 +73,7 @@ public: } void write_i2c( - boost::uint8_t addr, + boost::uint16_t addr, const byte_vector_t &bytes ){ this->poke(REG_I2C_WR_DATA, (addr << 1) | 0); //addr and read bit (0) @@ -96,7 +96,7 @@ public: } byte_vector_t read_i2c( - boost::uint8_t addr, + boost::uint16_t addr, size_t num_bytes ){ byte_vector_t bytes; -- cgit v1.2.3