diff options
Diffstat (limited to 'examples/resource.rs')
-rw-r--r-- | examples/resource.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/examples/resource.rs b/examples/resource.rs index c8c57bf5..2c7dffe3 100644 --- a/examples/resource.rs +++ b/examples/resource.rs @@ -12,19 +12,20 @@ mod app { use cortex_m_semihosting::{debug, hprintln}; use lm3s6965::Interrupt; - #[resources] - struct Resources { - // A resource - #[init(0)] + #[shared] + struct Shared { shared: u32, } + #[local] + struct Local {} + #[init] - fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { + fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { rtic::pend(Interrupt::UART0); rtic::pend(Interrupt::UART1); - (init::LateResources {}, init::Monotonics()) + (Shared { shared: 0 }, Local {}, init::Monotonics()) } // `shared` cannot be accessed from this context @@ -32,8 +33,8 @@ mod app { fn idle(_cx: idle::Context) -> ! { debug::exit(debug::EXIT_SUCCESS); - // error: no `resources` field in `idle::Context` - // _cx.resources.shared += 1; + // error: no `shared` field in `idle::Context` + // _cx.shared.shared += 1; loop { cortex_m::asm::nop(); @@ -42,9 +43,9 @@ mod app { // `shared` can be accessed from this context // defaults to priority 1 - #[task(binds = UART0, resources = [shared])] + #[task(binds = UART0, shared = [shared])] fn uart0(mut cx: uart0::Context) { - let shared = cx.resources.shared.lock(|shared| { + let shared = cx.shared.shared.lock(|shared| { *shared += 1; *shared }); @@ -54,9 +55,9 @@ mod app { // `shared` can be accessed from this context // explicitly set to priority 2 - #[task(binds = UART1, resources = [shared], priority = 2)] + #[task(binds = UART1, shared = [shared], priority = 2)] fn uart1(mut cx: uart1::Context) { - let shared = cx.resources.shared.lock(|shared| { + let shared = cx.shared.shared.lock(|shared| { *shared += 1; *shared }); |