Skip to content

Commit 69c8cd9

Browse files
authored
Merge pull request arduino#528 from maidnl/increase_wire_timeout_lcd_issue
Increase I2C timeout to ensure compatibility with LCD oled displays
2 parents 2922e19 + e1a4a1e commit 69c8cd9

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

libraries/Wire/Wire.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ TwoWire::TwoWire(int scl, int sda, WireAddressMode_t am /*= ADDRESS_MODE_7_BITS*
191191
is_master(true),
192192
is_sci(false),
193193
address_mode(am),
194-
timeout_us(1000),
194+
timeout_us(WIRE_DEFAULT_TIMEOUT_US),
195195
transmission_begun(false),
196196
data_too_long(false),
197197
rx_index(0),

libraries/Wire/Wire.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include "r_i2c_master_api.h"
3434
#include "r_i2c_slave_api.h"
3535

36+
#define WIRE_DEFAULT_TIMEOUT_US (100000)
37+
3638
extern "C" {
3739
void i2c_callback(i2c_master_callback_args_t *p_args);
3840
}
@@ -124,7 +126,7 @@ class TwoWire : public arduino::HardwareI2C {
124126
void onRequest( void (*)(void) );
125127

126128
void setBusStatus(WireStatus_t);
127-
/* set timeout in us for I2C communication (default is 1000 us)
129+
/* set timeout in us for I2C communication
128130
the second parameter has been added for compatibility but it has no effect
129131
130132
Please note: on uno R4 (both minima and wifi) the timeout has only effect
@@ -133,7 +135,7 @@ class TwoWire : public arduino::HardwareI2C {
133135
On Portenta C33 however timeout is used in both cases (with or without
134136
I2C pull up) because at low level the NACK does not immediately stop the I2C
135137
communication. */
136-
void setWireTimeout(unsigned int _timeout_us = 1000, bool reset_on_timeout = false);
138+
void setWireTimeout(unsigned int _timeout_us = WIRE_DEFAULT_TIMEOUT_US, bool reset_on_timeout = false);
137139

138140
inline size_t write(unsigned long n) { return write((uint8_t)n); }
139141
inline size_t write(long n) { return write((uint8_t)n); }

0 commit comments

Comments
 (0)