1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-27 01:56:14 +01:00

Update I2CManager_AVR.h

Avoid loop in I2C_sendStart function.
This commit is contained in:
Neil McKechnie 2023-02-10 19:57:42 +00:00
parent c315895cd9
commit e498915b28

View File

@ -97,15 +97,10 @@ void I2CManagerClass::I2C_init()
void I2CManagerClass::I2C_sendStart() { void I2CManagerClass::I2C_sendStart() {
rxCount = 0; rxCount = 0;
txCount = 0; txCount = 0;
#if defined(I2C_EXTENDED_ADDRESSXXXXXXXXXXXX) // We may have already triggered a stop bit in the same run as this. To avoid
if (currentRequest->i2cAddress.muxNumber() != I2CMux_None) { // clearing that bit before the stop bit has been sent, we can either wait for
// Send request to multiplexer // it to complete or we can OR the bit onto the existing bits.
muxPhase = MuxPhase_PROLOG; // When start bit interrupt comes in, send SLA+W to MUX TWCR |= (1<<TWEN)|ENABLE_TWI_INTERRUPT|(1<<TWINT)|(1<<TWEA)|(1<<TWSTA); // Send Start
} else
muxPhase = 0;
#endif
while(TWCR & (1<<TWSTO)) {} // Wait for any in-progress stop to finish
TWCR = (1<<TWEN)|ENABLE_TWI_INTERRUPT|(1<<TWINT)|(1<<TWEA)|(1<<TWSTA); // Send Start
} }