From c0c24d7f524735d73ad11752b483c2f615c72775 Mon Sep 17 00:00:00 2001 From: Steve Evans Date: Sun, 22 Sep 2024 13:35:53 +0100 Subject: [PATCH] Don't consider a prior I2C NACK to indicate the bus to be busy (#13917) --- src/main/drivers/mcu/at32/bus_i2c_atbsp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/drivers/mcu/at32/bus_i2c_atbsp.c b/src/main/drivers/mcu/at32/bus_i2c_atbsp.c index 26a94e409a5..52cd0d959f2 100644 --- a/src/main/drivers/mcu/at32/bus_i2c_atbsp.c +++ b/src/main/drivers/mcu/at32/bus_i2c_atbsp.c @@ -245,7 +245,8 @@ bool i2cBusy(I2CDevice device, bool *error) *error = pHandle->error_code; } - if (pHandle->error_code == I2C_OK) { + // I2C_ERR_ACKFAIL indicates that the last access wasn't acknowledged, but doesn't mean the bus is busy + if ((pHandle->error_code == I2C_OK) || (pHandle->error_code == I2C_ERR_ACKFAIL)) { if (i2c_flag_get(pHandle->i2cx, I2C_BUSYF_FLAG) == SET) { return true; }