diff options
| author | Bogdan Petru Chircu Mare <[email protected]> | 2025-11-25 22:09:01 -0800 |
|---|---|---|
| committer | Bogdan Petru Chircu Mare <[email protected]> | 2025-11-28 12:34:24 -0800 |
| commit | 03356a261801d7ee234490809eef3eac3c27cc52 (patch) | |
| tree | 23de784ea642f65ce5c02fdcb111ee314a4ca97f /src/lib.rs | |
| parent | 87c4eaf3380505ca15ef7ed1d5dc435e9af2200e (diff) | |
feat(dma): add DMA driver with 10 verified examples
Initial DMA driver implementation for MCXA276 with:
Core DMA Features:
- DmaChannel type with ownership tracking via Channel trait
- Transfer, RingBuffer, and ScatterGatherBuilder abstractions
- Support for mem-to-mem, mem-to-peripheral, peripheral-to-mem transfers
- Interrupt-driven completion with embassy async/await integration
- Word size abstraction (u8, u16, u32) via Word trait
LPUART DMA Integration:
- LpuartTxDma and LpuartRxDma drivers for async UART with DMA
- LpuartDma combined TX/RX driver
- Automatic chunking for buffers > 0x7FFF bytes
- DMA guards with Drop impl for safe cancellation
10 Verified Examples:
- dma_mem2mem: Basic memory-to-memory copy
- dma_memset: Memory fill with pattern
- dma_uart_tx: UART transmit via DMA
- dma_uart_rx: UART receive via DMA
- dma_uart_loopback: Combined TX/RX loopback test
- dma_scatter_gather: Linked descriptor chains
- dma_channel_linking: Major/minor loop channel linking
- dma_ring_buffer: Circular buffer for continuous streaming
- dma_ping_pong: Double-buffering pattern
- dma_software_trigger: Manual transfer triggering
PR Feedback Addressed:
- Use PAC accessor for LPUART DATA register instead of manual offset
- Add EnableInterrupt enum to replace boolean parameter for readability
- Add DMA guards with Drop impl for safe async cancellation
- Automatic chunking for large buffers instead of returning error
- Use NonNull<[W]> + PhantomData for RingBuffer (DMA acts like separate thread)
- Remove edma parameter from all methods (single eDMA instance steals ptr internally)
- Make edma_tcd() non-public (HAL should not expose PAC items)
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs index fb204d27b..d3560e651 100644 --- a/src/lib.rs +++ b/src/lib.rs | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | // #![doc = document_features::document_features!(feature_label = r#"<span class="stab portability"><code>{feature}</code></span>"#)] | 6 | // #![doc = document_features::document_features!(feature_label = r#"<span class="stab portability"><code>{feature}</code></span>"#)] |
| 7 | 7 | ||
| 8 | pub mod clocks; // still provide clock helpers | 8 | pub mod clocks; // still provide clock helpers |
| 9 | pub mod dma; | ||
| 9 | pub mod gpio; | 10 | pub mod gpio; |
| 10 | pub mod pins; // pin mux helpers | 11 | pub mod pins; // pin mux helpers |
| 11 | 12 | ||
| @@ -51,6 +52,14 @@ embassy_hal_internal::peripherals!( | |||
| 51 | 52 | ||
| 52 | DBGMAILBOX, | 53 | DBGMAILBOX, |
| 53 | DMA0, | 54 | DMA0, |
| 55 | DMA_CH0, | ||
| 56 | DMA_CH1, | ||
| 57 | DMA_CH2, | ||
| 58 | DMA_CH3, | ||
| 59 | DMA_CH4, | ||
| 60 | DMA_CH5, | ||
| 61 | DMA_CH6, | ||
| 62 | DMA_CH7, | ||
| 54 | EDMA0_TCD0, | 63 | EDMA0_TCD0, |
| 55 | EIM0, | 64 | EIM0, |
| 56 | EQDC0, | 65 | EQDC0, |
