Skip to content

Commit afc25a6

Browse files
committed
arduino#1476 Add timout in twi_stop(void) method.
1 parent 4028bdc commit afc25a6

File tree

1 file changed

+9
-0
lines changed
  • hardware/arduino/avr/libraries/Wire/src/utility

1 file changed

+9
-0
lines changed

hardware/arduino/avr/libraries/Wire/src/utility/twi.c

+9
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,16 @@ void twi_stop(void)
402402

403403
// wait for stop condition to be exectued on bus
404404
// TWINT is not set after a stop condition!
405+
uint32_t counter = 0;
405406
while(TWCR & _BV(TWSTO)){
407+
counter++;
408+
if((twi_timeout_ms > 0) && (counter >= 25000)) {
409+
// timeout
410+
twi_init();
411+
412+
return;
413+
}
414+
406415
continue;
407416
}
408417

0 commit comments

Comments
 (0)