mirror of https://github.com/ARMmbed/mbed-os.git
Fix I2CEEBlockDevice read()
When reading a data block, the returned error codes from the I2C subsystem are different from normal single byte operations. We have to verify that the read-function for multiple bytes does return zero, because it returns "readBytes != expectedLength". Additionally, sync before trying to read from the eeprom as slow devices may not yet be ready to return data, especially with low-priced ones used with fast controllers.pull/12395/head
parent
d847f9f164
commit
97c00f1a22
|
@ -68,7 +68,9 @@ int I2CEEBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
|
|||
|
||||
_i2c->stop();
|
||||
|
||||
if (_i2c->read(_i2c_addr, static_cast<char *>(buffer), size) < 0) {
|
||||
_sync();
|
||||
|
||||
if (0 != _i2c->read(_i2c_addr, static_cast<char *>(buffer), size)) {
|
||||
return BD_ERROR_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue