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

Consider supporting extended DMA transfers #11

Open
hannobraun opened this issue Sep 12, 2018 · 4 comments
Open

Consider supporting extended DMA transfers #11

hannobraun opened this issue Sep 12, 2018 · 4 comments

Comments

@hannobraun
Copy link
Contributor

This issue was first opened in the old nrf52-hal repository. Original discussion: jamesmunns/nrf52-hal#14


The nRF52832's DMA channels are limited to buffers with a maximum length of 255 bytes. This is very limiting. For example, in the DW1000 driver, I need to support registers that are much longer than that (although there are ways to read/write subsets).

There is a way to use multiple consecutive buffers to circumvent this limitation. The product specification alludes to this (see section 10.1), but doesn't really explain how this works. I found the following discussions that provide a clearer picture:

Since this technique requires additional system resources (PPI, TIMER) and applies to all DMA channels, I think it's probably best to provide this as a separate layer that builds on top of DMA users like SPIM.

@jamesmunns
Copy link
Member

Hey @hannobraun, do you think a solution like #40 would work? My idea would be roughly as follows:

  • Continue offering a "blocking" implementation of each peripheral, essentially what we have now
  • Offer an "async" version of each peripheral which does the following:
    • Provides the interrupt handler, transparent to the user
    • uses a static BBQueue (one for each peripheral and each direction)
    • uses something like this demo to allow the user to enable/configure the buffer size, at least until it is possible to have the UarteAsync instance totally own the BBQueue in a way that makes sense

@hannobraun
Copy link
Contributor Author

@jamesmunns
I left some comments in your pull request. Whether it is an alternative to the approach suggested in this issue, I don't know. My impression is that this approach would enable the blocking API to support larger buffers with little hassle (from the user's perspective). You're suggesting a non-blocking API, which seems somewhat orthogonal.

@Yatekii
Copy link
Contributor

Yatekii commented Feb 6, 2019

I used exactly that feature of the nRF52832 in C already and it's really not that much sorcery.
You need to set some triggers on the PPI bus accordingly to start the next transfer with the transfer done event. You will still require some stop condition (e.g. an ISR) that stops the chain of write/read events, such that it does not trigger the chain for all eternity (I think this is kinda sad and I would have loved a register to set a max transfers value or total buffer size).

I think this should be easily doable but would require some nicer higher level interface to the PPI bus.

@hannobraun
Copy link
Contributor Author

I think this should be easily doable but would require some nicer higher level interface to the PPI bus.

Which would be a nice thing to have in itself!

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

No branches or pull requests

3 participants