Skip to content

Commit

Permalink
fix(Wire): in case of slave, (re)enable interrupt when configuring clock
Browse files Browse the repository at this point in the history
Because TwoWire::setClock() calls i2c_setTiming()
which disable/(re)enable I2C Hardware,
it is necessary to restore interrupts.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
  • Loading branch information
ABOSTM authored and fpistm committed Aug 30, 2022
1 parent e0cf26e commit 08334ff
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libraries/Wire/src/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 08334ff

Please sign in to comment.