embassy-rp::dma::Channel: Allow use of custom irq handler#5388
embassy-rp::dma::Channel: Allow use of custom irq handler#5388dobrowolski-lukasz wants to merge 2 commits intoembassy-rs:mainfrom
Conversation
24a76b4 to
2b29499
Compare
|
the way to do this I had in mind is using the same pattern as the Blocking/Async modes in other drivers. fn new(ch, irq) -> Channel<'a, Async>;
fn new_blocking(ch) -> Channel<'a, Blocking>;and then make Transfer only awaitable in Async mode, since it'll hang if the irq handler is not bound. |
|
I feel we are talking about two different things. Can You elaborate? I'll explain my use case. It should make things clearer. The solution I'm trying to implement is to start next transfer in IRQ handler. The only negative I can see is the annotations. In my own app I'm passing |
|
Ahh. Did You mean adding another method to If so then I'm still unsure if it's sensible. As I've written those annotations seem to be needed only in weird situation when global I could change the examples so that the annotations aren't needed but I feel that It's better to leave them as is, so that when somebody struggles they will have a solution shown in examples. |
|
Awaiting a transfer needs the interrupt handler to wake the waker. If the user forgets to bind the interrupt handler, await would simply hang. This is why the typelevel interrupt binding stuff exists. It forces the user to "prove" to This is all embassy-rp should care about. You bound embassy-rp's irq handler? you can await transfers. You didn't? then you can't. It shouldn't care whether you've bound a custom irq handler or you've bound nothing at all. It's not going to do anything different based on that. This is why making |
I feel that there is a misunderstanding here. Code before this PR hardcodes that I've discovered this when I've bound my custom IRQ handler and the code failed to compile because |
I don't understand "blocking dma" concept. I have guesses but those make little sense:
|
|
I would be surprised if this really fixes the problem you have. When a transfer completes, the IRQ handler wakes the channels waker, so your loop should continue promptly. Are you running in an InterruptExecutor? Using that, with a correctly set priority should help. |
In theory, yes. There are two problems in practice:
Maybe I could shuffle my app around to make it work but that would be a workaround and I have other constraints too. |
this is correct, it's needed to ensure
this is wrong. with this the user can pass a random handler, and write code that still uses
"blocking" is perhaps not the best name. It basically means "not async, ie you can't
which I guess is what you want? The point of having this new "mode" represented as a generic param is to prevent the user from doing |
I see. This indeed is a problem. By making Channel reusable we loose correctness grantees. "blockig dma" concept: I understand it now. It does make sense. Through it's not what I need and it's something different then this PR. |
I have an app with an OLED screen. Core1 renders the next frame, and Core0 does everything else. |
|
This comment was marked as outdated.
This comment was marked as outdated.
2b29499 to
37b7abe
Compare
37b7abe to
c1308e9
Compare
|
I've gone with I've made |
Follow up to #5338.
Make it possible to use Channel with custom irq handler.
This change makes some type annotations necessary. Do let me know if there is a better way.
Misc: Make Channel number method pub to help with custom DMA handling code.