From 0050ba9ac7e4cfef2b3a0f7a8d8b03c9774447ed Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Thu, 12 Dec 2019 16:27:21 -0800 Subject: [PATCH] imxrt:lpi2c ensure that on an error status reflects it. After an error the STOP detect was overwriting the previous error status. --- arch/arm/src/imxrt/imxrt_lpi2c.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/imxrt/imxrt_lpi2c.c b/arch/arm/src/imxrt/imxrt_lpi2c.c index 11a523a1c1..2a90c165e8 100644 --- a/arch/arm/src/imxrt/imxrt_lpi2c.c +++ b/arch/arm/src/imxrt/imxrt_lpi2c.c @@ -1364,6 +1364,10 @@ static int imxrt_lpi2c_isr_process(struct imxrt_lpi2c_priv_s *priv) #ifndef CONFIG_I2C_POLLED if (priv->intstate == INTSTATE_WAITING) { + /* Update Status once at the end */ + + priv->status = status; + /* inform the thread that transfer is complete * and wake it up */ @@ -1372,6 +1376,7 @@ static int imxrt_lpi2c_isr_process(struct imxrt_lpi2c_priv_s *priv) priv->intstate = INTSTATE_DONE; } #else + priv->status = status; priv->intstate = INTSTATE_DONE; #endif /* Mark that this transaction stopped */ @@ -1412,6 +1417,10 @@ static int imxrt_lpi2c_isr_process(struct imxrt_lpi2c_priv_s *priv) #ifndef CONFIG_I2C_POLLED if (priv->intstate == INTSTATE_WAITING) { + /* Update Status once at the end */ + + priv->status = status; + /* inform the thread that transfer is complete * and wake it up */ @@ -1420,11 +1429,11 @@ static int imxrt_lpi2c_isr_process(struct imxrt_lpi2c_priv_s *priv) priv->intstate = INTSTATE_DONE; } #else + priv->status = status; priv->intstate = INTSTATE_DONE; #endif } - priv->status = status; return OK; }