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/late.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'examples/late.rs') diff --git a/examples/late.rs b/examples/late.rs index 0074fb3..4d48a6a 100644 --- a/examples/late.rs +++ b/examples/late.rs @@ -5,20 +5,21 @@ #![no_main] #![no_std] -extern crate panic_semihosting; - use cortex_m_semihosting::{debug, hprintln}; use heapless::{ consts::*, spsc::{Consumer, Producer, Queue}, }; use lm3s6965::Interrupt; +use panic_semihosting as _; #[rtfm::app(device = lm3s6965)] const APP: () = { // Late resources - static mut P: Producer<'static, u32, U4> = (); - static mut C: Consumer<'static, u32, U4> = (); + extern "C" { + static mut P: Producer<'static, u32, U4>; + static mut C: Consumer<'static, u32, U4>; + } #[init] fn init(_: init::Context) -> init::LateResources { -- 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/late.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples/late.rs') diff --git a/examples/late.rs b/examples/late.rs index 4d48a6a..19807ff 100644 --- a/examples/late.rs +++ b/examples/late.rs @@ -47,8 +47,8 @@ const APP: () = { } } - #[interrupt(resources = [P])] - fn UART0(c: UART0::Context) { + #[task(binds = UART0, resources = [P])] + fn uart0(c: uart0::Context) { c.resources.P.enqueue(42).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/late.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'examples/late.rs') diff --git a/examples/late.rs b/examples/late.rs index 19807ff..536d71a 100644 --- a/examples/late.rs +++ b/examples/late.rs @@ -16,9 +16,9 @@ use panic_semihosting as _; #[rtfm::app(device = lm3s6965)] const APP: () = { // Late resources - extern "C" { - static mut P: Producer<'static, u32, U4>; - static mut C: Consumer<'static, u32, U4>; + struct Resources { + p: Producer<'static, u32, U4>, + c: Consumer<'static, u32, U4>, } #[init] @@ -31,13 +31,13 @@ const APP: () = { let (p, c) = Q.as_mut().unwrap().split(); // Initialization of late resources - init::LateResources { P: p, C: c } + init::LateResources { p, c } } - #[idle(resources = [C])] + #[idle(resources = [c])] fn idle(c: idle::Context) -> ! { loop { - if let Some(byte) = c.resources.C.dequeue() { + if let Some(byte) = c.resources.c.dequeue() { hprintln!("received message: {}", byte).unwrap(); debug::exit(debug::EXIT_SUCCESS); @@ -47,8 +47,8 @@ const APP: () = { } } - #[task(binds = UART0, resources = [P])] + #[task(binds = UART0, resources = [p])] fn uart0(c: uart0::Context) { - c.resources.P.enqueue(42).unwrap(); + c.resources.p.enqueue(42).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/late.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'examples/late.rs') diff --git a/examples/late.rs b/examples/late.rs index 536d71a..2eb12d6 100644 --- a/examples/late.rs +++ b/examples/late.rs @@ -8,6 +8,7 @@ use cortex_m_semihosting::{debug, hprintln}; use heapless::{ consts::*, + i, spsc::{Consumer, Producer, Queue}, }; use lm3s6965::Interrupt; @@ -23,12 +24,9 @@ const APP: () = { #[init] fn init(_: init::Context) -> init::LateResources { - // NOTE: we use `Option` here to work around the lack of - // a stable `const` constructor - static mut Q: Option> = None; + static mut Q: Queue = Queue(i::Queue::new()); - *Q = Some(Queue::new()); - let (p, c) = Q.as_mut().unwrap().split(); + let (p, c) = Q.split(); // Initialization of late resources init::LateResources { p, c } -- cgit v1.2.3