dma transfering from buffer to the gpio

This commit is contained in:
Priec
2025-10-29 21:37:08 +01:00
parent 62303e7cf1
commit c78af52849
11 changed files with 1660 additions and 0 deletions

45
dma_gpio/src/bin/main.rs Normal file
View File

@@ -0,0 +1,45 @@
// src/bin/main.rs
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_sync::{
blocking_mutex::raw::CriticalSectionRawMutex,
pipe::Pipe,
};
use embassy_time::{Duration, Timer};
use {defmt_rtt as _, panic_probe as _};
static PIPE: Pipe<CriticalSectionRawMutex, 64> = Pipe::new();
#[embassy_executor::main]
async fn main(spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
info!("Hello World!");
spawner.spawn(pipe_consumer_task()).unwrap();
let mut counter: u32 = 0;
loop {
let bytes = counter.to_le_bytes(); // convert 4 bytes
PIPE.write(&bytes).await;
info!("Producer pushed value {}", counter);
counter = counter.wrapping_add(1);
Timer::after(Duration::from_secs(2)).await;
}
}
#[embassy_executor::task]
async fn pipe_consumer_task() {
let mut buf = [0u8; 4];
loop {
let n = PIPE.read(&mut buf).await;
if n == 4 {
let val = u32::from_le_bytes(buf);
info!("Consumer read {}", val);
}
}
}

1
dma_gpio/src/lib.rs Normal file
View File

@@ -0,0 +1 @@
#![no_std]