Enable full-duplex I2S for spi_v2 devices using I2SEXT peripherals#5773
Draft
bifurcation wants to merge 3 commits intoembassy-rs:mainfrom
Draft
Enable full-duplex I2S for spi_v2 devices using I2SEXT peripherals#5773bifurcation wants to merge 3 commits intoembassy-rs:mainfrom
bifurcation wants to merge 3 commits intoembassy-rs:mainfrom
Conversation
The STM32F4 SPI2/SPI3 peripherals have associated I2SEXT peripherals (I2S2EXT/I2S3EXT) that enable true full-duplex I2S. These are not in stm32-metapac, so we define custom traits for the SPI-to-I2SEXT register mapping, DMA request numbers, and AF pin assignments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add I2SEXT peripheral traits (I2sExtRegs, RxDmaExt, SdExtPin) for STM32F405 SPI2/SPI3 - Add new_full_duplex constructor for spi_v2 using I2SEXT - Add regs_tx/regs_rx helpers and read_write method - Update start/stop to handle I2SEXT peripheral enable/disable - Configure I2SEXT in new_inner with opposite direction and slave mode - RX DMA reads from I2SEXT register block when present - Rename existing spi_v3 full_duplex to new_full_duplex_native - Enable I2S (set_i2se) in start() for spi_v1/v2/v3 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The I2SEXT-based full-duplex method works on both spi_v1 (STM32F405 in embassy 0.4) and spi_v2 (embassy 0.5). Widen the cfg gate so the constructor is available on both. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
This PR is also based on an older commit of |
Contributor
|
@bifurcation hang on a minute, I'm going to rework the traits a bit... |
Author
|
@xoviat No rush! My fork is working for me right now, so we can do thus on whatever schedule you like. I just refreshed the PR with my latest state since I saw your ping. |
Merged
Contributor
|
@bifurcation I just merged #5774, which should have the traits that you need to complete this. |
This was referenced Apr 2, 2026
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.
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 WsPin and RxDma, 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. The I2sRegs trait should probably be absorbed into spi::Instance.
The permanent changes are of the following character:
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
stm32f405rgusing SPI to talk to anWM8960and it works reliably, but I have not tested not more generally.Replaces #4746