Skip to content

Commit 4f53e51

Browse files
Wire: Define default timeout settings in Wire.h
Previously, these were implicit in the default values of some global variables. Now, the default timeout is defined in Wire.h, which: - Makes it easier to change later - Allows sketches to detect the default timeout value
1 parent 3bd4d11 commit 4f53e51

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

libraries/Wire/src/Wire.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ void TwoWire::begin(void)
6464
twi_init();
6565
twi_attachSlaveTxEvent(onRequestService); // default callback must exist
6666
twi_attachSlaveRxEvent(onReceiveService); // default callback must exist
67+
68+
twi_setTimeoutInMicros(WIRE_DEFAULT_TIMEOUT, WIRE_DEFAULT_RESET_WITH_TIMEOUT);
6769
}
6870

6971
void TwoWire::begin(uint8_t address)

libraries/Wire/src/Wire.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
// and clearWireTimeoutFlag()
3535
#define WIRE_HAS_TIMEOUT 1
3636

37+
// When not configured, these settings are used for the timeout
38+
#define WIRE_DEFAULT_TIMEOUT 0
39+
#define WIRE_DEFAULT_RESET_WITH_TIMEOUT false
40+
3741
class TwoWire : public Stream
3842
{
3943
private:

0 commit comments

Comments
 (0)