Skip to content

Commit 5fd4736

Browse files
Handle swapped Wire IRQs properly (#1608)
When we swap the Wire objects, we need the i2c0 IRQ shim to call Wire1.onIRQ, not the usual Wire.onIRQ. Same for i2c1 IRQ shim. Fixes #1607
1 parent 67a07ed commit 5fd4736

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

libraries/Wire/src/Wire.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,27 @@ void TwoWire::begin() {
108108
}
109109

110110
static void _handler0() {
111+
#if defined(__WIRE0_DEVICE)
112+
if (__WIRE0_DEVICE == i2c0) {
113+
Wire.onIRQ();
114+
} else {
115+
Wire1.onIRQ();
116+
}
117+
#else
111118
Wire.onIRQ();
119+
#endif
112120
}
113121

114122
static void _handler1() {
123+
#if defined(__WIRE1_DEVICE)
124+
if (__WIRE1_DEVICE == i2c0) {
125+
Wire.onIRQ();
126+
} else {
127+
Wire1.onIRQ();
128+
}
129+
#else
115130
Wire1.onIRQ();
131+
#endif
116132
}
117133

118134
// Slave mode

0 commit comments

Comments
 (0)