From 038e7f78633c6980f8897c489e58936ff0ab90b5 Mon Sep 17 00:00:00 2001 From: "Wagner Frederik (DES DOS SW ESW EPE)" Date: Mon, 2 Dec 2024 10:23:09 +0100 Subject: [PATCH] Wire.cpp: add exit condition to timeout --- libraries/Wire/src/Wire.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libraries/Wire/src/Wire.cpp b/libraries/Wire/src/Wire.cpp index 983f04a0..3a2f04d7 100644 --- a/libraries/Wire/src/Wire.cpp +++ b/libraries/Wire/src/Wire.cpp @@ -243,11 +243,14 @@ 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++) {