esp32/machine_i2c: Set default for new I2C driver at esp-idf >= v5.5.2.#19256
Open
robert-hh wants to merge 2 commits into
Open
esp32/machine_i2c: Set default for new I2C driver at esp-idf >= v5.5.2.#19256robert-hh wants to merge 2 commits into
robert-hh wants to merge 2 commits into
Conversation
Contributor
Author
|
@dpgeorge The code path for the new I2C driver still contains code to support esp-idf versions < 5.5.2. For code clarity, that can be removed and a Pre-Compiler check added that flags an error is the esp-idf version is < v5.5.2. Likewise the old driver path could get a check for esp-idf < v6.0. |
|
Code size report: |
By default the new I2C driver is enabled for esp-idf version >= 5.5.2. With v5.5.2 and up the the additional bus probing is not needed any more. It was needed because transfers to a non-existing address caused an error message to be printed instead of just returning an error code. With esp-idf v5.5.2 it returns just an error code. For 0-length writes as being used by i2c.scan(), an additional code path using i2c_master_execute_defined_operations() is needed to avoid an error message. Tested with a Generic ESP32 and esp-idf v5.5.1, v5.5.2 and v5.5.4. Tested as well using the new driver with v5.5.1. Tested V5.5.2 with Generic ESP32, ESP32S2, ESP32S3, ESP32C2, ESP32C3, ESP32C5, ESP32C6, ESP32P4. Driving an external device as I2C controller. There is a slight inconsistency: reading 0 bytes from a non-existing address return an empty bytes object and does not raise an error. Writing 0 bytes to a non-existing address returns an error. That case is used by i2c.scan(). Signed-off-by: robert-hh <robert@hammelrath.com>
If the new driver is enabled for versions previous to v5.5.2, an error is raised and compilation aborted. Signed-off-by: robert-hh <robert@hammelrath.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
With v5.5.2 and up the the additional bus probing is not needed any more. It was needed because transfers to a non-existing address caused an error message to be printed instead of just returning an error code. With esp-idf v5.5.2 it returns just an error code. For 0-length writes as being used by i2c.scan(), an additional code path using i2c_master_execute_defined_operations() is needed to avoid an error message.
By default the new I2C driver is enabled for esp-idf version >= 5.5.2.
There is a slight inconsistency: reading 0 bytes from a non-existing address return an empty bytes object and does not raise an error. Writing 0 bytes to a non-existing address returns an error. That case is used by i2c.scan().
Testing
Tested with a Generic ESP32 and esp-idf v5.5.1, v5.5.2 and v5.5.4. Tested as well using the new driver with v5.5.1.
Tested V5.5.2 with Generic ESP32, ESP32S2, ESP32S3, ESP32C2, ESP32C3, ESP32C5, ESP32C6, ESP32P4. Driving an external device as I2C controller.
Trade-offs and Alternatives
There is still a problem with I2CTarget mode. But that exists back to v5.4.2 and did not get worse with v5.5.2 and v5.5.4
Generative AI
I did not use generative AI tools when creating this PR.