diff options
Diffstat (limited to 'examples/resource-user-struct.rs')
-rw-r--r-- | examples/resource-user-struct.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/examples/resource-user-struct.rs b/examples/resource-user-struct.rs index 6ad540b0..1ebaa59e 100644 --- a/examples/resource-user-struct.rs +++ b/examples/resource-user-struct.rs @@ -12,26 +12,28 @@ mod app { use cortex_m_semihosting::{debug, hprintln}; use lm3s6965::Interrupt; - #[resources] - struct Resources { + #[shared] + struct Shared { // A resource - #[init(0)] shared: u32, } // Should not collide with the struct above #[allow(dead_code)] - struct Resources2 { + struct Shared2 { // A resource 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 @@ -39,16 +41,16 @@ 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 {} } // `shared` can be accessed from this context - #[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 }); @@ -57,9 +59,9 @@ mod app { } // `shared` can be accessed from this context - #[task(binds = UART1, resources = [shared])] + #[task(binds = UART1, shared = [shared])] fn uart1(mut cx: uart1::Context) { - let shared = cx.resources.shared.lock(|shared| { + let shared = cx.shared.shared.lock(|shared| { *shared += 1; *shared }); |