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 not working anymore #34

Closed
dkm opened this issue Jul 20, 2020 · 2 comments · Fixed by #35
Closed

I2C not working anymore #34

dkm opened this issue Jul 20, 2020 · 2 comments · Fixed by #35

Comments

@dkm
Copy link
Contributor

dkm commented Jul 20, 2020

After last changes in I2C, it seems the logic of the busy_wait macro is not correct.
I've been able to patch it locally and will push a clean proposal tomorrow (@thejpster asked me to file an issue).

Basically, checking for BusBusy everywhere is not correct as it will always be set between START and STOP, so during a transaction, we should not return an error (that's what I'm currently seeing).

Previous code was basically adapted from stm32f30x-hal and I see that the busy_wait macro has been changed (no more flag as parameter) and is not really busy_waiting on anything but the BUSY bit. The macro is now wrapped in loop{}. Was is not better to have the busy wait inside the macro ? Maybe there's something I'm not seeing here.

The original code was doing things like:

  • wait for busbsy to be clear
  • do something
  • wait for busy to be clear
  • do something
    ....

I see that previous code was wrongly looking at all mcs bits without waiting for busy to be clear, but maybe the cleaning went too far ? At least with my patch that reverts back the logic above, my application is working correctly again.

dkm added a commit to dkm/tm4c-hal that referenced this issue Jul 21, 2020
Restore previous logic where a transaction starts by waiting for the controler
to be ready and the busy available and then wait for the controller to be ready
at intermediate step.
Modify the i2c_busy_wait to implement this behavior.

fix rust-embedded-community#34
dkm added a commit to dkm/tm4c-hal that referenced this issue Jul 21, 2020
Restore previous logic where a transaction starts by waiting for the controler
to be ready and the busy available and then wait for the controller to be ready
at intermediate step.
Modify the i2c_busy_wait to implement this behavior.

fix rust-embedded-community#34
dkm added a commit to dkm/tm4c-hal that referenced this issue Jul 21, 2020
Restore previous logic where a transaction starts by waiting for the controler
to be ready and the bus available and then only wait for the controller to be ready
at intermediate step (not the bus to be available as it will be busy).
Modify the i2c_busy_wait to implement this behavior.

fix rust-embedded-community#34
dkm added a commit to dkm/tm4c-hal that referenced this issue Jul 21, 2020
Restore previous logic where a transaction starts by waiting for the controler
to be ready and the bus available and then only wait for the controller to be ready
at intermediate step (not the bus to be available as it will be busy).
Modify the i2c_busy_wait to implement this behavior.

fix rust-embedded-community#34
@thejpster
Copy link
Member

@dtwood any thoughts on this one?

dkm added a commit to dkm/tm4c-hal that referenced this issue Jul 23, 2020
Restore previous logic where a transaction starts by waiting for the controler
to be ready and the bus available and then only wait for the controller to be ready
at intermediate step (not the bus to be available as it will be busy).
Modify the i2c_busy_wait to implement this behavior.

fix rust-embedded-community#34
dkm added a commit to dkm/tm4c-hal that referenced this issue Jul 27, 2020
Restore previous logic where a transaction starts by waiting for the controler
to be ready and the bus available and then only wait for the controller to be ready
at intermediate step (not the bus to be available as it will be busy).
Modify the i2c_busy_wait to implement this behavior.

fix rust-embedded-community#34
@thejpster
Copy link
Member

@dtwood?

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 a pull request may close this issue.

2 participants