Disable Wire slave interrupt on ::end (#621)

Fixes #620
This commit is contained in:
Earle F. Philhower, III 2022-06-10 11:42:04 -07:00 committed by GitHub
parent 1c85a1ca52
commit c4623f4297
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -132,7 +132,6 @@ void TwoWire::begin(uint8_t addr) {
irq_set_exclusive_handler(irqNo, i2c_hw_index(_i2c) == 0 ? _handler0 : _handler1);
irq_set_enabled(irqNo, true);
gpio_set_function(_sda, GPIO_FUNC_I2C);
gpio_pull_up(_sda);
gpio_set_function(_scl, GPIO_FUNC_I2C);
@ -192,7 +191,15 @@ void TwoWire::end() {
// ERROR
return;
}
if (_slave) {
int irqNo = I2C0_IRQ + i2c_hw_index(_i2c);
irq_remove_handler(irqNo, i2c_hw_index(_i2c) == 0 ? _handler0 : _handler1);
irq_set_enabled(irqNo, false);
}
i2c_deinit(_i2c);
pinMode(_sda, INPUT);
pinMode(_scl, INPUT);
_running = false;