repeated dma send

This commit is contained in:
Jörn-Michael Miehe 2024-03-01 15:18:26 +00:00
parent fc94b6186a
commit 08229bc0e9

View file

@ -46,7 +46,7 @@ fn main() -> ! {
&mut flash.acr, &mut flash.acr,
); );
// Acquire the GPIOC peripheral // Acquire the peripherals
let mut gpioa = dp.GPIOA.split(); let mut gpioa = dp.GPIOA.split();
let mut gpioc = dp.GPIOC.split(); let mut gpioc = dp.GPIOC.split();
@ -62,20 +62,14 @@ fn main() -> ! {
(tx, rx), (tx, rx),
&mut afio.mapr, &mut afio.mapr,
serial::Config { serial::Config {
baudrate: 9_600.bps(), baudrate: 250_000.bps(),
..Default::default() ..Default::default()
}, },
&clocks, &clocks,
); );
let tx = serial.tx.with_dma(dma1.4); let mut tx = serial.tx.with_dma(dma1.4);
let buf = singleton!(: [u8; 255] = [0b01010101; 255]).unwrap(); let mut buf = singleton!(: [u8; 255] = [0b01010101; 255]).unwrap();
let xfer = tx.write(buf);
while !xfer.is_done() {}
// while circ_buffer.readable_half().unwrap() != dma::Half::First {}
// let _first_half = circ_buffer.peek(|half, _| *half).unwrap();
// Configure gpio C pin 13 as a push-pull output. The `crh` register is passed to the function // Configure gpio C pin 13 as a push-pull output. The `crh` register is passed to the function
// in order to configure the port. For pins 0-7, crl should be passed instead. // in order to configure the port. For pins 0-7, crl should be passed instead.
@ -86,13 +80,9 @@ fn main() -> ! {
// at 72 MHz, timer of 1 Hz overflows, use 10 Hz instead (8 Hz experimental minimum) // at 72 MHz, timer of 1 Hz overflows, use 10 Hz instead (8 Hz experimental minimum)
timer.start(10.Hz()).unwrap(); timer.start(10.Hz()).unwrap();
// equivalent timers:
// let mut timer = Timer::syst(cp.SYST, &clocks).counter_us(); // us resolution
// let mut timer: SysCounter<1000> = Timer::syst(cp.SYST, &clocks).counter(); // ms resolution
// timer.start(100.millis()).unwrap();
// Wait for the timer to trigger an update and change the state of the LED // Wait for the timer to trigger an update and change the state of the LED
loop { loop {
let xfer = tx.write(buf);
for _ in 0..10 { for _ in 0..10 {
block!(timer.wait()).unwrap(); block!(timer.wait()).unwrap();
} }
@ -102,5 +92,7 @@ fn main() -> ! {
block!(timer.wait()).unwrap(); block!(timer.wait()).unwrap();
} }
led.set_low(); led.set_low();
(buf, tx) = xfer.wait();
} }
} }