From 08334ff809f1c059bce497365d9763967b3466e5 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Fri, 26 Aug 2022 18:33:02 +0200 Subject: [PATCH] fix(Wire): in case of slave, (re)enable interrupt when configuring clock Because TwoWire::setClock() calls i2c_setTiming() which disable/(re)enable I2C Hardware, it is necessary to restore interrupts. Signed-off-by: Alexandre Bourdiol --- libraries/Wire/src/Wire.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/Wire/src/Wire.cpp b/libraries/Wire/src/Wire.cpp index b95cb04778..dc9d14ba30 100644 --- a/libraries/Wire/src/Wire.cpp +++ b/libraries/Wire/src/Wire.cpp @@ -117,6 +117,10 @@ void TwoWire::end(void) void TwoWire::setClock(uint32_t frequency) { i2c_setTiming(&_i2c, frequency); + if (_i2c.isMaster == 0) { + i2c_attachSlaveTxEvent(&_i2c, onRequestService); + i2c_attachSlaveRxEvent(&_i2c, onReceiveService); + } } uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint32_t iaddress, uint8_t isize, uint8_t sendStop)