diff options
Diffstat (limited to 'examples/periodic.rs')
| -rw-r--r-- | examples/periodic.rs | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/examples/periodic.rs b/examples/periodic.rs index 29fa6bd..82c2128 100644 --- a/examples/periodic.rs +++ b/examples/periodic.rs @@ -10,25 +10,31 @@ use panic_semihosting as _; // NOTE: does NOT work on QEMU! #[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { - use cortex_m_semihosting::hprintln; - use rtic::cyccnt::{Instant, U32Ext}; + use dwt_systick_monotonic::{ + consts::{U0, U8}, + DwtSystick, + }; + use rtic::time::duration::Seconds; - const PERIOD: u32 = 8_000_000; + #[monotonic(binds = SysTick, default = true)] + type MyMono = DwtSystick<U8, U0, U0>; // 8 MHz #[init] fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) { - // omitted: initialization of `CYCCNT` + let mut dcb = cx.core.DCB; + let dwt = cx.core.DWT; + let systick = cx.core.SYST; - foo::schedule(cx.start + PERIOD.cycles()).unwrap(); + let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000); - (init::LateResources {}, init::Monotonics()) + foo::spawn_after(Seconds(1_u32)).unwrap(); + + (init::LateResources {}, init::Monotonics(mono)) } #[task] - fn foo(cx: foo::Context) { - let now = Instant::now(); - hprintln!("foo(scheduled = {:?}, now = {:?})", cx.scheduled, now).unwrap(); - - foo::schedule(cx.scheduled + PERIOD.cycles()).unwrap(); + fn foo(_cx: foo::Context) { + // Periodic + foo::spawn_after(Seconds(1_u32)).unwrap(); } } |
