Skip to content

Conversation

HendryKaak
Copy link

@HendryKaak HendryKaak commented Jan 16, 2020

This is related to: #748 (review)

When this timeout is triggered, I2C_OK was returned. This happens because in the
loop above, it checks for (delta < I2C_TIMEOUT_TICK), so it breaks out of the
loop as soon as delta == I2C_TIMEOUT_TICK. Then, the if below checks for
(delta > I2C_TIMEOUT_TICK), which is not yet false. Since the hardware reports
no errors either, I2C_OK was returned.

By using >= in the if rather than >, this is fixed and I2C_TIMEOUT is now
returned instead.

When this timeout is triggered, I2C_OK was returned. This happens because in the
loop above, it checks for `(delta < I2C_TIMEOUT_TICK)`, so it breaks out of the
loop as soon as `delta == I2C_TIMEOUT_TICK`. Then, the if below checks for
`(delta > I2C_TIMEOUT_TICK)`, which is not yet false. Since the hardware reports
no errors either, I2C_OK was returned.

By using `>=` in the if rather than `>`, this is fixed and I2C_TIMEOUT is now
returned instead.
@fpistm fpistm added the fix 🩹 Bug fix label Jan 16, 2020
@fpistm fpistm merged commit 120cea1 into stm32duino:master Jan 17, 2020
@HendryKaak
Copy link
Author

@fpistm Thanks :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix 🩹 Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants