aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/baseline.rs4
-rw-r--r--examples/binds.rs4
-rw-r--r--examples/capacity.rs4
-rw-r--r--examples/cfg.rs4
-rw-r--r--examples/destructure.rs4
-rw-r--r--examples/generics.rs4
-rw-r--r--examples/hardware.rs4
-rw-r--r--examples/idle.rs4
-rw-r--r--examples/init.rs4
-rw-r--r--examples/lock.rs4
-rw-r--r--examples/message.rs4
-rw-r--r--examples/not-send.rs4
-rw-r--r--examples/not-sync.rs4
-rw-r--r--examples/periodic.rs4
-rw-r--r--examples/peripherals-taken.rs4
-rw-r--r--examples/pool.rs4
-rw-r--r--examples/preempt.rs4
-rw-r--r--examples/ramfunc.rs4
-rw-r--r--examples/resource.rs4
-rw-r--r--examples/schedule.rs4
-rw-r--r--examples/shared-with-init.rs4
-rw-r--r--examples/t-binds.rs4
-rw-r--r--examples/t-cfg.rs4
-rw-r--r--examples/t-htask-main.rs6
-rw-r--r--examples/t-idle-main.rs4
-rw-r--r--examples/t-init-main.rs4
-rw-r--r--examples/t-resource.rs4
-rw-r--r--examples/t-schedule.rs4
-rw-r--r--examples/t-spawn.rs4
-rw-r--r--examples/t-stask-main.rs4
-rw-r--r--examples/task.rs4
-rw-r--r--examples/types.rs4
32 files changed, 97 insertions, 33 deletions
diff --git a/examples/baseline.rs b/examples/baseline.rs
index f46b273d..5a6dbd4c 100644
--- a/examples/baseline.rs
+++ b/examples/baseline.rs
@@ -13,13 +13,15 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
const APP: () = {
#[init(spawn = [foo])]
- fn init(cx: init::Context) {
+ fn init(cx: init::Context) -> init::LateResources {
// omitted: initialization of `CYCCNT`
hprintln!("init(baseline = {:?})", cx.start).unwrap();
// `foo` inherits the baseline of `init`: `Instant(0)`
cx.spawn.foo().unwrap();
+
+ init::LateResources {}
}
#[task(schedule = [foo])]
diff --git a/examples/binds.rs b/examples/binds.rs
index 82bf8964..f3ce51ec 100644
--- a/examples/binds.rs
+++ b/examples/binds.rs
@@ -13,10 +13,12 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
const APP: () = {
#[init]
- fn init(_: init::Context) {
+ fn init(_: init::Context) -> init::LateResources {
rtic::pend(Interrupt::UART0);
hprintln!("init").unwrap();
+
+ init::LateResources {}
}
#[idle]
diff --git a/examples/capacity.rs b/examples/capacity.rs
index 00cec344..cac0029c 100644
--- a/examples/capacity.rs
+++ b/examples/capacity.rs
@@ -12,8 +12,10 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
const APP: () = {
#[init]
- fn init(_: init::Context) {
+ fn init(_: init::Context) -> init::LateResources {
rtic::pend(Interrupt::UART0);
+
+ init::LateResources {}
}
#[task(binds = UART0, spawn = [foo, bar])]
diff --git a/examples/cfg.rs b/examples/cfg.rs
index 8eeeb2a9..4f467247 100644
--- a/examples/cfg.rs
+++ b/examples/cfg.rs
@@ -19,9 +19,11 @@ const APP: () = {
}
#[init(spawn = [foo])]
- fn init(cx: init::Context) {
+ fn init(cx: init::Context) -> init::LateResources {
cx.spawn.foo().unwrap();
cx.spawn.foo().unwrap();
+
+ init::LateResources {}
}
#[idle]
diff --git a/examples/destructure.rs b/examples/destructure.rs
index 1756bd9e..ad1d8594 100644
--- a/examples/destructure.rs
+++ b/examples/destructure.rs
@@ -22,9 +22,11 @@ const APP: () = {
}
#[init]
- fn init(_: init::Context) {
+ fn init(_: init::Context) -> init::LateResources {
rtic::pend(Interrupt::UART0);
rtic::pend(Interrupt::UART1);
+
+ init::LateResources {}
}
// Direct destructure
diff --git a/examples/generics.rs b/examples/generics.rs
index 40ab81ac..65c5db02 100644
--- a/examples/generics.rs
+++ b/examples/generics.rs
@@ -18,9 +18,11 @@ const APP: () = {
}
#[init]
- fn init(_: init::Context) {
+ fn init(_: init::Context) -> init::LateResources {
rtic::pend(Interrupt::UART0);
rtic::pend(Interrupt::UART1);
+
+ init::LateResources {}
}
#[task(binds = UART0, resources = [shared])]
diff --git a/examples/hardware.rs b/examples/hardware.rs
index 8105a742..30de77ab 100644
--- a/examples/hardware.rs
+++ b/examples/hardware.rs
@@ -12,12 +12,14 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
const APP: () = {
#[init]
- fn init(_: init::Context) {
+ fn init(_: init::Context) -> init::LateResources {
// Pends the UART0 interrupt but its handler won't run until *after*
// `init` returns because interrupts are disabled
rtic::pend(Interrupt::UART0); // equivalent to NVIC::pend
hprintln!("init").unwrap();
+
+ init::LateResources {}
}
#[idle]
diff --git a/examples/idle.rs b/examples/idle.rs
index 3d28dac8..b029fcae 100644
--- a/examples/idle.rs
+++ b/examples/idle.rs
@@ -11,8 +11,10 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
const APP: () = {
#[init]
- fn init(_: init::Context) {
+ fn init(_: init::Context) -> init::LateResources {
hprintln!("init").unwrap();
+
+ init::LateResources {}
}
#[idle]
diff --git a/examples/init.rs b/examples/init.rs
index 315969f0..d5cebbaa 100644
--- a/examples/init.rs
+++ b/examples/init.rs
@@ -11,7 +11,7 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965, peripherals = true)]
const APP: () = {
#[init]
- fn init(cx: init::Context) {
+ fn init(cx: init::Context) -> init::LateResources {
static mut X: u32 = 0;
// Cortex-M peripherals
@@ -26,5 +26,7 @@ const APP: () = {
hprintln!("init").unwrap();
debug::exit(debug::EXIT_SUCCESS);
+
+ init::LateResources {}
}
};
diff --git a/examples/lock.rs b/examples/lock.rs
index 5e3bce25..ff947c53 100644
--- a/examples/lock.rs
+++ b/examples/lock.rs
@@ -17,8 +17,10 @@ const APP: () = {
}
#[init]
- fn init(_: init::Context) {
+ fn init(_: init::Context) -> init::LateResources {
rtic::pend(Interrupt::GPIOA);
+
+ init::LateResources {}
}
// when omitted priority is assumed to be `1`
diff --git a/examples/message.rs b/examples/message.rs
index 596f2449..a1352c0e 100644
--- a/examples/message.rs
+++ b/examples/message.rs
@@ -11,8 +11,10 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
const APP: () = {
#[init(spawn = [foo])]
- fn init(c: init::Context) {
+ fn init(c: init::Context) -> init::LateResources {
c.spawn.foo(/* no message */).unwrap();
+
+ init::LateResources {}
}
#[task(spawn = [bar])]
diff --git a/examples/not-send.rs b/examples/not-send.rs
index 16a874dc..999abfaf 100644
--- a/examples/not-send.rs
+++ b/examples/not-send.rs
@@ -23,9 +23,11 @@ const APP: () = {
}
#[init(spawn = [baz, quux])]
- fn init(c: init::Context) {
+ fn init(c: init::Context) -> init::LateResources {
c.spawn.baz().unwrap();
c.spawn.quux().unwrap();
+
+ init::LateResources {}
}
#[task(spawn = [bar])]
diff --git a/examples/not-sync.rs b/examples/not-sync.rs
index a7eaac8e..5a67489f 100644
--- a/examples/not-sync.rs
+++ b/examples/not-sync.rs
@@ -22,8 +22,10 @@ const APP: () = {
}
#[init]
- fn init(_: init::Context) {
+ fn init(_: init::Context) -> init::LateResources {
debug::exit(debug::EXIT_SUCCESS);
+
+ init::LateResources {}
}
#[task(resources = [&shared])]
diff --git a/examples/periodic.rs b/examples/periodic.rs
index 405346e3..da56d468 100644
--- a/examples/periodic.rs
+++ b/examples/periodic.rs
@@ -15,10 +15,12 @@ const PERIOD: u32 = 8_000_000;
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
const APP: () = {
#[init(schedule = [foo])]
- fn init(cx: init::Context) {
+ fn init(cx: init::Context) -> init::LateResources {
// omitted: initialization of `CYCCNT`
cx.schedule.foo(cx.start + PERIOD.cycles()).unwrap();
+
+ init::LateResources {}
}
#[task(schedule = [foo])]
diff --git a/examples/peripherals-taken.rs b/examples/peripherals-taken.rs
index cd4ba0f0..42ad8c0f 100644
--- a/examples/peripherals-taken.rs
+++ b/examples/peripherals-taken.rs
@@ -9,8 +9,10 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
const APP: () = {
#[init]
- fn main(_: main::Context) {
+ fn main(_: main::Context) -> main::LateResources {
assert!(cortex_m::Peripherals::take().is_none());
debug::exit(debug::EXIT_SUCCESS);
+
+ main::LateResources {}
}
};
diff --git a/examples/pool.rs b/examples/pool.rs
index 824d5bd8..9fccdf84 100644
--- a/examples/pool.rs
+++ b/examples/pool.rs
@@ -20,13 +20,15 @@ pool!(P: [u8; 128]);
#[app(device = lm3s6965)]
const APP: () = {
#[init]
- fn init(_: init::Context) {
+ fn init(_: init::Context) -> init::LateResources {
static mut MEMORY: [u8; 512] = [0; 512];
// Increase the capacity of the memory pool by ~4
P::grow(MEMORY);
rtic::pend(Interrupt::I2C0);
+
+ init::LateResources {}
}
#[task(binds = I2C0, priority = 2, spawn = [foo, bar])]
diff --git a/examples/preempt.rs b/examples/preempt.rs
index 3cb11029..7103b17b 100644
--- a/examples/preempt.rs
+++ b/examples/preempt.rs
@@ -11,8 +11,10 @@ use rtic::app;
#[app(device = lm3s6965)]
const APP: () = {
#[init]
- fn init(_: init::Context) {
+ fn init(_: init::Context) -> init::LateResources {
rtic::pend(Interrupt::GPIOA);
+
+ init::LateResources {}
}
#[task(binds = GPIOA, priority = 1)]
diff --git a/examples/ramfunc.rs b/examples/ramfunc.rs
index 1f95d496..214b7e67 100644
--- a/examples/ramfunc.rs
+++ b/examples/ramfunc.rs
@@ -11,8 +11,10 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
const APP: () = {
#[init(spawn = [bar])]
- fn init(c: init::Context) {
+ fn init(c: init::Context) -> init::LateResources {
c.spawn.bar().unwrap();
+
+ init::LateResources {}
}
#[inline(never)]
diff --git a/examples/resource.rs b/examples/resource.rs
index 2361fd00..06aa9756 100644
--- a/examples/resource.rs
+++ b/examples/resource.rs
@@ -18,9 +18,11 @@ const APP: () = {
}
#[init]
- fn init(_: init::Context) {
+ fn init(_: init::Context) -> init::LateResources {
rtic::pend(Interrupt::UART0);
rtic::pend(Interrupt::UART1);
+
+ init::LateResources {}
}
// `shared` cannot be accessed from this context
diff --git a/examples/schedule.rs b/examples/schedule.rs
index 70a7a5e3..b76d9e7f 100644
--- a/examples/schedule.rs
+++ b/examples/schedule.rs
@@ -14,7 +14,7 @@ use rtic::cyccnt::{Instant, U32Ext as _};
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
const APP: () = {
#[init(schedule = [foo, bar])]
- fn init(mut cx: init::Context) {
+ fn init(mut cx: init::Context) -> init::LateResources {
// Initialize (enable) the monotonic timer (CYCCNT)
cx.core.DCB.enable_trace();
// required on Cortex-M7 devices that software lock the DWT (e.g. STM32F7)
@@ -32,6 +32,8 @@ const APP: () = {
// Schedule `bar` to run 4e6 cycles in the future
cx.schedule.bar(now + 4_000_000.cycles()).unwrap();
+
+ init::LateResources {}
}
#[task]
diff --git a/examples/shared-with-init.rs b/examples/shared-with-init.rs
index bd55f7ef..fa900a26 100644
--- a/examples/shared-with-init.rs
+++ b/examples/shared-with-init.rs
@@ -20,12 +20,14 @@ const APP: () = {
}
#[init(resources = [shared])]
- fn init(c: init::Context) {
+ fn init(c: init::Context) -> init::LateResources {
// this `message` will be sent to task `UART0`
let message = MustBeSend;
*c.resources.shared = Some(message);
rtic::pend(Interrupt::UART0);
+
+ init::LateResources {}
}
#[task(binds = UART0, resources = [shared])]
diff --git a/examples/t-binds.rs b/examples/t-binds.rs
index 588ac46f..edf0fc69 100644
--- a/examples/t-binds.rs
+++ b/examples/t-binds.rs
@@ -10,7 +10,9 @@ use panic_halt as _;
#[rtic::app(device = lm3s6965)]
const APP: () = {
#[init]
- fn init(_: init::Context) {}
+ fn init(_: init::Context) -> init::LateResources {
+ init::LateResources {}
+ }
// Cortex-M exception
#[task(binds = SVCall)]
diff --git a/examples/t-cfg.rs b/examples/t-cfg.rs
index b6c9e472..254cb8e0 100644
--- a/examples/t-cfg.rs
+++ b/examples/t-cfg.rs
@@ -14,9 +14,11 @@ const APP: () = {
}
#[init]
- fn init(_: init::Context) {
+ fn init(_: init::Context) -> init::LateResources {
#[cfg(never)]
static mut BAR: u32 = 0;
+
+ init::LateResources {}
}
#[idle]
diff --git a/examples/t-htask-main.rs b/examples/t-htask-main.rs
index c4bebf94..885019a1 100644
--- a/examples/t-htask-main.rs
+++ b/examples/t-htask-main.rs
@@ -9,8 +9,10 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
const APP: () = {
#[init]
- fn init(_: init::Context) {
- rtic::pend(lm3s6965::Interrupt::UART0)
+ fn init(_: init::Context) -> init::LateResources {
+ rtic::pend(lm3s6965::Interrupt::UART0);
+
+ init::LateResources {}
}
#[task(binds = UART0)]
diff --git a/examples/t-idle-main.rs b/examples/t-idle-main.rs
index 051a9ee8..3e06cac6 100644
--- a/examples/t-idle-main.rs
+++ b/examples/t-idle-main.rs
@@ -9,7 +9,9 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
const APP: () = {
#[init]
- fn init(_: init::Context) {}
+ fn init(_: init::Context) -> init::LateResources {
+ init::LateResources {}
+ }
#[idle]
fn main(_: main::Context) -> ! {
diff --git a/examples/t-init-main.rs b/examples/t-init-main.rs
index 6a6cd991..f6c1d9ca 100644
--- a/examples/t-init-main.rs
+++ b/examples/t-init-main.rs
@@ -9,7 +9,9 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
const APP: () = {
#[init]
- fn main(_: main::Context) {
+ fn main(_: main::Context) -> main::LateResources {
debug::exit(debug::EXIT_SUCCESS);
+
+ main::LateResources {}
}
};
diff --git a/examples/t-resource.rs b/examples/t-resource.rs
index 81ba1856..78e518c1 100644
--- a/examples/t-resource.rs
+++ b/examples/t-resource.rs
@@ -31,7 +31,7 @@ const APP: () = {
}
#[init(resources = [o1, o4, o5, o6, s3])]
- fn init(c: init::Context) {
+ fn init(c: init::Context) -> init::LateResources {
// owned by `init` == `&'static mut`
let _: &'static mut u32 = c.resources.o1;
@@ -42,6 +42,8 @@ const APP: () = {
let _: &mut u32 = c.resources.o4;
let _: &mut u32 = c.resources.o5;
let _: &mut u32 = c.resources.s3;
+
+ init::LateResources {}
}
#[idle(resources = [o2, &o4, s1, &s3])]
diff --git a/examples/t-schedule.rs b/examples/t-schedule.rs
index 3854aad3..8af01aba 100644
--- a/examples/t-schedule.rs
+++ b/examples/t-schedule.rs
@@ -11,10 +11,12 @@ use rtic::cyccnt::{Instant, U32Ext as _};
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
const APP: () = {
#[init(schedule = [foo, bar, baz])]
- fn init(c: init::Context) {
+ fn init(c: init::Context) -> init::LateResources {
let _: Result<(), ()> = c.schedule.foo(c.start + 10.cycles());
let _: Result<(), u32> = c.schedule.bar(c.start + 20.cycles(), 0);
let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 30.cycles(), 0, 1);
+
+ init::LateResources {}
}
#[idle(schedule = [foo, bar, baz])]
diff --git a/examples/t-spawn.rs b/examples/t-spawn.rs
index 35831ccf..af2a79ea 100644
--- a/examples/t-spawn.rs
+++ b/examples/t-spawn.rs
@@ -10,10 +10,12 @@ use panic_halt as _;
#[rtic::app(device = lm3s6965)]
const APP: () = {
#[init(spawn = [foo, bar, baz])]
- fn init(c: init::Context) {
+ fn init(c: init::Context) -> init::LateResources {
let _: Result<(), ()> = c.spawn.foo();
let _: Result<(), u32> = c.spawn.bar(0);
let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
+
+ init::LateResources {}
}
#[idle(spawn = [foo, bar, baz])]
diff --git a/examples/t-stask-main.rs b/examples/t-stask-main.rs
index f2709404..aefd4821 100644
--- a/examples/t-stask-main.rs
+++ b/examples/t-stask-main.rs
@@ -9,8 +9,10 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
const APP: () = {
#[init(spawn = [main])]
- fn init(cx: init::Context) {
+ fn init(cx: init::Context) -> init::LateResources {
cx.spawn.main().ok();
+
+ init::LateResources {}
}
#[task]
diff --git a/examples/task.rs b/examples/task.rs
index 12c4ac83..e148b356 100644
--- a/examples/task.rs
+++ b/examples/task.rs
@@ -11,8 +11,10 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
const APP: () = {
#[init(spawn = [foo])]
- fn init(c: init::Context) {
+ fn init(c: init::Context) -> init::LateResources {
c.spawn.foo().unwrap();
+
+ init::LateResources {}
}
#[task(spawn = [bar, baz])]
diff --git a/examples/types.rs b/examples/types.rs
index 5233f868..46d08b83 100644
--- a/examples/types.rs
+++ b/examples/types.rs
@@ -17,7 +17,7 @@ const APP: () = {
}
#[init(schedule = [foo], spawn = [foo])]
- fn init(cx: init::Context) {
+ fn init(cx: init::Context) -> init::LateResources {
let _: cyccnt::Instant = cx.start;
let _: rtic::Peripherals = cx.core;
let _: lm3s6965::Peripherals = cx.device;
@@ -25,6 +25,8 @@ const APP: () = {
let _: init::Spawn = cx.spawn;
debug::exit(debug::EXIT_SUCCESS);
+
+ init::LateResources {}
}
#[idle(schedule = [foo], spawn = [foo])]