Erase DMA channel type from Camera and AesDma drivers #2258
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.
Thank you for your contribution!
We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:
Submission Checklist 📝
cargo xtask fmt-packages
command to ensure that all changed code is formatted correctly.CHANGELOG.md
in the proper section.Extra:
Pull Request Details 📖
Description
This PR gives users the ability to degrade a DMA channel into a less specific type.
On GDMA chips this is a transformation from
DmaChannel0
/DmaChannel1
/DmaChannel2
/etc toAnyDmaChannel
.On PDMA chips this does nothing (For now).
I've added a default generic parameter to
Camera
andAesDma
.i.e.
pub struct Camera<'d, CH: DmaChannel = AnyDmaChannel>
So now users can do this.
I've only done
Camera
andAesDma
as those two didn't require breaking changes to add.I8080
for example has this type signaturestruct I8080<'d, CH: DmaChannel, DM: Mode>
.To add the erased DMA channel type I have to do reorder the generics like so
struct I8080<'d, DM: Mode, CH: DmaChannel = AnyDmaChannel>
, which is a breaking change. There's the option of adding a default mode as well but I'm not interested in making this decision nor carrying out the admin for the breaking changes.For the PDMA side, having an "Any" type isn't as important because there is always a single answer to the question "What DMA channel do I need to use for this peripheral?" (Except on the ESP32 SPI DMA but we won't get into that here).
In this case I think it's reasonable to use a conditional type alias, like what I did for Aes.
The nice this about this is that PDMA chips always have "type erasure" in the sense that you'll never have to name the channel, even if you don't call
degrade()
.For SPI and I2S that have multiple instances, an associated type can be used.
If you don't like my proposal for the PDMA, you can land this PR since it implements erasure on the GDMA side and build PDMA erasure on top of it I guess.
If you choose to take this path of further erasure, just beware of the ESP32-P4 because the GDMA isn't as universal as the current chips. Half of the channels work on some peripherals and the other half on a different set of peripherals. (The difference is PSRAM support)
This is the finish line for me, I've done the heavy lifting. Someone else can pick up the admin of updating all the other drivers and creating migration guides 😄 .
Testing
It builds. I was also able to name
Camera
without specifying the channel type after callingdegrade()
.