diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2013-01-15 19:34:35 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2013-01-15 19:34:35 +0000 |
commit | 730db924c92de6db6c3115325984f740ef300dd4 (patch) | |
tree | 64b1e52a7acf72eef41d1fd12e5e9717682d943c | |
parent | f51c87b9160dd89810bac7579246ae14f61e0a8b (diff) | |
download | lufa-730db924c92de6db6c3115325984f740ef300dd4.tar.gz lufa-730db924c92de6db6c3115325984f740ef300dd4.tar.bz2 lufa-730db924c92de6db6c3115325984f740ef300dd4.zip |
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).
-rw-r--r-- | LUFA/DoxygenPages/ChangeLog.txt | 1 | ||||
-rw-r--r-- | LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.c | 6 |
2 files changed, 5 insertions, 2 deletions
diff --git a/LUFA/DoxygenPages/ChangeLog.txt b/LUFA/DoxygenPages/ChangeLog.txt index b46efd09c..e06e235e1 100644 --- a/LUFA/DoxygenPages/ChangeLog.txt +++ b/LUFA/DoxygenPages/ChangeLog.txt @@ -40,6 +40,7 @@ * - Fixed hardware race condition that could cause failed device enumerations for AVR8 and UC3 architectures (thanks to Mike Beyhs) * - Fixed incorrect Minimus board LED definitions (thanks to Joonas Lahtinen) * - Fixed incorrect ordering of the linker options in the build system causing link failures in some cases + * - Fixed bug in the TWI peripheral driver for the AVR8 devices causing incorrect failure codes to be returned in some cases (thanks to ) * - Library Applications: * - Fixed broken RESET_TOGGLES_LIBUSB_COMPAT compile time option in the AVRISP-MKII project * - Fixed incompatibility in the CDC class bootloader on some systems (thanks to Sylvain Munaut) 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)) |