Enable full-duplex I2S for spi_v2 devices using I2SEXT peripherals #4746
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.
Fixes #4698
There are two classes of changes in this PR: Ones that will be permanent, and ones that are temporary until stm32-metapac gets updated to reflect information about I2SEXT peripherals.
Changes of the latter type are reflected in a few traits at the top of the file. I have mimicked traits such as
WsPinandRxDma, which is nice because it preserves a bunch of the design patterns below. It seems like metapac just needs to add these traits and implement them as appropriate for a device, but I don't grok metapac well enough to make this change right now. TheI2sRegstrait should probably be absorbed intospi::Instance.The permanent changes are of the following character:
I2S::new_full_duplex()which is feature-gated tospi_v2(though TBH I'm not sure if this is the only version of SPI that should be covered, or if everyspi_v2platform has I2SEXT peripherals)struct I2Sto hold the register block for the I2SEXT peripheral, if usednew_inner, if an I2SEXT peripheral is being used, we initialize it to the same I2S settings as the main SPI peripheral, in the opposite direction, and always in slave mode.self.spi.info.regs, we distinguish between register blocks used in the tx and rx directions. These are different when an I2SEXT peripheral is in use, and the same otherwise. This does result in some duplication when I2SEXT is not in use; it might be possible to refactor to avoid.Marking this as draft because of the above-mentioned issues, and because of the unresolved dependency on metapac changes. I have tested this on a real device using
stm32f405rg, but not more generally.