Skip to content
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

Make DMA-based AES API more ergonomic #19

Merged
merged 10 commits into from Aug 1, 2019
Merged

Make DMA-based AES API more ergonomic #19

merged 10 commits into from Aug 1, 2019

Conversation

hannobraun
Copy link
Contributor

@hannobraun hannobraun commented Jul 23, 2019

This pull request changes the AES API to work with u8 buffers, instead of u32 buffers, which should make it easier to use in most scenarios.

I've also snuck in a few commits that fix and improve some other things related to AES and DMA. It didn't seem worth it to create a separate pull request for those, especially since I've already got a bit a bit of a traffic jam going :-)

This pull request is based on #16. I recommend reviewing/merging that one first.

cc @lthiery

@arkorobotics
Copy link
Member

arkorobotics commented Jul 27, 2019

Are #16 and #19 ready for review?

@hannobraun
Copy link
Contributor Author

hannobraun commented Jul 28, 2019

@arkorobotics Yes. #16 is fully ready. This PR (#19) still includes the commit from #16, but I'm marking it "Ready for review", as the one shared commit shouldn't be too much of a hindrance in reviewing.

@hannobraun hannobraun marked this pull request as ready for review Jul 28, 2019
@arkorobotics
Copy link
Member

arkorobotics commented Jul 29, 2019

Sounds good, how would you like to resolve these merge conflicts?

@hannobraun
Copy link
Contributor Author

hannobraun commented Jul 30, 2019

Sounds good, how would you like to resolve these merge conflicts?

They shouldn't be there :-)
I thought both PRs shared the same commit, so it looks like some wires got crossed.

I'll take a look later today!

hannobraun added 10 commits Jul 30, 2019
I'm working on some changes that require `Transfer::new` to be opened up
to the rest of the crate, so I think it makes sense to not require weird
PAC types when calling it.
The problem with these constructors is that they're not flexible enough.
In general, peripheral APIs might want to present DMA transfers to the
user in a different way than they work in hardware.

For example, the AES peripheral supports only transfers of 32-bit words,
but might want to present an API that works with byte slices (I'm
currently working on this). Another example would be SPI, which might
want to hide two simultaneous DMA transfers (for read and write) behind
a single transfer struct.

This commit doesn't make these use cases possible yet, as some
modifications to the unsafe constructor are still required. But it paves
the way, by exposing that constructor to the peripheral APIs.

Please note that none of this exposes any unsafety to the users. They
will still use the same (safe) peripheral APIs to access DMA.
The new trait, `Buffer`, provides everything the DMA code needs from the
buffer, without requiring implementers to be able to return a slice.
This makes the trait more flexible, as it can be implemented for a
larger variety of types, without requiring any complex transmuting.
The type parameter names were wrong, as they were in a different order
than was used everywhere else in the code. Please note that this didn't
cause any incorrect behavior, as just the names were wrong and nothing
else.
This should be more natural than operating with `u32` words.
@hannobraun
Copy link
Contributor Author

hannobraun commented Jul 30, 2019

I don't know what GitHub's problem is. This rebased flawlessly, no conflicts in sight.

Anyways, all should be well now.

@arkorobotics arkorobotics merged commit 5e3344a into stm32-rs:master Aug 1, 2019
@hannobraun hannobraun deleted the aes-u8 branch Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants