diff --git a/examples/late.rs b/examples/late.rs index be656408cf..622008a7fe 100644 --- a/examples/late.rs +++ b/examples/late.rs @@ -22,7 +22,7 @@ const APP: () = { static mut C: Consumer<'static, u32, U4> = (); #[init] - fn init() { + fn init() -> init::LateResources { // NOTE: we use `Option` here to work around the lack of // a stable `const` constructor static mut Q: Option> = None; @@ -31,8 +31,7 @@ const APP: () = { let (p, c) = Q.as_mut().unwrap().split(); // Initialization of late resources - P = p; - C = c; + init::LateResources { P: p, C: c } } #[idle(resources = [C])] diff --git a/examples/singleton.rs b/examples/singleton.rs index 79815e8852..9e48e54121 100644 --- a/examples/singleton.rs +++ b/examples/singleton.rs @@ -20,10 +20,12 @@ const APP: () = { static mut P: Pool = (); #[init(resources = [M])] - fn init() { + fn init() -> init::LateResources { rtfm::pend(Interrupt::I2C0); - P = Pool::new(resources.M); + init::LateResources { + P: Pool::new(resources.M), + } } #[interrupt( diff --git a/examples/static.rs b/examples/static.rs index d40fdb1a6d..0309b68163 100644 --- a/examples/static.rs +++ b/examples/static.rs @@ -16,11 +16,11 @@ const APP: () = { static KEY: u32 = (); #[init] - fn init() { + fn init() -> init::LateResources { rtfm::pend(Interrupt::UART0); rtfm::pend(Interrupt::UART1); - KEY = 0xdeadbeef; + init::LateResources { KEY: 0xdeadbeef } } #[interrupt(resources = [KEY])] diff --git a/tests/cfail/init-divergent.rs b/tests/cfail/init-divergent.rs index 400c805e91..54813d479f 100644 --- a/tests/cfail/init-divergent.rs +++ b/tests/cfail/init-divergent.rs @@ -11,7 +11,7 @@ use rtfm::app; const APP: () = { #[init] fn init() -> ! { - //~^ ERROR `init` must have type signature `[unsafe] fn()` + //~^ ERROR `init` must have type signature `[unsafe] fn() [-> init::LateResources]` loop {} } }; diff --git a/tests/cfail/init-input.rs b/tests/cfail/init-input.rs index fa79099c35..3bf0cadf13 100644 --- a/tests/cfail/init-input.rs +++ b/tests/cfail/init-input.rs @@ -11,6 +11,6 @@ use rtfm::app; const APP: () = { #[init] fn init(undef: u32) { - //~^ ERROR `init` must have type signature `[unsafe] fn()` + //~^ ERROR `init` must have type signature `[unsafe] fn() [-> init::LateResources]` } }; diff --git a/tests/cfail/init-output.rs b/tests/cfail/init-output.rs index 1200aca774..414a35a83a 100644 --- a/tests/cfail/init-output.rs +++ b/tests/cfail/init-output.rs @@ -11,7 +11,7 @@ use rtfm::app; const APP: () = { #[init] fn init() -> u32 { - //~^ ERROR `init` must have type signature `[unsafe] fn()` + //~^ ERROR `init` must have type signature `[unsafe] fn() [-> init::LateResources]` 0 } }; diff --git a/tests/cfail/late-not-send.rs b/tests/cfail/late-not-send.rs index b9180fed9d..eb3048d90f 100644 --- a/tests/cfail/late-not-send.rs +++ b/tests/cfail/late-not-send.rs @@ -22,8 +22,10 @@ const APP: () = { static mut X: NotSend = (); #[init] - fn init() { - X = NotSend { _0: PhantomData }; + fn init() -> init::LateResources { + init::LateResources { + X: NotSend { _0: PhantomData }, + } } #[interrupt(resources = [X])] diff --git a/tests/cfail/late-uninit.rs b/tests/cfail/late-uninit.rs index eeb9bd4191..55122ed7e4 100644 --- a/tests/cfail/late-uninit.rs +++ b/tests/cfail/late-uninit.rs @@ -1,3 +1,5 @@ +// TODO remove in v0.5.x + #![no_main] #![no_std] diff --git a/tests/cpass/late-not-send.rs b/tests/cpass/late-not-send.rs index 06d376bdf1..5b278ab5c3 100644 --- a/tests/cpass/late-not-send.rs +++ b/tests/cpass/late-not-send.rs @@ -19,10 +19,12 @@ const APP: () = { static mut Y: Option = None; #[init(resources = [Y])] - fn init() { + fn init() -> init::LateResources { *resources.Y = Some(NotSend { _0: PhantomData }); - X = NotSend { _0: PhantomData }; + init::LateResources { + X: NotSend { _0: PhantomData }, + } } #[idle(resources = [X, Y])] diff --git a/tests/cpass/late-resource.rs b/tests/cpass/late-resource.rs index 94ec8c9676..0dec4cbee0 100644 --- a/tests/cpass/late-resource.rs +++ b/tests/cpass/late-resource.rs @@ -14,8 +14,7 @@ const APP: () = { static Y: u32 = (); #[init] - fn init() { - X = 0; - Y = 1; + fn init() -> init::LateResources { + init::LateResources { X: 0, Y: 1 } } };