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

Add gpdma ringbuffer support #3162

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

calebstewart
Copy link

@calebstewart calebstewart commented Jul 9, 2024

This is an ongoing attempt to get the changes from #2302 merged and working. I'm by no means an expert here, and this is currently just a first-pass at getting the merge conflicts fixed. This hasn't been tested at all yet by me.

@calebstewart
Copy link
Author

@Dirbaio I'm going to try and test this soon ( ™️ ) but I'm curious if I even updated some of this correctly. The APIs within DMA seem to have changed since Tyler originally implemented this branch. There were things like this:

/// This is a Readable ring buffer. It reads data from a peripheral into a buffer. The reads happen in circular mode.
/// There are interrupts on complete and half complete. You should read half the buffer on every read.
pub struct ReadableRingBuffer<'a, C: Channel, W: Word> {
    channel: PeripheralRef<'a, C>,
    ringbuf: ReadableDmaRingBuffer<'a, W>,
}

Where self.channel was used like:

self.channel.regs().ch(self.channel.num())

This was no longer valid, and looking over the repository changes over the last few months, I realized that other similar code was now using a pattern where they had an AnyChannel variable, and accessed the DMA registers through channel.info().dma.ch(...), so I opted to modify the structs like this:

/// This is a Readable ring buffer. It reads data from a peripheral into a buffer. The reads happen in circular mode.
/// There are interrupts on complete and half complete. You should read half the buffer on every read.
pub struct ReadableRingBuffer<'a, W: Word> {
    channel: PeripheralRef<'a, AnyChannel>,
    ringbuf: ReadableDmaRingBuffer<'a, W>,
}

And now most of the references to that variable look like:

let info = self.channel.info();
info.dma.ch(info.num)

I'm not sure if that's the "correct" way to go about it, though. Given that the only place I saw the channel info exposed was AnyChannel and that AnyChannel could represent... well, any channel, the generic seemed unnecessary. Happy to be corrected though.

@calebstewart
Copy link
Author

Ah, I just had a look at dma_bdma.rs, and what I did appears to be mostly the same as what was done there with some minor modifications. :)

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