Skip to content

Commit 580970c

Browse files
Use Stream::setTimeout to specify I2C TO (#263)
Use the existing Arduino Stream method of setTimeout to set the Wire I2C timeout delay. Fixes #260
1 parent c13bb1e commit 580970c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

libraries/Wire/Wire.cpp renamed to libraries/Wire/src/Wire.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ size_t TwoWire::requestFrom(uint8_t address, size_t quantity, bool stopBit) {
201201
return 0;
202202
}
203203

204-
_buffLen = i2c_read_blocking_until(_i2c, address, _buff, quantity, !stopBit, make_timeout_time_ms(50));
204+
_buffLen = i2c_read_blocking_until(_i2c, address, _buff, quantity, !stopBit, make_timeout_time_ms(_timeout));
205205
if (_buffLen == PICO_ERROR_GENERIC) {
206206
_buffLen = 0;
207207
}
@@ -292,7 +292,7 @@ uint8_t TwoWire::endTransmission(bool stopBit) {
292292
return _probe(_addr, _sda, _scl, _clkHz) ? 0 : 2;
293293
} else {
294294
auto len = _buffLen;
295-
auto ret = i2c_write_blocking_until(_i2c, _addr, _buff, _buffLen, !stopBit, make_timeout_time_ms(50));
295+
auto ret = i2c_write_blocking_until(_i2c, _addr, _buff, _buffLen, !stopBit, make_timeout_time_ms(_timeout));
296296
_buffLen = 0;
297297
return (ret == len) ? 0 : 4;
298298
}
File renamed without changes.

0 commit comments

Comments
 (0)