From 07b2b4d83078d0fd260d5f0812e8d5a34d02b793 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 21 Aug 2019 10:17:27 +0200 Subject: doc up --- examples/resource.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'examples/resource.rs') diff --git a/examples/resource.rs b/examples/resource.rs index 2506a2c..8632525 100644 --- a/examples/resource.rs +++ b/examples/resource.rs @@ -23,29 +23,31 @@ const APP: () = { rtfm::pend(Interrupt::UART1); } + // `shared` cannot be accessed from this context #[idle] - fn idle(_: idle::Context) -> ! { + fn idle(_cx: idle::Context) -> ! { debug::exit(debug::EXIT_SUCCESS); - // error: `shared` can't be accessed from this context - // shared += 1; + // error: no `resources` field in `idle::Context` + // _cx.resources.shared += 1; loop {} } - // `shared` can be access from this context + // `shared` can be accessed from this context #[task(binds = UART0, resources = [shared])] - fn uart0(c: uart0::Context) { - *c.resources.shared += 1; + fn uart0(cx: uart0::Context) { + let shared: &mut u32 = cx.resources.shared; + *shared += 1; - hprintln!("UART0: shared = {}", c.resources.shared).unwrap(); + hprintln!("UART0: shared = {}", shared).unwrap(); } - // `shared` can be access from this context + // `shared` can be accessed from this context #[task(binds = UART1, resources = [shared])] - fn uart1(c: uart1::Context) { - *c.resources.shared += 1; + fn uart1(cx: uart1::Context) { + *cx.resources.shared += 1; - hprintln!("UART1: shared = {}", c.resources.shared).unwrap(); + hprintln!("UART1: shared = {}", cx.resources.shared).unwrap(); } }; -- cgit v1.2.3