aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimofey Titovets <nefelim4ag@gmail.com>2024-09-23 01:24:29 +0200
committerGitHub <noreply@github.com>2024-09-22 19:24:29 -0400
commitd9236f1c20ea603e456f959d0914b72b1d730e86 (patch)
tree59435347421e9b39a17f9a511e4ce58aac0b4941 /src
parent8a5801a204a2491bcf64127e6ade1c24875c7b74 (diff)
downloadkutter-d9236f1c20ea603e456f959d0914b72b1d730e86.tar.gz
kutter-d9236f1c20ea603e456f959d0914b72b1d730e86.tar.xz
kutter-d9236f1c20ea603e456f959d0914b72b1d730e86.zip
STM32: Check for NACK (#6687)
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/stm32/i2c.c2
-rw-r--r--src/stm32/stm32f0_i2c.c2
2 files changed, 4 insertions, 0 deletions
diff --git a/src/stm32/i2c.c b/src/stm32/i2c.c
index f5bbd01d..4bb8b105 100644
--- a/src/stm32/i2c.c
+++ b/src/stm32/i2c.c
@@ -97,6 +97,8 @@ i2c_wait(I2C_TypeDef *i2c, uint32_t set, uint32_t clear, uint32_t timeout)
uint32_t sr1 = i2c->SR1;
if ((sr1 & set) == set && (sr1 & clear) == 0)
return sr1;
+ if (sr1 & I2C_SR1_AF)
+ shutdown("I2C NACK error encountered");
if (!timer_is_before(timer_read_time(), timeout))
shutdown("i2c timeout");
}
diff --git a/src/stm32/stm32f0_i2c.c b/src/stm32/stm32f0_i2c.c
index 597b4846..1382cd86 100644
--- a/src/stm32/stm32f0_i2c.c
+++ b/src/stm32/stm32f0_i2c.c
@@ -166,6 +166,8 @@ i2c_wait(I2C_TypeDef *i2c, uint32_t set, uint32_t timeout)
uint32_t isr = i2c->ISR;
if (isr & set)
return isr;
+ if (isr & I2C_ISR_NACKF)
+ shutdown("I2C NACK error encountered");
if (!timer_is_before(timer_read_time(), timeout))
shutdown("i2c timeout");
}