diff options
| author | James Munns <[email protected]> | 2024-07-07 16:54:37 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-07-07 16:54:37 +0000 |
| commit | 462daeeb4927416ed817423e91adb71c0861a83d (patch) | |
| tree | 40d457c47a0dc58468511c75856d587df281635b /examples | |
| parent | f91244bae6a4b277f8464c499e50c492a7671039 (diff) | |
| parent | 3408e1ddbf7076e119307ae04dce4a9ddf922f34 (diff) | |
Merge pull request #3154 from Dicklessgreat/main
Fix BDMA example for soundness
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32h7/src/bin/spi_bdma.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/examples/stm32h7/src/bin/spi_bdma.rs b/examples/stm32h7/src/bin/spi_bdma.rs index b2e941078..43fb6b41c 100644 --- a/examples/stm32h7/src/bin/spi_bdma.rs +++ b/examples/stm32h7/src/bin/spi_bdma.rs | |||
| @@ -10,18 +10,24 @@ use embassy_executor::Executor; | |||
| 10 | use embassy_stm32::mode::Async; | 10 | use embassy_stm32::mode::Async; |
| 11 | use embassy_stm32::time::mhz; | 11 | use embassy_stm32::time::mhz; |
| 12 | use embassy_stm32::{spi, Config}; | 12 | use embassy_stm32::{spi, Config}; |
| 13 | use grounded::uninit::GroundedArrayCell; | ||
| 13 | use heapless::String; | 14 | use heapless::String; |
| 14 | use static_cell::StaticCell; | 15 | use static_cell::StaticCell; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 17 | ||
| 17 | // Defined in memory.x | 18 | // Defined in memory.x |
| 18 | #[link_section = ".ram_d3"] | 19 | #[link_section = ".ram_d3"] |
| 19 | static mut RAM_D3: [u8; 64 * 1024] = [0u8; 64 * 1024]; | 20 | static mut RAM_D3: GroundedArrayCell<u8, 256> = GroundedArrayCell::uninit(); |
| 20 | 21 | ||
| 21 | #[embassy_executor::task] | 22 | #[embassy_executor::task] |
| 22 | async fn main_task(mut spi: spi::Spi<'static, Async>) { | 23 | async fn main_task(mut spi: spi::Spi<'static, Async>) { |
| 23 | let read_buffer = unsafe { &mut RAM_D3[0..128] }; | 24 | let (read_buffer, write_buffer) = unsafe { |
| 24 | let write_buffer = unsafe { &mut RAM_D3[128..256] }; | 25 | RAM_D3.initialize_all_copied(0); |
| 26 | ( | ||
| 27 | RAM_D3.get_subslice_mut_unchecked(0, 128), | ||
| 28 | RAM_D3.get_subslice_mut_unchecked(128, 128), | ||
| 29 | ) | ||
| 30 | }; | ||
| 25 | 31 | ||
| 26 | for n in 0u32.. { | 32 | for n in 0u32.. { |
| 27 | let mut write: String<128> = String::new(); | 33 | let mut write: String<128> = String::new(); |
