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

answer about short I2C responses #23

Open
tlyu opened this issue Jul 27, 2022 · 1 comment
Open

answer about short I2C responses #23

tlyu opened this issue Jul 27, 2022 · 1 comment

Comments

@tlyu
Copy link

tlyu commented Jul 27, 2022

This is not exactly an issue (except maybe of documentation in a comment), but more of a possible answer to a question that @obra indirectly posed in wire-protocol.c:

                // Nothing in the ring buffer is the same thing as all keys released
                // Really, we _should_ be able to return a single byte here, but
                // Jesse is too clueless to figure out how to get I2C to signal
                // a 'short' response

I think the short answer is that you're not clueless: a target transmitter doesn't have a conforming way to shorten its responses beyond what the controller expects.

A target can maybe prolong a response by violating the I2C protocol and continuing to transmit after the controller NACKs a byte, if it can prevent the controller from asserting a STOP or repeated START condition. (The AVR TWI hardware module doesn't seem to support doing this.) If the target is honoring the I2C protocol, the controller determines the length of the response. (If the target stops transmitting early, the controller will receive 0xFF bytes until it gives up and NACKs and then sends a STOP or repeated START. The controller has no way to distinguish this from the target deliberately transmitting 0xFF bytes.)

I guess a target could also cause a bus error by violating the protocol in some other way (maybe by asserting a STOP or START before the bus is free?) and force a short read that way. Again, I think the AVR TWI hardware module doesn't support doing that.

Does this explanation seem to fit the observations? (I might be able to do some testing to confirm the finer details, if you have additional questions.)

@obra
Copy link
Member

obra commented Jul 28, 2022 via email

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

No branches or pull requests

2 participants