Skip to content

Clean up DMA module - #262

Merged
david-sawatzke merged 10 commits into
lpc-rs:masterfrom
braun-embedded:dma
Jul 29, 2020
Merged

david-sawatzke merged 10 commits into
lpc-rs:masterfrom
braun-embedded:dma

Conversation

@hannobraun

Copy link
Copy Markdown
Member

This PR contains multiple orthogonal clean-ups, the most significant of which removes the lifetime from Channel and Transfer, making the API much more convenient to use in non-trivial use cases.

I plan to move the `start_transfer` method to `Transfer`, and in the
future we will need to add more methods there, to control and query the
ongoing transfer. Those methods will probably need most of these
registers, so I figured why not just make all of them available.
I'm going to add more methods that need to access channel registers
there anyway, and the start method seems to fit there better. Plus, all
the compiler fence stuff is now concentrated in `Channel`.
Use a custom abstraction instead.

cc #211
This makes using the DMA peripheral more convenient and opens the door
for further simplications, at the cost of requiring more memory when the
DMA peripheral isn't used (actually I believe that as of this commit,
the compiler can optimize the static out, if DMA is not used; I'm
working on further changes that would make this impossible).

I think the added memory use if far from ideal, but right now I'd like
to focus on a simpler and more flexible API. We can restore efficiency
later, if desired, by being a bit more clever about using the static and
allowing the compiler to optimize it.
It's an internal implementation detail now.
Since the descriptor table is no longer supplied by the user, a separate
`split` step is no longer necessary.

Please see the description of one of the previous commit for some notes
on the consequences this change has on efficiency.
This removes the need for carrying a reference in every enabled channel,
thereby removing the lifetime from channels and transfers, while
offering the same guarantees. This makes the API much more convenient in
non-trivial use cases.

In addition, it allows for disabling the peripheral after a channel has
been disabled, which has not been possible with the old API.
This follows the example from other modules, limits the wildcard
re-export to that one module, and makes the `channels` module much
lighter.
I believe the new name is much nicer and better reflects the difference
between `Channel` and the trait. It also follows the example set by the
peripheral APIs, so the consistency is an added bonus.

@david-sawatzke david-sawatzke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that happy about the static DescriptorTable, but can live with it

@david-sawatzke
david-sawatzke merged commit cf43508 into lpc-rs:master Jul 29, 2020
@hannobraun
hannobraun deleted the dma branch July 29, 2020 12:26
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.

2 participants