Revision b96088b6 host/lib/usrp/usrp1/usrp1_iface.cpp
| b/host/lib/usrp/usrp1/usrp1_iface.cpp | ||
|---|---|---|
| 109 | 109 |
******************************************************************/ |
| 110 | 110 |
static const size_t max_i2c_data_bytes = 64; |
| 111 | 111 |
|
| 112 |
//TODO: make this handle EEPROM page sizes. right now you can't write over a 16-byte boundary. |
|
| 113 |
//to accomplish this you'll have to have addr offset as a separate parameter. |
|
| 114 |
|
|
| 112 | 115 |
void write_i2c(boost::uint8_t addr, const byte_vector_t &bytes) |
| 113 | 116 |
{
|
| 114 | 117 |
UHD_ASSERT_THROW(bytes.size() < max_i2c_data_bytes); |
| 115 | 118 |
|
| 116 | 119 |
unsigned char buff[max_i2c_data_bytes]; |
| 117 |
std::copy(bytes.begin(), bytes.end(), buff);
|
|
| 120 |
std::copy(bytes.begin(), bytes.end(), buff); |
|
| 118 | 121 |
|
| 119 |
int ret = _ctrl_transport->usrp_control_write(VRQ_I2C_WRITE, |
|
| 120 |
addr & 0xff, |
|
| 121 |
0, |
|
| 122 |
buff, |
|
| 123 |
bytes.size()); |
|
| 122 |
int ret = _ctrl_transport->usrp_i2c_write(addr & 0xff, |
|
| 123 |
buff, |
|
| 124 |
bytes.size()); |
|
| 124 | 125 |
|
| 125 | 126 |
// TODO throw and catch i2c failures during eeprom read |
| 126 | 127 |
if (iface_debug && (ret < 0)) |
| ... | ... | |
| 132 | 133 |
UHD_ASSERT_THROW(num_bytes < max_i2c_data_bytes); |
| 133 | 134 |
|
| 134 | 135 |
unsigned char buff[max_i2c_data_bytes]; |
| 135 |
int ret = _ctrl_transport->usrp_control_read(VRQ_I2C_READ, |
|
| 136 |
addr & 0xff, |
|
| 137 |
0, |
|
| 138 |
buff, |
|
| 139 |
num_bytes); |
|
| 136 |
int ret = _ctrl_transport->usrp_i2c_read(addr & 0xff, |
|
| 137 |
buff, |
|
| 138 |
num_bytes); |
|
| 140 | 139 |
|
| 141 | 140 |
// TODO throw and catch i2c failures during eeprom read |
| 142 | 141 |
if (iface_debug && ((ret < 0) || (unsigned)ret < (num_bytes))) {
|
Also available in: Unified diff