From 08229bc0e9e1d37cfa9aac9082f63dcf432418fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael?= <40151420+ldericher@users.noreply.github.com> Date: Fri, 1 Mar 2024 15:18:26 +0000 Subject: [PATCH] repeated dma send --- src/main.rs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1b33e23..a82cce7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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(); } }