Skip to content

Commit

Permalink
Wire.cpp: add exit condition to timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Wagner Frederik (DES DOS SW ESW EPE) authored and Wagner Frederik (DES DOS SW ESW EPE) committed Dec 2, 2024
1 parent 0731922 commit 79f6158
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions libraries/Wire/src/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,15 @@ uint8_t TwoWire::requestFrom(
timeout = WIRE_COMMUNICATION_TIMEOUT;
// wait for ACK or timeout incase no ACK is received, a time-based wait-state is added since XMC
// devices run at variable frequencies
while (((XMC_I2C_CH_GetStatusFlag(XMC_I2C_config->channel) &
XMC_I2C_CH_STATUS_FLAG_ACK_RECEIVED) == 0U) ||
timeout == 0) {
while ((XMC_I2C_CH_GetStatusFlag(XMC_I2C_config->channel) &
XMC_I2C_CH_STATUS_FLAG_ACK_RECEIVED) == 0U) {
delay(1);
timeout--;
if(timeout==0)
{
Serial.println("Warning Timeout");
break;
}
}

for (uint8_t count = 0; count < (quantity - 1); count++) {
Expand Down

0 comments on commit 79f6158

Please sign in to comment.