diff options
Diffstat (limited to 'examples/periodic.rs')
-rw-r--r-- | examples/periodic.rs | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/examples/periodic.rs b/examples/periodic.rs index ba2b4933..d3aedd32 100644 --- a/examples/periodic.rs +++ b/examples/periodic.rs @@ -5,30 +5,37 @@ #![no_main] #![no_std] -extern crate panic_semihosting; - use cortex_m_semihosting::hprintln; -use rtfm::{app, Instant}; +use panic_semihosting as _; +use rtic::cyccnt::{Instant, U32Ext}; const PERIOD: u32 = 8_000_000; // NOTE: does NOT work on QEMU! -#[app(device = lm3s6965)] -const APP: () = { +#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)] +mod app { + #[init(schedule = [foo])] - fn init() { - schedule.foo(Instant::now() + PERIOD.cycles()).unwrap(); + fn init(cx: init::Context) -> init::LateResources { + // omitted: initialization of `CYCCNT` + + cx.schedule.foo(cx.start + PERIOD.cycles()).unwrap(); + + init::LateResources {} } #[task(schedule = [foo])] - fn foo() { + fn foo(cx: foo::Context) { let now = Instant::now(); - hprintln!("foo(scheduled = {:?}, now = {:?})", scheduled, now).unwrap(); + hprintln!("foo(scheduled = {:?}, now = {:?})", cx.scheduled, now).unwrap(); - schedule.foo(scheduled + PERIOD.cycles()).unwrap(); + cx.schedule.foo(cx.scheduled + PERIOD.cycles()).unwrap(); } + // RTIC requires that unused interrupts are declared in an extern block when + // using software tasks; these free interrupts will be used to dispatch the + // software tasks. extern "C" { - fn UART0(); + fn SSI0(); } -}; +} |