main.rs task "foo"
This commit is contained in:
parent
a82f68d546
commit
df790fcc74
2 changed files with 20 additions and 12 deletions
|
@ -22,7 +22,7 @@ impl DMX {
|
||||||
where
|
where
|
||||||
PINS: serial::Pins<pac::USART1>,
|
PINS: serial::Pins<pac::USART1>,
|
||||||
{
|
{
|
||||||
let _ = serial.reconfigure(250_000.bps(), &clocks);
|
serial.reconfigure(250_000.bps(), &clocks).unwrap();
|
||||||
|
|
||||||
Self::Idle(DMXIdle {
|
Self::Idle(DMXIdle {
|
||||||
tx: Some(serial.tx.with_dma(channel)),
|
tx: Some(serial.tx.with_dma(channel)),
|
||||||
|
|
|
@ -72,6 +72,8 @@ mod app {
|
||||||
&clocks,
|
&clocks,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
foo::spawn().unwrap();
|
||||||
|
|
||||||
(
|
(
|
||||||
Shared {
|
Shared {
|
||||||
buffer: singleton!(: [u8; 512] = [0b01010101; 512]).unwrap(),
|
buffer: singleton!(: [u8; 512] = [0b01010101; 512]).unwrap(),
|
||||||
|
@ -90,18 +92,24 @@ mod app {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[idle(local = [dmx, delay_us, led], shared = [&buffer])]
|
#[idle]
|
||||||
fn idle(cx: idle::Context) -> ! {
|
fn idle(_: idle::Context) -> ! {
|
||||||
loop {
|
loop {
|
||||||
cx.local.dmx.send(cx.shared.buffer);
|
cortex_m::asm::nop();
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue