Skip to content

Commit 08334ff

Browse files
ABOSTMfpistm
authored andcommitted
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 <[email protected]>
1 parent e0cf26e commit 08334ff

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: libraries/Wire/src/Wire.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ void TwoWire::end(void)
117117
void TwoWire::setClock(uint32_t frequency)
118118
{
119119
i2c_setTiming(&_i2c, frequency);
120+
if (_i2c.isMaster == 0) {
121+
i2c_attachSlaveTxEvent(&_i2c, onRequestService);
122+
i2c_attachSlaveRxEvent(&_i2c, onReceiveService);
123+
}
120124
}
121125

122126
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint32_t iaddress, uint8_t isize, uint8_t sendStop)

0 commit comments

Comments
 (0)