From 81275bfa4f41e2066770087f3a33cad4227eab41 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 13 Jun 2019 23:56:59 +0200 Subject: rtfm-syntax refactor + heterogeneous multi-core support --- examples/resource.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'examples/resource.rs') diff --git a/examples/resource.rs b/examples/resource.rs index 06bdf39..8268950 100644 --- a/examples/resource.rs +++ b/examples/resource.rs @@ -5,10 +5,9 @@ #![no_main] #![no_std] -extern crate panic_semihosting; - use cortex_m_semihosting::{debug, hprintln}; use lm3s6965::Interrupt; +use panic_semihosting as _; #[rtfm::app(device = lm3s6965)] const APP: () = { @@ -33,7 +32,7 @@ const APP: () = { // `SHARED` can be access from this context #[interrupt(resources = [SHARED])] - fn UART0(mut c: UART0::Context) { + fn UART0(c: UART0::Context) { *c.resources.SHARED += 1; hprintln!("UART0: SHARED = {}", c.resources.SHARED).unwrap(); @@ -41,7 +40,7 @@ const APP: () = { // `SHARED` can be access from this context #[interrupt(resources = [SHARED])] - fn UART1(mut c: UART1::Context) { + fn UART1(c: UART1::Context) { *c.resources.SHARED += 1; hprintln!("UART1: SHARED = {}", c.resources.SHARED).unwrap(); -- cgit v1.2.3 From 4e51bb68b976c6bb6a9a989dc560d2a8123a84ca Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 20 Jun 2019 06:19:59 +0200 Subject: RFC #207 --- examples/resource.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'examples/resource.rs') diff --git a/examples/resource.rs b/examples/resource.rs index 8268950..661f8c3 100644 --- a/examples/resource.rs +++ b/examples/resource.rs @@ -31,16 +31,16 @@ const APP: () = { } // `SHARED` can be access from this context - #[interrupt(resources = [SHARED])] - fn UART0(c: UART0::Context) { + #[task(binds = UART0, resources = [SHARED])] + fn uart0(c: uart0::Context) { *c.resources.SHARED += 1; hprintln!("UART0: SHARED = {}", c.resources.SHARED).unwrap(); } // `SHARED` can be access from this context - #[interrupt(resources = [SHARED])] - fn UART1(c: UART1::Context) { + #[task(binds = UART1, resources = [SHARED])] + fn uart1(c: uart1::Context) { *c.resources.SHARED += 1; hprintln!("UART1: SHARED = {}", c.resources.SHARED).unwrap(); -- cgit v1.2.3 From 9195038c87703fc94b6e99f6de593886d51c2b19 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 10 Jul 2019 22:42:44 +0200 Subject: implement RFC #212 --- examples/resource.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'examples/resource.rs') diff --git a/examples/resource.rs b/examples/resource.rs index 661f8c3..2506a2c 100644 --- a/examples/resource.rs +++ b/examples/resource.rs @@ -11,8 +11,11 @@ use panic_semihosting as _; #[rtfm::app(device = lm3s6965)] const APP: () = { - // A resource - static mut SHARED: u32 = 0; + struct Resources { + // A resource + #[init(0)] + shared: u32, + } #[init] fn init(_: init::Context) { @@ -24,25 +27,25 @@ const APP: () = { fn idle(_: idle::Context) -> ! { debug::exit(debug::EXIT_SUCCESS); - // error: `SHARED` can't be accessed from this context - // SHARED += 1; + // error: `shared` can't be accessed from this context + // shared += 1; loop {} } - // `SHARED` can be access from this context - #[task(binds = UART0, resources = [SHARED])] + // `shared` can be access from this context + #[task(binds = UART0, resources = [shared])] fn uart0(c: uart0::Context) { - *c.resources.SHARED += 1; + *c.resources.shared += 1; - hprintln!("UART0: SHARED = {}", c.resources.SHARED).unwrap(); + hprintln!("UART0: shared = {}", c.resources.shared).unwrap(); } - // `SHARED` can be access from this context - #[task(binds = UART1, resources = [SHARED])] + // `shared` can be access from this context + #[task(binds = UART1, resources = [shared])] fn uart1(c: uart1::Context) { - *c.resources.SHARED += 1; + *c.resources.shared += 1; - hprintln!("UART1: SHARED = {}", c.resources.SHARED).unwrap(); + hprintln!("UART1: shared = {}", c.resources.shared).unwrap(); } }; -- cgit v1.2.3 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