-
Notifications
You must be signed in to change notification settings - Fork 630
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
stm32 i2c slave #2909
base: main
Are you sure you want to change the base?
stm32 i2c slave #2909
Conversation
Hi Jared, interesting. Will respond soon if I figure anything out. |
I've figured out why the function wasn't being polled. Now just working on finishing up the implementation |
@Dirbaio the stm32 i2c supports multimaster for allowing both a master and a slave functionality. The slave mode is the default and the master mode is enabled by a start condition and ends with a stop condition. Currently in this implementation I have split the slave from the master. This more closely matches the API in the embassy-rp crate. Would it be better to join them and merge the slave functionality into the regular i2c driver (in order to let you switch from slave to master without reconfiguring) or is it better to leave them split? (edited) |
I think being part of the regular driver works, if say you introduce a Thoughts? |
@jrmoulton see CI issues please, just a heads up. keen to test this soon - thanks so much!! edit: did some tracing to help you with picking this up mate - these seem CI related only, as your build works |
@Dirbaio I like your CI page title "lol job"?? https://ci.embassy.dev/jobs/586c0e7a5b13 |
test result: ok. 3 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out; finished in 0.06s
Updating crates.io index
Updating git repository `https://github.com/embassy-rs/stm32-data-generated`
Compiling embassy-hal-internal v0.1.0 (/ci/code/embassy-hal-internal)
Compiling embassy-time v0.3.0 (/ci/code/embassy-time)
Compiling embassy-usb-synopsys-otg v0.1.0 (/ci/code/embassy-usb-synopsys-otg)
Compiling embassy-stm32 v0.1.0 (/ci/code/embassy-stm32)
Compiling embassy-net-driver v0.2.0 (/ci/code/embassy-net-driver)
Compiling embassy-embedded-hal v0.1.0 (/ci/code/embassy-embedded-hal)
error[E0432]: unresolved import `stm32_metapac::i2c::vals::Oamsk`
--> src/i2c/mod.rs:19:5
|
19 | use stm32_metapac::i2c::vals::Oamsk;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `Oamsk` in `i2c::vals`
warning: unused import: `interrupt`
--> src/time_driver.rs:19:13
|
19 | use crate::{interrupt, peripherals};
| ^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused import: `interrupt`
--> src/exti.rs:14:13
|
14 | use crate::{interrupt, pac, peripherals, Peripheral};
| ^^^^^^^^^
error[E0599]: no method named `init` found for struct `I2cSlave` in the current scope
--> src/i2c/mod.rs:367:14
|
299 | pub struct I2cSlave<'d, T: Instance, M: Mode> {
| --------------------------------------------- method `init` not found for this struct
...
367 | this.init(freq, config);
| ^^^^ method not found in `I2cSlave<'_, T, M>`
warning: unused variable: `waker`
--> src/dma/ringbuffer.rs:429:33
|
429 | fn set_waker(&mut self, waker: &Waker) {}
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_waker`
|
= note: `#[warn(unused_variables)]` on by default |
_phantom: PhantomData, | ||
}; | ||
|
||
this.init(freq, config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is missing.
@@ -13,6 +16,7 @@ use embassy_hal_internal::{into_ref, Peripheral, PeripheralRef}; | |||
use embassy_sync::waitqueue::AtomicWaker; | |||
#[cfg(feature = "time")] | |||
use embassy_time::{Duration, Instant}; | |||
use stm32_metapac::i2c::vals::Oamsk; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Odd error in CI, needs a deeper look.
I'm in the process of reworking the I2C driver to be generic over an I2C mode which can either be Master, Slave, or MultiMaster. |
Just wanted to let you know that I'm also eagerly awaiting slave mode, thanks a lot @jrmoulton! |
This isn't quite finished. It only has the async slave implementation and the code needs to be cleaned up.
I could use some help debugging also.
In the listen method I enable the address match interrupt and register the waker in the poll closure.
The issue is that the runtime never polls the function again even when an address is matched.
If I write code that blocks instead of yielding and send and I2C communication the peripheral will still be enabled and will match the address.
I've tried also adding the wupen bit but that didn't make a difference
Any idea why the runtime wouldn't poll the function again?