Skip to content

Commit 68fe5f1

Browse files
committed
twi_stop() should use the same timeout as everywhere else
1 parent d8c03ff commit 68fe5f1

File tree

1 file changed

+2
-3
lines changed
  • libraries/Wire/src/utility

1 file changed

+2
-3
lines changed

Diff for: libraries/Wire/src/utility/twi.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,9 @@ void twi_stop(void)
394394

395395
// wait for stop condition to be exectued on bus
396396
// TWINT is not set after a stop condition!
397-
uint32_t counter = 0;
397+
unit32_t startMicros = micros();
398398
while(TWCR & _BV(TWSTO)){
399-
counter++;
400-
if((twi_timeout_us > 0ul) && (counter >= 25000)) {
399+
if((twi_timeout_us > 0ul) && (micros() - startMicros > twi_timeout_us)) {
401400
twi_handleTimeout();
402401
return;
403402
}

0 commit comments

Comments
 (0)