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,
);
// Acquire the GPIOC peripheral
// Acquire the peripherals
let mut gpioa = dp.GPIOA.split();
let mut gpioc = dp.GPIOC.split();
@ -62,20 +62,14 @@ fn main() -> ! {
(tx, rx),
&mut afio.mapr,
serial::Config {
baudrate: 9_600.bps(),
baudrate: 250_000.bps(),
..Default::default()
},
&clocks,
);
let tx = serial.tx.with_dma(dma1.4);
let 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();
let mut tx = serial.tx.with_dma(dma1.4);
let mut buf = singleton!(: [u8; 255] = [0b01010101; 255]).unwrap();
// 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.
@ -86,13 +80,9 @@ fn main() -> ! {
// at 72 MHz, timer of 1 Hz overflows, use 10 Hz instead (8 Hz experimental minimum)
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
loop {
let xfer = tx.write(buf);
for _ in 0..10 {
block!(timer.wait()).unwrap();
}
@ -102,5 +92,7 @@ fn main() -> ! {
block!(timer.wait()).unwrap();
}
led.set_low();
(buf, tx) = xfer.wait();
}
}