mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
check TWWC (Write Collision Flag) bit after setting TWDR
as suggested by @earlyprogrammer in #2173, to ensure TWDR value is set if there is a write collision
This commit is contained in:
parent
48ff3a10ad
commit
c71f5e9f88
@ -167,7 +167,9 @@ uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sen
|
|||||||
// up. Also, don't enable the START interrupt. There may be one pending from the
|
// up. Also, don't enable the START interrupt. There may be one pending from the
|
||||||
// repeated start that we sent outselves, and that would really confuse things.
|
// repeated start that we sent outselves, and that would really confuse things.
|
||||||
twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR
|
twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR
|
||||||
TWDR = twi_slarw;
|
do {
|
||||||
|
TWDR = twi_slarw;
|
||||||
|
} while(TWCR & _BV(TWWC));
|
||||||
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
|
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -247,7 +249,9 @@ uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait
|
|||||||
// up. Also, don't enable the START interrupt. There may be one pending from the
|
// up. Also, don't enable the START interrupt. There may be one pending from the
|
||||||
// repeated start that we sent outselves, and that would really confuse things.
|
// repeated start that we sent outselves, and that would really confuse things.
|
||||||
twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR
|
twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR
|
||||||
TWDR = twi_slarw;
|
do {
|
||||||
|
TWDR = twi_slarw;
|
||||||
|
} while(TWCR & _BV(TWWC));
|
||||||
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
|
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user