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

Add new i2c includes for idf 5.2 #290

Merged
merged 2 commits into from
Apr 9, 2024

Conversation

teamplayer3
Copy link
Contributor

@teamplayer3 teamplayer3 commented Mar 6, 2024

Challenges

  • new implementation of i2c does not expose commands interface, so the transaction function in the esp-idf-hal couldn't be used anymore.
    1. Now is the question to keep the legacy implementations for a I2CDriver implementation with the transaction interface. This will lead to #include hal/i2c_types.h because the legacy header exposes types from the hal. The new i2c implementation could be used for an extra I2CBusDriver.
    2. The other solution would be to request a public interface to a transactional operation in the new i2c implementation in esp-idf.

#include "driver/i2c_types.h"
#include "driver/i2c_master.h"
#include "driver/i2c_slave.h"
#else
#include "driver/i2c.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the old driver available with 5.2+?

Copy link
Contributor Author

@teamplayer3 teamplayer3 Mar 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read this The legacy driver can't coexist with the new driver. Include i2c.h to use the legacy driver or the other two headers to use the new driver. Please keep in mind that the legacy driver is now deprecated and will be removed in future. in the doc. Consequently it's a problem to include both if I understand it correctly. Or is this not a problem when we use bindgen?

Additionally it's a general problem to implement the embedded_hal for the new i2c impl. when the interface is not any more available. Should the trait implemented with unimplented!() and give a hint to use the legacy driver?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its the same with the gptimer headers. Creating the bindgen itself is not a problem. Also "compiling" works, but as soon as you will run both, there will be runtime check at startup that enforces it and will crash your app. So its ok to have them both in esp-idf-sys, but a wrapper driver in esp-idf-hal would need to be conditionally included

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@teamplayer3 Not sure if it was clear: to merge this, we need you to remove the #else statement.

@teamplayer3 teamplayer3 requested a review from ivmarkov April 9, 2024 06:22
@ivmarkov ivmarkov merged commit 50bb071 into esp-rs:master Apr 9, 2024
3 of 4 checks passed
@teamplayer3 teamplayer3 deleted the include-new-i2c-interface branch April 9, 2024 06:56
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

Successfully merging this pull request may close these issues.

3 participants