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(); + } }