Unverified Commit 580970cd authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

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
parent c13bb1ec
...@@ -201,7 +201,7 @@ size_t TwoWire::requestFrom(uint8_t address, size_t quantity, bool stopBit) { ...@@ -201,7 +201,7 @@ size_t TwoWire::requestFrom(uint8_t address, size_t quantity, bool stopBit) {
return 0; return 0;
} }
_buffLen = i2c_read_blocking_until(_i2c, address, _buff, quantity, !stopBit, make_timeout_time_ms(50)); _buffLen = i2c_read_blocking_until(_i2c, address, _buff, quantity, !stopBit, make_timeout_time_ms(_timeout));
if (_buffLen == PICO_ERROR_GENERIC) { if (_buffLen == PICO_ERROR_GENERIC) {
_buffLen = 0; _buffLen = 0;
} }
...@@ -292,7 +292,7 @@ uint8_t TwoWire::endTransmission(bool stopBit) { ...@@ -292,7 +292,7 @@ uint8_t TwoWire::endTransmission(bool stopBit) {
return _probe(_addr, _sda, _scl, _clkHz) ? 0 : 2; return _probe(_addr, _sda, _scl, _clkHz) ? 0 : 2;
} else { } else {
auto len = _buffLen; auto len = _buffLen;
auto ret = i2c_write_blocking_until(_i2c, _addr, _buff, _buffLen, !stopBit, make_timeout_time_ms(50)); auto ret = i2c_write_blocking_until(_i2c, _addr, _buff, _buffLen, !stopBit, make_timeout_time_ms(_timeout));
_buffLen = 0; _buffLen = 0;
return (ret == len) ? 0 : 4; return (ret == len) ? 0 : 4;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment