Prevent starting a new I2C transmission before previous stop finishes. #737
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.
When a stop condition is generated by the I2C DMA (example), the code does not wait for the finish of the stop condition. However, the comments falsely indicate that there will be a spin-wait.
The I2C interface can get stuck if a new I2C transmission attempts to start while the previous stop condition is being generated. The new transaction will be inadvertently terminated by the previous stop condition. Subsequently, the I2C interface gets stuck. The following figure shows that a previous stop condition being generated can immediately terminate a new start condition, and after that the I2C interface is stuck.
Since ISRs should finish as quickly as possible, the fix should not let ISRs spin-wait in the interrupt handler until the stop condition finishes. Instead, the spin-wait should be placed before starting a new transmission.
The patch also removes incorrect comments that falsely indicate that the code will spin-wait until the stop condition finishes.