Skip to content

Commit c4623f4

Browse files
Disable Wire slave interrupt on ::end (#621)
Fixes #620
1 parent 1c85a1c commit c4623f4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

libraries/Wire/src/Wire.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ void TwoWire::begin(uint8_t addr) {
132132
irq_set_exclusive_handler(irqNo, i2c_hw_index(_i2c) == 0 ? _handler0 : _handler1);
133133
irq_set_enabled(irqNo, true);
134134

135-
136135
gpio_set_function(_sda, GPIO_FUNC_I2C);
137136
gpio_pull_up(_sda);
138137
gpio_set_function(_scl, GPIO_FUNC_I2C);
@@ -192,7 +191,15 @@ void TwoWire::end() {
192191
// ERROR
193192
return;
194193
}
194+
195+
if (_slave) {
196+
int irqNo = I2C0_IRQ + i2c_hw_index(_i2c);
197+
irq_remove_handler(irqNo, i2c_hw_index(_i2c) == 0 ? _handler0 : _handler1);
198+
irq_set_enabled(irqNo, false);
199+
}
200+
195201
i2c_deinit(_i2c);
202+
196203
pinMode(_sda, INPUT);
197204
pinMode(_scl, INPUT);
198205
_running = false;

0 commit comments

Comments
 (0)