Skip to content

Commit

Permalink
STM32: Check for NACK (#6687)
Browse files Browse the repository at this point in the history
Signed-off-by: Timofey Titovets <[email protected]>
  • Loading branch information
nefelim4ag authored Sep 22, 2024
1 parent 8a5801a commit d9236f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/stm32/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 2 additions & 0 deletions src/stm32/stm32f0_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit d9236f1

Please sign in to comment.