Fixed bug in the TWI peripheral driver for the AVR8 devices causing incorrect failure codes to be returned in some cases (thanks to Peter K).
This commit is contained in:
parent
f51c87b916
commit
730db924c9
2 changed files with 5 additions and 2 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue