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

handle repeated START condition correctly #18

Merged
merged 1 commit into from
May 28, 2022

Conversation

tlyu
Copy link

@tlyu tlyu commented May 28, 2022

Fixes #17.

The Atmel TWI interface can indicate an "unexpected STOP" when
there's a repeated START condition. Don't try to treat it as a bus
error, and don't wait for TWSTO to clear even if we do have a bus
error (and it's not officially documented that reading TWSTO is
meaningful).

Previously, a repeated START condition would cause the receiver
to loop waiting for TWSTO to clear. This meant it would miss
an address match in a repeated START condition, resulting in a
default NAK until the next START condition (which might clear
TWSTO?).

Signed-off-by: Taylor Yu [email protected]

The Atmel TWI interface can indicate an "unexpected STOP" when
there's a repeated START condition. Don't try to treat it as a bus
error, and don't wait for TWSTO to clear even if we do have a bus
error (and it's not officially documented that reading TWSTO is
meaningful).

Previously, a repeated START condition would cause the receiver
to loop waiting for TWSTO to clear. This meant it would miss
an address match in a repeated START condition, resulting in a
default NAK until the next START condition (which might clear
TWSTO?).

Signed-off-by: Taylor Yu <[email protected]>
@obra obra merged commit f840e91 into keyboardio:master May 28, 2022
@numist
Copy link
Collaborator

numist commented May 28, 2022

@tlyu: assuming you'd like blame attribution for your work, would you mind opening a PR for this upstream at numist/is31io7326_clone?

@tlyu
Copy link
Author

tlyu commented Jun 14, 2022

@tlyu: assuming you'd like blame attribution for your work, would you mind opening a PR for this upstream at numist/is31io7326_clone?

You are welcome to cherry-pick it for your repo if you like. (I think that will preserve author attribution unless you override some stuff in git.) I prefer not to make pull requests if I don't have a way to test the code. Note that there is also a related #20 that might make additional improvements in some situations.

@numist
Copy link
Collaborator

numist commented Jul 7, 2022

Done and done. Thanks!

@tlyu tlyu deleted the fix-repeated-start branch July 27, 2022 01:06
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.

TWI probably doesn't handle repeated start correctly
3 participants