diff options
Diffstat (limited to 'examples/hardware.rs')
-rw-r--r-- | examples/hardware.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/examples/hardware.rs b/examples/hardware.rs index 3cf98807..5dff8222 100644 --- a/examples/hardware.rs +++ b/examples/hardware.rs @@ -12,15 +12,21 @@ mod app { use cortex_m_semihosting::{debug, hprintln}; use lm3s6965::Interrupt; + #[shared] + struct Shared {} + + #[local] + struct Local {} + #[init] - fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { + fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { // Pends the UART0 interrupt but its handler won't run until *after* // `init` returns because interrupts are disabled rtic::pend(Interrupt::UART0); // equivalent to NVIC::pend hprintln!("init").unwrap(); - (init::LateResources {}, init::Monotonics()) + (Shared {}, Local {}, init::Monotonics()) } #[idle] @@ -38,17 +44,15 @@ mod app { } } - #[task(binds = UART0)] - fn uart0(_: uart0::Context) { - static mut TIMES: u32 = 0; - + #[task(binds = UART0, local = [times: u32 = 0])] + fn uart0(cx: uart0::Context) { // Safe access to local `static mut` variable - *TIMES += 1; + *cx.local.times += 1; hprintln!( "UART0 called {} time{}", - *TIMES, - if *TIMES > 1 { "s" } else { "" } + *cx.local.times, + if *cx.local.times > 1 { "s" } else { "" } ) .unwrap(); } |