Skip to content

Commit 746d79d

Browse files
committed
rp2: Properly de-init all DMA channels during soft reboot.
Fixes micropython#18446. Signed-off-by: Dryw Wade <dryw.wade@sparkfun.com>
1 parent c07fda7 commit 746d79d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

ports/rp2/rp2_dma.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,25 @@ void rp2_dma_init(void) {
471471
}
472472

473473
void rp2_dma_deinit(void) {
474+
// Reset all DMA channel registers to their default values.
475+
dma_channel_config config = { .ctrl = 0 };
476+
for (uint i = 0; i < NUM_DMA_CHANNELS; i++) {
477+
dma_channel_configure(
478+
i,
479+
&config,
480+
NULL,
481+
NULL,
482+
0,
483+
false
484+
);
485+
}
486+
487+
// Abort all DMA channels. Must be done after clearing EN bits in control
488+
// registers due to errata RP2350-E5.
489+
for (uint i = 0; i < NUM_DMA_CHANNELS; i++) {
490+
dma_channel_abort(i);
491+
}
492+
474493
// Remove our interrupt handler.
475494
irq_remove_handler(DMA_IRQ_0, rp2_dma_irq_handler);
476495
}

0 commit comments

Comments
 (0)