Skip to content

Commit 3804723

Browse files
committed
Fix I2C lock-up when endTransmission() is called with empty txBuffer
close #121
1 parent 028b420 commit 3804723

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libraries/Wire/Wire_nRF52.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ uint8_t TwoWire::endTransmission(bool stopBit)
214214
while(!_p_twim->EVENTS_TXSTARTED && !_p_twim->EVENTS_ERROR);
215215
_p_twim->EVENTS_TXSTARTED = 0x0UL;
216216

217-
while(!_p_twim->EVENTS_LASTTX && !_p_twim->EVENTS_ERROR);
217+
if (txBuffer.available()) {
218+
while(!_p_twim->EVENTS_LASTTX && !_p_twim->EVENTS_ERROR);
219+
}
218220
_p_twim->EVENTS_LASTTX = 0x0UL;
219221

220222
if (stopBit || _p_twim->EVENTS_ERROR)

0 commit comments

Comments
 (0)