From b5af966d209b67535399b960cfe472aba4235d8f Mon Sep 17 00:00:00 2001 From: Frederik-Wagner Date: Mon, 9 Dec 2024 14:42:10 +0100 Subject: [PATCH] bugfix: change I2C ACK signal timeout condition --- libraries/Wire/src/Wire.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/Wire/src/Wire.cpp b/libraries/Wire/src/Wire.cpp index 983f04a0..1ab8ecf8 100644 --- a/libraries/Wire/src/Wire.cpp +++ b/libraries/Wire/src/Wire.cpp @@ -244,10 +244,12 @@ uint8_t TwoWire::requestFrom( // 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) { + XMC_I2C_CH_STATUS_FLAG_ACK_RECEIVED) == 0U)) { delay(1); timeout--; + if (timeout == 0) { + break; + } } for (uint8_t count = 0; count < (quantity - 1); count++) {