aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/Peripheral
diff options
context:
space:
mode:
Diffstat (limited to 'LUFA/Drivers/Peripheral')
-rw-r--r--LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.c b/LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.c
index 9cfad9af4..e7629d5b7 100644
--- a/LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.c
+++ b/LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.c
@@ -45,7 +45,7 @@ uint8_t TWI_StartTransmission(const uint8_t SlaveAddress,
TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN));
TimeoutRemaining = (TimeoutMS * 100);
- while (TimeoutRemaining-- && !(BusCaptured))
+ while (TimeoutRemaining && !(BusCaptured))
{
if (TWCR & (1 << TWINT))
{
@@ -65,6 +65,7 @@ uint8_t TWI_StartTransmission(const uint8_t SlaveAddress,
}
_delay_us(10);
+ TimeoutRemaining--;
}
if (!(TimeoutRemaining))
@@ -77,12 +78,13 @@ uint8_t TWI_StartTransmission(const uint8_t SlaveAddress,
TWCR = ((1 << TWINT) | (1 << TWEN));
TimeoutRemaining = (TimeoutMS * 100);
- while (TimeoutRemaining--)
+ while (TimeoutRemaining)
{
if (TWCR & (1 << TWINT))
break;
_delay_us(10);
+ TimeoutRemaining--;
}
if (!(TimeoutRemaining))