From 2feef77d3a04bb4281d70fdeff9c1cdf458b6320 Mon Sep 17 00:00:00 2001 From: Alexander Williams Date: Thu, 11 Apr 2024 18:23:58 -0700 Subject: [PATCH] [testutils,i2c] Stop waiting upon receiving a NACK End the transaction wait if the controller receives a NACK. Signed-off-by: Alexander Williams --- sw/device/lib/testing/i2c_testutils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sw/device/lib/testing/i2c_testutils.c b/sw/device/lib/testing/i2c_testutils.c index 07c09f1abd43b..3f3d1070c118b 100644 --- a/sw/device/lib/testing/i2c_testutils.c +++ b/sw/device/lib/testing/i2c_testutils.c @@ -432,8 +432,11 @@ status_t i2c_testutils_wait_host_idle(const dif_i2c_t *i2c) { status_t i2c_testutils_wait_transaction_finish(const dif_i2c_t *i2c) { dif_i2c_status_t status; + bool controller_halted = false; do { TRY(dif_i2c_get_status(i2c, &status)); - } while (!status.fmt_fifo_empty); + TRY(dif_i2c_irq_is_pending(i2c, kDifI2cIrqControllerHalt, + &controller_halted)); + } while (!status.fmt_fifo_empty || controller_halted); return OK_STATUS(); }