Compare commits

..

No commits in common. "91139c792c3c464f1c6fa0c18473b246519125c1" and "a82f68d546ad9224e2773c8139cb497b4adfbf6a" have entirely different histories.

2 changed files with 17 additions and 23 deletions

View file

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

View file

@ -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 = [PVD])] #[rtic::app(device = stm32f1xx_hal::pac, dispatchers = [DMA1_CHANNEL4])]
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,19 +72,16 @@ mod app {
&clocks, &clocks,
); );
// rtic::pend(pac::Interrupt::DMA1_CHANNEL4); // ???
foo::spawn().unwrap();
( (
Shared { Shared {
buffer: singleton!(: [u8; 512] = [0b01010101; 512]).unwrap(), buffer: singleton!(: [u8; 512] = [0b01010101; 512]).unwrap(),
// Configure timer
delay_us: cx.device.TIM2.delay_us(&clocks),
}, },
Local { Local {
dmx: DMX::new(serial, dma1.4, &clocks), dmx: DMX::new(serial, dma1.4, &clocks),
// Configure timer
delay_us: cx.device.TIM2.delay_us(&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.
led: gpioc.pc13.into_push_pull_output(&mut gpioc.crh), led: gpioc.pc13.into_push_pull_output(&mut gpioc.crh),
@ -93,21 +90,18 @@ mod app {
) )
} }
#[idle] #[idle(local = [dmx, delay_us, led], shared = [&buffer])]
fn idle(_: idle::Context) -> ! { fn idle(cx: idle::Context) -> ! {
loop { loop {
rtic::export::wfi();
}
}
#[task(local = [dmx, led], shared = [&buffer, delay_us])]
fn foo(mut cx: foo::Context) {
cx.local.dmx.send(cx.shared.buffer); cx.local.dmx.send(cx.shared.buffer);
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.led.set_low();
cx.local.dmx.wait(); cx.local.dmx.wait();
foo::spawn().unwrap(); }
} }
} }