Commit 91138312 authored by Alex Tsamakos's avatar Alex Tsamakos Committed by Sandeep Mistry

Fix I2C lock-up when endTransmission() is called with empty txBuffer

The problem (at least in the case of the I2C scanner that I had to deal with) was related to an empty tx buffer, so the LASTTX event never occurres, resulting into an endless loop.
parent 41f2aadb
...@@ -222,7 +222,9 @@ uint8_t TwoWire::endTransmission(bool stopBit) ...@@ -222,7 +222,9 @@ uint8_t TwoWire::endTransmission(bool stopBit)
while(!_p_twim->EVENTS_TXSTARTED && !_p_twim->EVENTS_ERROR); while(!_p_twim->EVENTS_TXSTARTED && !_p_twim->EVENTS_ERROR);
_p_twim->EVENTS_TXSTARTED = 0x0UL; _p_twim->EVENTS_TXSTARTED = 0x0UL;
if (txBuffer.available()) {
while(!_p_twim->EVENTS_LASTTX && !_p_twim->EVENTS_ERROR); while(!_p_twim->EVENTS_LASTTX && !_p_twim->EVENTS_ERROR);
}
_p_twim->EVENTS_LASTTX = 0x0UL; _p_twim->EVENTS_LASTTX = 0x0UL;
if (stopBit || _p_twim->EVENTS_ERROR) if (stopBit || _p_twim->EVENTS_ERROR)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment