2019-06-13 23:56:59 +02:00
|
|
|
//! [compile-pass] Cross initialization of late resources
|
|
|
|
|
|
|
|
#![deny(unsafe_code)]
|
|
|
|
#![deny(warnings)]
|
|
|
|
#![no_main]
|
|
|
|
#![no_std]
|
|
|
|
|
|
|
|
use panic_halt as _;
|
|
|
|
|
2019-06-18 10:31:31 +02:00
|
|
|
#[rtfm::app(cores = 2, device = homogeneous)]
|
2019-06-13 23:56:59 +02:00
|
|
|
const APP: () = {
|
2019-07-10 22:42:44 +02:00
|
|
|
struct Resources {
|
2019-06-13 23:56:59 +02:00
|
|
|
// owned by core #1 but initialized by core #0
|
2019-07-10 22:42:44 +02:00
|
|
|
x: u32,
|
2019-06-13 23:56:59 +02:00
|
|
|
|
|
|
|
// owned by core #0 but initialized by core #1
|
2019-07-10 22:42:44 +02:00
|
|
|
y: u32,
|
2019-06-13 23:56:59 +02:00
|
|
|
}
|
|
|
|
|
2019-07-10 22:42:44 +02:00
|
|
|
#[init(core = 0, late = [x])]
|
2019-06-13 23:56:59 +02:00
|
|
|
fn a(_: a::Context) -> a::LateResources {
|
2019-07-10 22:42:44 +02:00
|
|
|
a::LateResources { x: 0 }
|
2019-06-13 23:56:59 +02:00
|
|
|
}
|
|
|
|
|
2019-07-10 22:42:44 +02:00
|
|
|
#[idle(core = 0, resources = [y])]
|
2019-06-13 23:56:59 +02:00
|
|
|
fn b(_: b::Context) -> ! {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[init(core = 1)]
|
|
|
|
fn c(_: c::Context) -> c::LateResources {
|
2019-07-10 22:42:44 +02:00
|
|
|
c::LateResources { y: 0 }
|
2019-06-13 23:56:59 +02:00
|
|
|
}
|
|
|
|
|
2019-07-10 22:42:44 +02:00
|
|
|
#[idle(core = 1, resources = [x])]
|
2019-06-13 23:56:59 +02:00
|
|
|
fn d(_: d::Context) -> ! {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
};
|