Skip to content

Commit 2bcf2af

Browse files
committed
Add note where TARGET_BUFFER should be initialised (but is not)
1 parent 4586b6f commit 2bcf2af

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

examples/dma.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ fn main() -> ! {
7171
// Save a copy on the stack so we can check it later
7272
let source_buffer_cloned = *source_buffer;
7373

74+
// NOTE(unsafe): TARGET_BUFFER must also be initialised to prevent undefined
75+
// behaviour (taking a mutable reference to uninitialised memory)
76+
7477
// Setup DMA
7578
//
7679
// We need to specify the transfer size with a type annotation

examples/mdma_bursts.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn main() -> ! {
6161
info!("");
6262

6363
// Initialise the source buffer without taking any references to
64-
// uninitialisated memory
64+
// uninitialised memory
6565
let _source_buffer: &'static mut [u32; 200] = {
6666
let buf: &mut [MaybeUninit<u32>; 200] = unsafe {
6767
&mut *(core::ptr::addr_of_mut!(SOURCE_BUFFER)
@@ -76,6 +76,9 @@ fn main() -> ! {
7676
unsafe { SOURCE_BUFFER.assume_init_mut() }
7777
};
7878

79+
// NOTE(unsafe): TARGET_BUFFER must also be initialised to prevent undefined
80+
// behaviour (taking a mutable reference to uninitialised memory)
81+
7982
// Setup DMA
8083
let streams = StreamsTuple::new(dp.MDMA, ccdr.peripheral.MDMA);
8184

0 commit comments

Comments
 (0)