main.rs task "foo"

This commit is contained in:
Jörn-Michael Miehe 2024-03-21 19:23:06 +00:00
parent a82f68d546
commit df790fcc74
2 changed files with 20 additions and 12 deletions

View file

@ -22,7 +22,7 @@ impl DMX {
where
PINS: serial::Pins<pac::USART1>,
{
let _ = serial.reconfigure(250_000.bps(), &clocks);
serial.reconfigure(250_000.bps(), &clocks).unwrap();
Self::Idle(DMXIdle {
tx: Some(serial.tx.with_dma(channel)),

View file

@ -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 {
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.delay_us.delay(1.secs());
cx.local.led.set_high();
cx.local.delay_us.delay(1.secs());
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();
}
}