streamlining
This commit is contained in:
parent
df790fcc74
commit
91139c792c
1 changed files with 11 additions and 13 deletions
|
@ -9,7 +9,7 @@ mod dmx;
|
||||||
// extern crate panic_halt;
|
// extern crate panic_halt;
|
||||||
extern crate panic_semihosting;
|
extern crate panic_semihosting;
|
||||||
|
|
||||||
#[rtic::app(device = stm32f1xx_hal::pac, dispatchers = [DMA1_CHANNEL4])]
|
#[rtic::app(device = stm32f1xx_hal::pac, dispatchers = [PVD])]
|
||||||
mod app {
|
mod app {
|
||||||
use cortex_m::singleton;
|
use cortex_m::singleton;
|
||||||
use stm32f1xx_hal::{gpio, pac, prelude::*, serial, timer};
|
use stm32f1xx_hal::{gpio, pac, prelude::*, serial, timer};
|
||||||
|
@ -24,12 +24,12 @@ mod app {
|
||||||
#[shared]
|
#[shared]
|
||||||
struct Shared {
|
struct Shared {
|
||||||
buffer: &'static mut [u8; 512],
|
buffer: &'static mut [u8; 512],
|
||||||
|
delay_us: timer::DelayUs<pac::TIM2>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[local]
|
#[local]
|
||||||
struct Local {
|
struct Local {
|
||||||
dmx: DMX,
|
dmx: DMX,
|
||||||
delay_us: timer::DelayUs<pac::TIM2>,
|
|
||||||
led: gpio::gpioc::PC13<gpio::Output>,
|
led: gpio::gpioc::PC13<gpio::Output>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,17 +72,18 @@ mod app {
|
||||||
&clocks,
|
&clocks,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// rtic::pend(pac::Interrupt::DMA1_CHANNEL4); // ???
|
||||||
foo::spawn().unwrap();
|
foo::spawn().unwrap();
|
||||||
|
|
||||||
(
|
(
|
||||||
Shared {
|
Shared {
|
||||||
buffer: singleton!(: [u8; 512] = [0b01010101; 512]).unwrap(),
|
buffer: singleton!(: [u8; 512] = [0b01010101; 512]).unwrap(),
|
||||||
},
|
|
||||||
Local {
|
|
||||||
dmx: DMX::new(serial, dma1.4, &clocks),
|
|
||||||
|
|
||||||
// Configure timer
|
// Configure timer
|
||||||
delay_us: cx.device.TIM2.delay_us(&clocks),
|
delay_us: cx.device.TIM2.delay_us(&clocks),
|
||||||
|
},
|
||||||
|
Local {
|
||||||
|
dmx: DMX::new(serial, dma1.4, &clocks),
|
||||||
|
|
||||||
// Configure gpio C pin 13 as a push-pull output. The `crh` register is passed to the function
|
// 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.
|
// in order to configure the port. For pins 0-7, crl should be passed instead.
|
||||||
|
@ -95,19 +96,16 @@ mod app {
|
||||||
#[idle]
|
#[idle]
|
||||||
fn idle(_: idle::Context) -> ! {
|
fn idle(_: idle::Context) -> ! {
|
||||||
loop {
|
loop {
|
||||||
cortex_m::asm::nop();
|
rtic::export::wfi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(local = [dmx, delay_us, led], shared = [&buffer])]
|
#[task(local = [dmx, led], shared = [&buffer, delay_us])]
|
||||||
fn foo(cx: foo::Context) {
|
fn foo(mut cx: foo::Context) {
|
||||||
cx.local.dmx.send(cx.shared.buffer);
|
cx.local.dmx.send(cx.shared.buffer);
|
||||||
|
|
||||||
cx.local.led.set_low();
|
cx.local.led.toggle();
|
||||||
cx.local.delay_us.delay(1.secs());
|
cx.shared.delay_us.lock(|d| d.delay(1.secs()));
|
||||||
|
|
||||||
cx.local.led.set_high();
|
|
||||||
cx.local.delay_us.delay(1.secs());
|
|
||||||
|
|
||||||
cx.local.dmx.wait();
|
cx.local.dmx.wait();
|
||||||
foo::spawn().unwrap();
|
foo::spawn().unwrap();
|
||||||
|
|
Loading…
Reference in a new issue