added clock stretch yield, [issue 2162] fixed twi::status #6860
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Finally figured out what I'd done wrong with the earlier commit. No -a in a local commit!
issue #2162
Added devyte's PolledTimeout in a nested loop replacing the original WAIT_CLOCK_STRETCH(). The outer loop exits if SCL goes high or the loop times out. The inner loop does a yield() every 5ms while we're waiting.
Additionally, two small changes to twi::status that add a clock stretch test before we exit if we find SCL stuck low, and the trailing if (!write_start()) at the end is removed as it leaves SDA low, killing the bus.