Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i2c: properly handle bus errors #98

Merged
merged 1 commit into from
May 29, 2020
Merged

Conversation

hlukasz
Copy link

@hlukasz hlukasz commented May 3, 2020

In send_byte() wait for TX fifo empty before returning Ok. It would be
better to wait for end of transmission, but there is no such field in
I2C status register.

In recv_byte() return Err if error condition detected while waiting for
byte.

Before starting new transaction ensure that both TX and RX buffers are
empty. There are some corner cases where something may be there.

src/i2c.rs Outdated
while self.i2c.isr.read().rxne().bit_is_clear() {}
while self.i2c.isr.read().rxne().bit_is_clear() {
let isr = self.i2c.isr.read();
if isr.berr().bit_is_set() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about reusing the whole error handling block? send_byte uses almost the same thing. It can be separated to the function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been done in #102, I think, so rebase should take care of this comment.

@hannobraun
Copy link
Contributor

Thank your for the PR, @hlukasz, and thanks for the review, @almusil.

I just merged a more recent pull request (#102) that conflicts with this one. Sorry about that! Can you rebase, @hlukasz?

@hlukasz
Copy link
Author

hlukasz commented May 28, 2020

Done. Basically only one change left after rebasing, but I think that it is still worth to add.

@hannobraun
Copy link
Contributor

Thank you, @hlukasz!

@hannobraun hannobraun merged commit 46b50b5 into stm32-rs:master May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants