summaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2013-07-24 17:46:04 -0700
committerJosh Blum <josh@joshknows.com>2013-07-24 17:46:04 -0700
commit0aeac60394420de1952ebc230a6fa2f8593df80a (patch)
treef08d6ca1555dc2df15a79c3da6d32cad9a6224d7 /host/lib/usrp
parent690637f78685b2979a9f128ce3c82149b5421c46 (diff)
downloaduhd-0aeac60394420de1952ebc230a6fa2f8593df80a.tar.gz
uhd-0aeac60394420de1952ebc230a6fa2f8593df80a.tar.bz2
uhd-0aeac60394420de1952ebc230a6fa2f8593df80a.zip
uhd: allow for 16 bit i2c and eeprom addrs
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/b100/dboard_iface.cpp8
-rw-r--r--host/lib/usrp/b200/b200_iface.cpp10
-rw-r--r--host/lib/usrp/common/fx2_ctrl.cpp8
-rw-r--r--host/lib/usrp/cores/i2c_core_100.cpp4
-rw-r--r--host/lib/usrp/cores/i2c_core_100_wb32.cpp12
-rw-r--r--host/lib/usrp/cores/i2c_core_200.cpp4
-rw-r--r--host/lib/usrp/e100/dboard_iface.cpp8
-rw-r--r--host/lib/usrp/e100/e100_ctrl.cpp4
-rw-r--r--host/lib/usrp/usrp1/dboard_iface.cpp8
-rw-r--r--host/lib/usrp/usrp1/usrp1_iface.cpp4
-rw-r--r--host/lib/usrp/usrp2/dboard_iface.cpp8
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.cpp4
12 files changed, 45 insertions, 37 deletions
diff --git a/host/lib/usrp/b100/dboard_iface.cpp b/host/lib/usrp/b100/dboard_iface.cpp
index 25604da72..efbba1c4c 100644
--- a/host/lib/usrp/b100/dboard_iface.cpp
+++ b/host/lib/usrp/b100/dboard_iface.cpp
@@ -73,8 +73,8 @@ public:
void set_gpio_debug(unit_t, int);
boost::uint16_t read_gpio(unit_t);
- void write_i2c(boost::uint8_t, const byte_vector_t &);
- byte_vector_t read_i2c(boost::uint8_t, size_t);
+ void write_i2c(boost::uint16_t, const byte_vector_t &);
+ byte_vector_t read_i2c(boost::uint16_t, size_t);
void write_spi(
unit_t unit,
@@ -219,11 +219,11 @@ boost::uint32_t b100_dboard_iface::read_write_spi(
/***********************************************************************
* I2C
**********************************************************************/
-void b100_dboard_iface::write_i2c(boost::uint8_t addr, const byte_vector_t &bytes){
+void b100_dboard_iface::write_i2c(boost::uint16_t addr, const byte_vector_t &bytes){
return _i2c_iface->write_i2c(addr, bytes);
}
-byte_vector_t b100_dboard_iface::read_i2c(boost::uint8_t addr, size_t num_bytes){
+byte_vector_t b100_dboard_iface::read_i2c(boost::uint16_t addr, size_t num_bytes){
return _i2c_iface->read_i2c(addr, num_bytes);
}
diff --git a/host/lib/usrp/b200/b200_iface.cpp b/host/lib/usrp/b200/b200_iface.cpp
index 5173beacb..933df8499 100644
--- a/host/lib/usrp/b200/b200_iface.cpp
+++ b/host/lib/usrp/b200/b200_iface.cpp
@@ -211,18 +211,18 @@ public:
}
- void write_i2c(boost::uint8_t addr, const byte_vector_t &bytes)
+ void write_i2c(boost::uint16_t addr, const byte_vector_t &bytes)
{
throw uhd::not_implemented_error("b200 write i2c");
}
- byte_vector_t read_i2c(boost::uint8_t addr, size_t num_bytes)
+ byte_vector_t read_i2c(boost::uint16_t addr, size_t num_bytes)
{
throw uhd::not_implemented_error("b200 read i2c");
}
- void write_eeprom(boost::uint8_t addr, boost::uint8_t offset,
+ void write_eeprom(boost::uint16_t addr, boost::uint16_t offset,
const byte_vector_t &bytes)
{
fx3_control_write(B200_VREQ_EEPROM_WRITE,
@@ -232,8 +232,8 @@ public:
}
byte_vector_t read_eeprom(
- boost::uint8_t addr,
- boost::uint8_t offset,
+ boost::uint16_t addr,
+ boost::uint16_t offset,
size_t num_bytes
){
byte_vector_t recv_bytes(num_bytes);
diff --git a/host/lib/usrp/common/fx2_ctrl.cpp b/host/lib/usrp/common/fx2_ctrl.cpp
index 1f9cb84b3..6111efea9 100644
--- a/host/lib/usrp/common/fx2_ctrl.cpp
+++ b/host/lib/usrp/common/fx2_ctrl.cpp
@@ -411,8 +411,8 @@ public:
}
byte_vector_t read_eeprom(
- boost::uint8_t addr,
- boost::uint8_t offset,
+ boost::uint16_t addr,
+ boost::uint16_t offset,
size_t num_bytes
){
this->write_i2c(addr, byte_vector_t(1, offset));
@@ -432,7 +432,7 @@ public:
static const bool iface_debug = false;
static const size_t max_i2c_data_bytes = 64;
- void write_i2c(boost::uint8_t addr, const byte_vector_t &bytes)
+ void write_i2c(boost::uint16_t addr, const byte_vector_t &bytes)
{
UHD_ASSERT_THROW(bytes.size() < max_i2c_data_bytes);
@@ -442,7 +442,7 @@ public:
uhd::runtime_error("USRP: failed i2c write");
}
- byte_vector_t read_i2c(boost::uint8_t addr, size_t num_bytes)
+ byte_vector_t read_i2c(boost::uint16_t addr, size_t num_bytes)
{
UHD_ASSERT_THROW(num_bytes < max_i2c_data_bytes);
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;
diff --git a/host/lib/usrp/e100/dboard_iface.cpp b/host/lib/usrp/e100/dboard_iface.cpp
index 532b2dc9e..07d0049c8 100644
--- a/host/lib/usrp/e100/dboard_iface.cpp
+++ b/host/lib/usrp/e100/dboard_iface.cpp
@@ -73,8 +73,8 @@ public:
void set_gpio_debug(unit_t, int);
boost::uint16_t read_gpio(unit_t);
- void write_i2c(boost::uint8_t, const byte_vector_t &);
- byte_vector_t read_i2c(boost::uint8_t, size_t);
+ void write_i2c(boost::uint16_t, const byte_vector_t &);
+ byte_vector_t read_i2c(boost::uint16_t, size_t);
void write_spi(
unit_t unit,
@@ -219,11 +219,11 @@ boost::uint32_t e100_dboard_iface::read_write_spi(
/***********************************************************************
* I2C
**********************************************************************/
-void e100_dboard_iface::write_i2c(boost::uint8_t addr, const byte_vector_t &bytes){
+void e100_dboard_iface::write_i2c(boost::uint16_t addr, const byte_vector_t &bytes){
return _i2c_iface->write_i2c(addr, bytes);
}
-byte_vector_t e100_dboard_iface::read_i2c(boost::uint8_t addr, size_t num_bytes){
+byte_vector_t e100_dboard_iface::read_i2c(boost::uint16_t addr, size_t num_bytes){
return _i2c_iface->read_i2c(addr, num_bytes);
}
diff --git a/host/lib/usrp/e100/e100_ctrl.cpp b/host/lib/usrp/e100/e100_ctrl.cpp
index c9c86c8af..cdbbff6dd 100644
--- a/host/lib/usrp/e100/e100_ctrl.cpp
+++ b/host/lib/usrp/e100/e100_ctrl.cpp
@@ -144,7 +144,7 @@ public:
::close(_node_fd);
}
- void write_i2c(boost::uint8_t addr, const byte_vector_t &bytes){
+ void write_i2c(boost::uint16_t addr, const byte_vector_t &bytes){
byte_vector_t rw_bytes(bytes);
//setup the message
@@ -163,7 +163,7 @@ public:
UHD_ASSERT_THROW(::ioctl(_node_fd, I2C_RDWR, &data) >= 0);
}
- byte_vector_t read_i2c(boost::uint8_t addr, size_t num_bytes){
+ byte_vector_t read_i2c(boost::uint16_t addr, size_t num_bytes){
byte_vector_t bytes(num_bytes);
//setup the message
diff --git a/host/lib/usrp/usrp1/dboard_iface.cpp b/host/lib/usrp/usrp1/dboard_iface.cpp
index 39850d5d1..4c3141d9e 100644
--- a/host/lib/usrp/usrp1/dboard_iface.cpp
+++ b/host/lib/usrp/usrp1/dboard_iface.cpp
@@ -113,8 +113,8 @@ public:
void set_gpio_debug(unit_t, int);
boost::uint16_t read_gpio(unit_t);
- void write_i2c(boost::uint8_t, const byte_vector_t &);
- byte_vector_t read_i2c(boost::uint8_t, size_t);
+ void write_i2c(boost::uint16_t, const byte_vector_t &);
+ byte_vector_t read_i2c(boost::uint16_t, size_t);
void write_spi(unit_t unit,
const spi_config_t &config,
@@ -386,13 +386,13 @@ boost::uint32_t usrp1_dboard_iface::read_write_spi(unit_t unit,
/***********************************************************************
* I2C
**********************************************************************/
-void usrp1_dboard_iface::write_i2c(boost::uint8_t addr,
+void usrp1_dboard_iface::write_i2c(boost::uint16_t addr,
const byte_vector_t &bytes)
{
return _iface->write_i2c(addr, bytes);
}
-byte_vector_t usrp1_dboard_iface::read_i2c(boost::uint8_t addr,
+byte_vector_t usrp1_dboard_iface::read_i2c(boost::uint16_t addr,
size_t num_bytes)
{
return _iface->read_i2c(addr, num_bytes);
diff --git a/host/lib/usrp/usrp1/usrp1_iface.cpp b/host/lib/usrp/usrp1/usrp1_iface.cpp
index 16b747e45..9301721aa 100644
--- a/host/lib/usrp/usrp1/usrp1_iface.cpp
+++ b/host/lib/usrp/usrp1/usrp1_iface.cpp
@@ -104,11 +104,11 @@ public:
/*******************************************************************
* I2C
******************************************************************/
- void write_i2c(boost::uint8_t addr, const byte_vector_t &bytes){
+ void write_i2c(boost::uint16_t addr, const byte_vector_t &bytes){
return _ctrl_transport->write_i2c(addr, bytes);
}
- byte_vector_t read_i2c(boost::uint8_t addr, size_t num_bytes){
+ byte_vector_t read_i2c(boost::uint16_t addr, size_t num_bytes){
return _ctrl_transport->read_i2c(addr, num_bytes);
}
diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp
index edd9ef242..8f2d0f0dc 100644
--- a/host/lib/usrp/usrp2/dboard_iface.cpp
+++ b/host/lib/usrp/usrp2/dboard_iface.cpp
@@ -60,8 +60,8 @@ public:
void set_gpio_debug(unit_t, int);
boost::uint16_t read_gpio(unit_t);
- void write_i2c(boost::uint8_t, const byte_vector_t &);
- byte_vector_t read_i2c(boost::uint8_t, size_t);
+ void write_i2c(boost::uint16_t, const byte_vector_t &);
+ byte_vector_t read_i2c(boost::uint16_t, size_t);
void set_clock_rate(unit_t, double);
double get_clock_rate(unit_t);
@@ -229,11 +229,11 @@ boost::uint32_t usrp2_dboard_iface::read_write_spi(
/***********************************************************************
* I2C
**********************************************************************/
-void usrp2_dboard_iface::write_i2c(boost::uint8_t addr, const byte_vector_t &bytes){
+void usrp2_dboard_iface::write_i2c(boost::uint16_t addr, const byte_vector_t &bytes){
return _i2c_iface->write_i2c(addr, bytes);
}
-byte_vector_t usrp2_dboard_iface::read_i2c(boost::uint8_t addr, size_t num_bytes){
+byte_vector_t usrp2_dboard_iface::read_i2c(boost::uint16_t addr, size_t num_bytes){
return _i2c_iface->read_i2c(addr, num_bytes);
}
diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp
index 8804433e7..3b230ca69 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.cpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.cpp
@@ -240,7 +240,7 @@ public:
/***********************************************************************
* I2C
**********************************************************************/
- void write_i2c(boost::uint8_t addr, const byte_vector_t &buf){
+ void write_i2c(boost::uint16_t addr, const byte_vector_t &buf){
//setup the out data
usrp2_ctrl_data_t out_data = usrp2_ctrl_data_t();
out_data.id = htonl(USRP2_CTRL_ID_WRITE_THESE_I2C_VALUES_BRO);
@@ -258,7 +258,7 @@ public:
UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_COOL_IM_DONE_I2C_WRITE_DUDE);
}
- byte_vector_t read_i2c(boost::uint8_t addr, size_t num_bytes){
+ byte_vector_t read_i2c(boost::uint16_t addr, size_t num_bytes){
//setup the out data
usrp2_ctrl_data_t out_data = usrp2_ctrl_data_t();
out_data.id = htonl(USRP2_CTRL_ID_DO_AN_I2C_READ_FOR_ME_BRO);