-
Notifications
You must be signed in to change notification settings - Fork 186
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
How can I share a I2CDriver? #496
Comments
It would've been better to ask this question on the Matrix ESP-RS chat rather than opening an issue here, but anyway. In any case, you should absolutely not play and hack around the
The "port" ^^^ simply means which of the (potentially multiple) I2c peripherals (or "bus"-es) should be used by this I2cDriver. ( Now, I assume you have TWO (or more) such devices, but just one To do this:
If you want the mutex to be shared into the |
Ah sorry did not know there is a matrix channel at all. Joined it now and will ask similar stuff there in the future. |
I currently try to wrap my head around, how I could share a I2CDriver between multiple I2CDevices.
Currently I'm force creating a new driver based on the first ones port. But since these fields are private this is obviously no the correct way to do it.
let driver = I2cDriver{ i2c: port as u8, _p: std::marker::PhantomData, };
I tried via unchecked_clone to clone all pins and then create a second driver via new(), but that one crashes since it tries to low lever init the i2c hardware a second time.
E (1035) i2c: i2c driver install error thread 'main' panicked at src/plant_hal.rs:1016:65: called Result::unwrap() on an Err value: ESP_FAIL (error code -1) note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
Is there any solution to this that I do not see?
The text was updated successfully, but these errors were encountered: