machine,nrf528,i2c: fix multiple resume-stop on bus error #5007
+3
−3
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.
As already shown in #4998, in case of an error the i2c TX method in nrf528xx loops until a stop condition is fulfilled. In case of an error, a resume-stop command on bus will be called, so the bus can finish its work and exit the loop afterwards - no "hard" return in case of error is done and needed.
With the current code, after the first error occurs, each loop checks again for an error and practically (assuming the error is not gone) sends the resume-stop sequence again and again until the stop state is reached (triggered by the first resume-stop-sequence) and the loop is finished. On long run with existing errors, e.g the device is not connected on the bus, and cyclic calls (e.g. each 10 seconds) this leads reproducible to hang of the loop with the bme280 driver.
The provided code change improves the code for this topics: