diff options
| author | Jorge Aparicio <jorge@japaric.io> | 2019-09-15 17:09:40 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-15 17:09:40 +0000 |
| commit | 4ff28e9d13e845abf39c662643ae2ff5df57ec16 (patch) | |
| tree | 7d9770cd357e584d85ef6ddc32bddd1a937d1020 /examples/late.rs | |
| parent | fafeeb27270ef24fc3852711c6032f65aa7dbcc0 (diff) | |
| parent | 7aa270cb92180abfc9102a69efdde378c3396b5e (diff) | |
Merge pull request #205 from japaric/heterogeneous
rtfm-syntax refactor + heterogeneous multi-core support
Diffstat (limited to 'examples/late.rs')
| -rw-r--r-- | examples/late.rs | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/examples/late.rs b/examples/late.rs index 0074fb3..2eb12d6 100644 --- a/examples/late.rs +++ b/examples/late.rs @@ -5,38 +5,37 @@ #![no_main] #![no_std] -extern crate panic_semihosting; - use cortex_m_semihosting::{debug, hprintln}; use heapless::{ consts::*, + i, 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> = (); + struct Resources { + p: Producer<'static, u32, U4>, + c: Consumer<'static, u32, U4>, + } #[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<Queue<u32, U4>> = None; + static mut Q: Queue<u32, U4> = 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: 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); @@ -46,8 +45,8 @@ const APP: () = { } } - #[interrupt(resources = [P])] - fn UART0(c: UART0::Context) { - c.resources.P.enqueue(42).unwrap(); + #[task(binds = UART0, resources = [p])] + fn uart0(c: uart0::Context) { + c.resources.p.enqueue(42).unwrap(); } }; |
