diff --git a/examples/dma.rs b/examples/dma.rs index 730a2c5b..c1ec1762 100644 --- a/examples/dma.rs +++ b/examples/dma.rs @@ -71,6 +71,9 @@ fn main() -> ! { // Save a copy on the stack so we can check it later let source_buffer_cloned = *source_buffer; + // NOTE(unsafe): TARGET_BUFFER must also be initialised to prevent undefined + // behaviour (taking a mutable reference to uninitialised memory) + // Setup DMA // // We need to specify the transfer size with a type annotation diff --git a/examples/mdma_bursts.rs b/examples/mdma_bursts.rs index 784fcb74..bfcd6083 100644 --- a/examples/mdma_bursts.rs +++ b/examples/mdma_bursts.rs @@ -61,7 +61,7 @@ fn main() -> ! { info!(""); // Initialise the source buffer without taking any references to - // uninitialisated memory + // uninitialised memory let _source_buffer: &'static mut [u32; 200] = { let buf: &mut [MaybeUninit; 200] = unsafe { &mut *(core::ptr::addr_of_mut!(SOURCE_BUFFER) @@ -76,6 +76,9 @@ fn main() -> ! { unsafe { SOURCE_BUFFER.assume_init_mut() } }; + // NOTE(unsafe): TARGET_BUFFER must also be initialised to prevent undefined + // behaviour (taking a mutable reference to uninitialised memory) + // Setup DMA let streams = StreamsTuple::new(dp.MDMA, ccdr.peripheral.MDMA);