From df790fcc74ae9ffdfc3f533479c6aa6a66aeb201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael?= <40151420+ldericher@users.noreply.github.com> Date: Thu, 21 Mar 2024 19:23:06 +0000 Subject: [PATCH] main.rs task "foo" --- bluepill-rs/src/dmx.rs | 2 +- bluepill-rs/src/main.rs | 30 +++++++++++++++++++----------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/bluepill-rs/src/dmx.rs b/bluepill-rs/src/dmx.rs index c1784c8..9b4dc33 100644 --- a/bluepill-rs/src/dmx.rs +++ b/bluepill-rs/src/dmx.rs @@ -22,7 +22,7 @@ impl DMX { where PINS: serial::Pins, { - let _ = serial.reconfigure(250_000.bps(), &clocks); + serial.reconfigure(250_000.bps(), &clocks).unwrap(); Self::Idle(DMXIdle { tx: Some(serial.tx.with_dma(channel)), diff --git a/bluepill-rs/src/main.rs b/bluepill-rs/src/main.rs index 5b21814..2fd77e8 100644 --- a/bluepill-rs/src/main.rs +++ b/bluepill-rs/src/main.rs @@ -72,6 +72,8 @@ mod app { &clocks, ); + foo::spawn().unwrap(); + ( Shared { buffer: singleton!(: [u8; 512] = [0b01010101; 512]).unwrap(), @@ -90,18 +92,24 @@ mod app { ) } - #[idle(local = [dmx, delay_us, led], shared = [&buffer])] - fn idle(cx: idle::Context) -> ! { + #[idle] + fn idle(_: idle::Context) -> ! { loop { - cx.local.dmx.send(cx.shared.buffer); - - cx.local.delay_us.delay(1.secs()); - cx.local.led.set_high(); - - cx.local.delay_us.delay(1.secs()); - cx.local.led.set_low(); - - cx.local.dmx.wait(); + cortex_m::asm::nop(); } } + + #[task(local = [dmx, delay_us, led], shared = [&buffer])] + fn foo(cx: foo::Context) { + cx.local.dmx.send(cx.shared.buffer); + + cx.local.led.set_low(); + cx.local.delay_us.delay(1.secs()); + + cx.local.led.set_high(); + cx.local.delay_us.delay(1.secs()); + + cx.local.dmx.wait(); + foo::spawn().unwrap(); + } }