aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/baseline.rs10
-rw-r--r--examples/capacity.rs16
-rw-r--r--examples/cfg.rs12
-rw-r--r--examples/double_schedule.rs14
-rw-r--r--examples/message.rs24
-rw-r--r--examples/not-send.rs68
-rw-r--r--examples/periodic.rs8
-rw-r--r--examples/pool.rs8
-rw-r--r--examples/ramfunc.rs12
-rw-r--r--examples/schedule.rs6
-rw-r--r--examples/spawn.rs35
-rw-r--r--examples/spawn2.rs41
-rw-r--r--examples/t-cfg.rs4
-rw-r--r--examples/t-schedule.rs42
-rw-r--r--examples/t-spawn.rs50
-rw-r--r--examples/t-stask-main.rs6
-rw-r--r--examples/task.rs14
-rw-r--r--examples/types.rs19
18 files changed, 194 insertions, 195 deletions
diff --git a/examples/baseline.rs b/examples/baseline.rs
index 3ab40dbb..0b7e3ea0 100644
--- a/examples/baseline.rs
+++ b/examples/baseline.rs
@@ -12,19 +12,19 @@ use panic_semihosting as _;
// NOTE: does NOT properly work on QEMU
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
mod app {
- #[init(spawn = [foo])]
+ #[init]
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();
+ foo::spawn().unwrap();
init::LateResources {}
}
- #[task(schedule = [foo])]
+ #[task]
fn foo(cx: foo::Context) {
static mut ONCE: bool = true;
@@ -39,12 +39,12 @@ mod app {
}
}
- #[task(binds = UART0, spawn = [foo])]
+ #[task(binds = UART0)]
fn uart0(cx: uart0::Context) {
hprintln!("UART0(baseline = {:?})", cx.start).unwrap();
// `foo` inherits the baseline of `UART0`: its `start` time
- cx.spawn.foo().unwrap();
+ foo::spawn().unwrap();
}
// RTIC requires that unused interrupts are declared in an extern block when
diff --git a/examples/capacity.rs b/examples/capacity.rs
index ba8b15b0..f903acbc 100644
--- a/examples/capacity.rs
+++ b/examples/capacity.rs
@@ -18,14 +18,14 @@ mod app {
init::LateResources {}
}
- #[task(binds = UART0, spawn = [foo, bar])]
- fn uart0(c: uart0::Context) {
- c.spawn.foo(0).unwrap();
- c.spawn.foo(1).unwrap();
- c.spawn.foo(2).unwrap();
- c.spawn.foo(3).unwrap();
-
- c.spawn.bar().unwrap();
+ #[task(binds = UART0)]
+ fn uart0(_: uart0::Context) {
+ foo::spawn(0).unwrap();
+ foo::spawn(1).unwrap();
+ foo::spawn(2).unwrap();
+ foo::spawn(3).unwrap();
+
+ bar::spawn().unwrap();
}
#[task(capacity = 4)]
diff --git a/examples/cfg.rs b/examples/cfg.rs
index d49f54c7..c8892eaf 100644
--- a/examples/cfg.rs
+++ b/examples/cfg.rs
@@ -19,10 +19,10 @@ mod app {
count: u32,
}
- #[init(spawn = [foo])]
- fn init(cx: init::Context) -> init::LateResources {
- cx.spawn.foo().unwrap();
- cx.spawn.foo().unwrap();
+ #[init]
+ fn init(_: init::Context) -> init::LateResources {
+ foo::spawn().unwrap();
+ foo::spawn().unwrap();
init::LateResources {}
}
@@ -36,13 +36,13 @@ mod app {
}
}
- #[task(capacity = 2, resources = [count], spawn = [log])]
+ #[task(capacity = 2, resources = [count])]
fn foo(_cx: foo::Context) {
#[cfg(debug_assertions)]
{
*_cx.resources.count += 1;
- _cx.spawn.log(*_cx.resources.count).unwrap();
+ log::spawn(*_cx.resources.count).unwrap();
}
// this wouldn't compile in `release` mode
diff --git a/examples/double_schedule.rs b/examples/double_schedule.rs
index b1b78b80..d242c57e 100644
--- a/examples/double_schedule.rs
+++ b/examples/double_schedule.rs
@@ -16,21 +16,21 @@ mod app {
nothing: (),
}
- #[init(spawn = [task1])]
- fn init(cx: init::Context) -> init::LateResources {
- cx.spawn.task1().ok();
+ #[init]
+ fn init(_: init::Context) -> init::LateResources {
+ task1::spawn().ok();
init::LateResources { nothing: () }
}
- #[task(schedule = [task2])]
+ #[task]
fn task1(_cx: task1::Context) {
- _cx.schedule.task2(_cx.scheduled + 100.cycles()).ok();
+ task2::schedule(_cx.scheduled + 100.cycles()).ok();
}
- #[task(schedule = [task1])]
+ #[task]
fn task2(_cx: task2::Context) {
- _cx.schedule.task1(_cx.scheduled + 100.cycles()).ok();
+ task1::schedule(_cx.scheduled + 100.cycles()).ok();
}
extern "C" {
diff --git a/examples/message.rs b/examples/message.rs
index f9736728..5ff6288a 100644
--- a/examples/message.rs
+++ b/examples/message.rs
@@ -10,39 +10,39 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
- #[init(spawn = [foo])]
- fn init(c: init::Context) -> init::LateResources {
- c.spawn.foo(/* no message */).unwrap();
+ #[init]
+ fn init(_: init::Context) -> init::LateResources {
+ foo::spawn(/* no message */).unwrap();
init::LateResources {}
}
- #[task(spawn = [bar])]
- fn foo(c: foo::Context) {
+ #[task]
+ fn foo(_: foo::Context) {
static mut COUNT: u32 = 0;
hprintln!("foo").unwrap();
- c.spawn.bar(*COUNT).unwrap();
+ bar::spawn(*COUNT).unwrap();
*COUNT += 1;
}
- #[task(spawn = [baz])]
- fn bar(c: bar::Context, x: u32) {
+ #[task]
+ fn bar(_: bar::Context, x: u32) {
hprintln!("bar({})", x).unwrap();
- c.spawn.baz(x + 1, x + 2).unwrap();
+ baz::spawn(x + 1, x + 2).unwrap();
}
- #[task(spawn = [foo])]
- fn baz(c: baz::Context, x: u32, y: u32) {
+ #[task]
+ fn baz(_: baz::Context, x: u32, y: u32) {
hprintln!("baz({}, {})", x, y).unwrap();
if x + y > 4 {
debug::exit(debug::EXIT_SUCCESS);
}
- c.spawn.foo().unwrap();
+ foo::spawn().unwrap();
}
// RTIC requires that unused interrupts are declared in an extern block when
diff --git a/examples/not-send.rs b/examples/not-send.rs
deleted file mode 100644
index 18071fc5..00000000
--- a/examples/not-send.rs
+++ /dev/null
@@ -1,68 +0,0 @@
-//! `examples/not-send.rs`
-
-#![deny(unsafe_code)]
-#![deny(warnings)]
-#![no_main]
-#![no_std]
-
-use core::marker::PhantomData;
-
-use cortex_m_semihosting::debug;
-use panic_halt as _;
-use rtic::app;
-
-pub struct NotSend {
- _0: PhantomData<*const ()>,
-}
-
-#[app(device = lm3s6965)]
-mod app {
- use super::NotSend;
-
- #[resources]
- struct Resources {
- #[init(None)]
- shared: Option<NotSend>,
- }
-
- #[init(spawn = [baz, quux])]
- fn init(c: init::Context) -> init::LateResources {
- c.spawn.baz().unwrap();
- c.spawn.quux().unwrap();
-
- init::LateResources {}
- }
-
- #[task(spawn = [bar])]
- fn foo(c: foo::Context) {
- // scenario 1: message passed to task that runs at the same priority
- c.spawn.bar(NotSend { _0: PhantomData }).ok();
- }
-
- #[task]
- fn bar(_: bar::Context, _x: NotSend) {
- // scenario 1
- }
-
- #[task(priority = 2, resources = [shared])]
- fn baz(c: baz::Context) {
- // scenario 2: resource shared between tasks that run at the same priority
- *c.resources.shared = Some(NotSend { _0: PhantomData });
- }
-
- #[task(priority = 2, resources = [shared])]
- fn quux(c: quux::Context) {
- // scenario 2
- let _not_send = c.resources.shared.take().unwrap();
-
- debug::exit(debug::EXIT_SUCCESS);
- }
-
- // RTIC requires that unused interrupts are declared in an extern block when
- // using software tasks; these free interrupts will be used to dispatch the
- // software tasks.
- extern "C" {
- fn SSI0();
- fn QEI0();
- }
-}
diff --git a/examples/periodic.rs b/examples/periodic.rs
index d3aedd32..95cd1451 100644
--- a/examples/periodic.rs
+++ b/examples/periodic.rs
@@ -15,21 +15,21 @@ const PERIOD: u32 = 8_000_000;
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
mod app {
- #[init(schedule = [foo])]
+ #[init]
fn init(cx: init::Context) -> init::LateResources {
// omitted: initialization of `CYCCNT`
- cx.schedule.foo(cx.start + PERIOD.cycles()).unwrap();
+ foo::schedule(cx.start + PERIOD.cycles()).unwrap();
init::LateResources {}
}
- #[task(schedule = [foo])]
+ #[task]
fn foo(cx: foo::Context) {
let now = Instant::now();
hprintln!("foo(scheduled = {:?}, now = {:?})", cx.scheduled, now).unwrap();
- cx.schedule.foo(cx.scheduled + PERIOD.cycles()).unwrap();
+ foo::schedule(cx.scheduled + PERIOD.cycles()).unwrap();
}
// RTIC requires that unused interrupts are declared in an extern block when
diff --git a/examples/pool.rs b/examples/pool.rs
index cdbabca7..2ad99841 100644
--- a/examples/pool.rs
+++ b/examples/pool.rs
@@ -36,16 +36,16 @@ mod app {
init::LateResources {}
}
- #[task(binds = I2C0, priority = 2, spawn = [foo, bar])]
- fn i2c0(c: i2c0::Context) {
+ #[task(binds = I2C0, priority = 2)]
+ fn i2c0(_: i2c0::Context) {
// claim a memory block, leave it uninitialized and ..
let x = P::alloc().unwrap().freeze();
// .. send it to the `foo` task
- c.spawn.foo(x).ok().unwrap();
+ foo::spawn(x).ok().unwrap();
// send another block to the task `bar`
- c.spawn.bar(P::alloc().unwrap().freeze()).ok().unwrap();
+ bar::spawn(P::alloc().unwrap().freeze()).ok().unwrap();
}
#[task]
diff --git a/examples/ramfunc.rs b/examples/ramfunc.rs
index 5ff167a3..84d633dd 100644
--- a/examples/ramfunc.rs
+++ b/examples/ramfunc.rs
@@ -10,9 +10,9 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
- #[init(spawn = [bar])]
- fn init(c: init::Context) -> init::LateResources {
- c.spawn.bar().unwrap();
+ #[init]
+ fn init(_: init::Context) -> init::LateResources {
+ foo::spawn().unwrap();
init::LateResources {}
}
@@ -28,9 +28,9 @@ mod app {
// run this task from RAM
#[inline(never)]
#[link_section = ".data.bar"]
- #[task(priority = 2, spawn = [foo])]
- fn bar(c: bar::Context) {
- c.spawn.foo().unwrap();
+ #[task(priority = 2)]
+ fn bar(_: bar::Context) {
+ foo::spawn().unwrap();
}
extern "C" {
diff --git a/examples/schedule.rs b/examples/schedule.rs
index 7e6adc1a..fa67a566 100644
--- a/examples/schedule.rs
+++ b/examples/schedule.rs
@@ -13,7 +13,7 @@ use rtic::cyccnt::{Instant, U32Ext as _};
// NOTE: does NOT work on QEMU!
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
mod app {
- #[init(schedule = [foo, bar])]
+ #[init()]
fn init(mut cx: init::Context) -> init::LateResources {
// Initialize (enable) the monotonic timer (CYCCNT)
cx.core.DCB.enable_trace();
@@ -28,10 +28,10 @@ mod app {
hprintln!("init @ {:?}", now).unwrap();
// Schedule `foo` to run 8e6 cycles (clock cycles) in the future
- cx.schedule.foo(now + 8_000_000.cycles()).unwrap();
+ foo::schedule(now + 8_000_000.cycles()).unwrap();
// Schedule `bar` to run 4e6 cycles in the future
- cx.schedule.bar(now + 4_000_000.cycles()).unwrap();
+ bar::schedule(now + 4_000_000.cycles()).unwrap();
init::LateResources {}
}
diff --git a/examples/spawn.rs b/examples/spawn.rs
new file mode 100644
index 00000000..041018ab
--- /dev/null
+++ b/examples/spawn.rs
@@ -0,0 +1,35 @@
+//! examples/spawn.rs
+
+#![deny(unsafe_code)]
+#![deny(warnings)]
+#![no_main]
+#![no_std]
+
+use cortex_m_semihosting::{debug, hprintln};
+use panic_semihosting as _;
+
+#[rtic::app(device = lm3s6965)]
+mod app {
+ #[init]
+ fn init(_c: init::Context) -> init::LateResources {
+ foo::spawn(1, 2).unwrap();
+
+ init::LateResources {}
+ }
+
+ #[task()]
+ fn foo(_c: foo::Context, x: i32, y: u32) {
+ hprintln!("foo {}, {}", x, y).unwrap();
+ if x == 2 {
+ debug::exit(debug::EXIT_SUCCESS);
+ }
+ foo::spawn(2, 3).unwrap();
+ }
+
+ // RTIC requires that unused interrupts are declared in an extern block when
+ // using software tasks; these free interrupts will be used to dispatch the
+ // software tasks.
+ extern "C" {
+ fn SSI0();
+ }
+}
diff --git a/examples/spawn2.rs b/examples/spawn2.rs
new file mode 100644
index 00000000..b50a3ee6
--- /dev/null
+++ b/examples/spawn2.rs
@@ -0,0 +1,41 @@
+//! examples/spawn2.rs
+
+#![deny(unsafe_code)]
+#![deny(warnings)]
+#![no_main]
+#![no_std]
+
+use cortex_m_semihosting::{debug, hprintln};
+use panic_semihosting as _;
+
+#[rtic::app(device = lm3s6965)]
+mod app {
+ #[init]
+ fn init(_c: init::Context) -> init::LateResources {
+ foo::spawn(1, 2).unwrap();
+
+ init::LateResources {}
+ }
+
+ #[task]
+ fn foo(_c: foo::Context, x: i32, y: u32) {
+ hprintln!("foo {}, {}", x, y).unwrap();
+ if x == 2 {
+ debug::exit(debug::EXIT_SUCCESS);
+ }
+ foo2::spawn(2).unwrap();
+ }
+
+ #[task]
+ fn foo2(_c: foo2::Context, x: i32) {
+ hprintln!("foo2 {}", x).unwrap();
+ foo::spawn(x, 0).unwrap();
+ }
+
+ // RTIC requires that unused interrupts are declared in an extern block when
+ // using software tasks; these free interrupts will be used to dispatch the
+ // software tasks.
+ extern "C" {
+ fn SSI0();
+ }
+}
diff --git a/examples/t-cfg.rs b/examples/t-cfg.rs
index 3da20d4e..7076f5d7 100644
--- a/examples/t-cfg.rs
+++ b/examples/t-cfg.rs
@@ -32,13 +32,13 @@ mod app {
}
}
- #[task(resources = [foo], schedule = [quux], spawn = [quux])]
+ #[task(resources = [foo])]
fn foo(_: foo::Context) {
#[cfg(never)]
static mut BAR: u32 = 0;
}
- #[task(priority = 3, resources = [foo], schedule = [quux], spawn = [quux])]
+ #[task(priority = 3, resources = [foo])]
fn bar(_: bar::Context) {
#[cfg(never)]
static mut BAR: u32 = 0;
diff --git a/examples/t-schedule.rs b/examples/t-schedule.rs
index d5a6d3ff..7c2c420c 100644
--- a/examples/t-schedule.rs
+++ b/examples/t-schedule.rs
@@ -10,45 +10,45 @@ use rtic::cyccnt::{Instant, U32Ext as _};
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
mod app {
- #[init(schedule = [foo, bar, baz])]
+ #[init]
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);
+ let _: Result<(), ()> = foo::schedule(c.start + 10.cycles());
+ let _: Result<(), u32> = bar::schedule(c.start + 20.cycles(), 0);
+ let _: Result<(), (u32, u32)> = baz::schedule(c.start + 30.cycles(), 0, 1);
init::LateResources {}
}
- #[idle(schedule = [foo, bar, baz])]
- fn idle(c: idle::Context) -> ! {
- let _: Result<(), ()> = c.schedule.foo(Instant::now() + 40.cycles());
- let _: Result<(), u32> = c.schedule.bar(Instant::now() + 50.cycles(), 0);
- let _: Result<(), (u32, u32)> = c.schedule.baz(Instant::now() + 60.cycles(), 0, 1);
+ #[idle]
+ fn idle(_: idle::Context) -> ! {
+ let _: Result<(), ()> = foo::schedule(Instant::now() + 40.cycles());
+ let _: Result<(), u32> = bar::schedule(Instant::now() + 50.cycles(), 0);
+ let _: Result<(), (u32, u32)> = baz::schedule(Instant::now() + 60.cycles(), 0, 1);
loop {
cortex_m::asm::nop();
}
}
- #[task(binds = SVCall, schedule = [foo, bar, baz])]
+ #[task(binds = SVCall)]
fn svcall(c: svcall::Context) {
- let _: Result<(), ()> = c.schedule.foo(c.start + 70.cycles());
- let _: Result<(), u32> = c.schedule.bar(c.start + 80.cycles(), 0);
- let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 90.cycles(), 0, 1);
+ let _: Result<(), ()> = foo::schedule(c.start + 70.cycles());
+ let _: Result<(), u32> = bar::schedule(c.start + 80.cycles(), 0);
+ let _: Result<(), (u32, u32)> = baz::schedule(c.start + 90.cycles(), 0, 1);
}
- #[task(binds = UART0, schedule = [foo, bar, baz])]
+ #[task(binds = UART0)]
fn uart0(c: uart0::Context) {
- let _: Result<(), ()> = c.schedule.foo(c.start + 100.cycles());
- let _: Result<(), u32> = c.schedule.bar(c.start + 110.cycles(), 0);
- let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 120.cycles(), 0, 1);
+ let _: Result<(), ()> = foo::schedule(c.start + 100.cycles());
+ let _: Result<(), u32> = bar::schedule(c.start + 110.cycles(), 0);
+ let _: Result<(), (u32, u32)> = baz::schedule(c.start + 120.cycles(), 0, 1);
}
- #[task(schedule = [foo, bar, baz])]
+ #[task]
fn foo(c: foo::Context) {
- let _: Result<(), ()> = c.schedule.foo(c.scheduled + 130.cycles());
- let _: Result<(), u32> = c.schedule.bar(c.scheduled + 140.cycles(), 0);
- let _: Result<(), (u32, u32)> = c.schedule.baz(c.scheduled + 150.cycles(), 0, 1);
+ let _: Result<(), ()> = foo::schedule(c.scheduled + 130.cycles());
+ let _: Result<(), u32> = bar::schedule(c.scheduled + 140.cycles(), 0);
+ let _: Result<(), (u32, u32)> = baz::schedule(c.scheduled + 150.cycles(), 0, 1);
}
#[task]
diff --git a/examples/t-spawn.rs b/examples/t-spawn.rs
index efb748bc..cf850e46 100644
--- a/examples/t-spawn.rs
+++ b/examples/t-spawn.rs
@@ -9,45 +9,45 @@ use panic_halt as _;
#[rtic::app(device = lm3s6965)]
mod app {
- #[init(spawn = [foo, bar, baz])]
- 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]
+ fn init(_: init::Context) -> init::LateResources {
+ let _: Result<(), ()> = foo::spawn();
+ let _: Result<(), u32> = bar::spawn(0);
+ let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
init::LateResources {}
}
- #[idle(spawn = [foo, bar, baz])]
- fn idle(c: idle::Context) -> ! {
- let _: Result<(), ()> = c.spawn.foo();
- let _: Result<(), u32> = c.spawn.bar(0);
- let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
+ #[idle]
+ fn idle(_: idle::Context) -> ! {
+ let _: Result<(), ()> = foo::spawn();
+ let _: Result<(), u32> = bar::spawn(0);
+ let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
loop {
cortex_m::asm::nop();
}
}
- #[task(binds = SVCall, spawn = [foo, bar, baz])]
- fn svcall(c: svcall::Context) {
- let _: Result<(), ()> = c.spawn.foo();
- let _: Result<(), u32> = c.spawn.bar(0);
- let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
+ #[task(binds = SVCall)]
+ fn svcall(_: svcall::Context) {
+ let _: Result<(), ()> = foo::spawn();
+ let _: Result<(), u32> = bar::spawn(0);
+ let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
}
- #[task(binds = UART0, spawn = [foo, bar, baz])]
- fn uart0(c: uart0::Context) {
- let _: Result<(), ()> = c.spawn.foo();
- let _: Result<(), u32> = c.spawn.bar(0);
- let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
+ #[task(binds = UART0)]
+ fn uart0(_: uart0::Context) {
+ let _: Result<(), ()> = foo::spawn();
+ let _: Result<(), u32> = bar::spawn(0);
+ let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
}
- #[task(spawn = [foo, bar, baz])]
- fn foo(c: foo::Context) {
- let _: Result<(), ()> = c.spawn.foo();
- let _: Result<(), u32> = c.spawn.bar(0);
- let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
+ #[task]
+ fn foo(_: foo::Context) {
+ let _: Result<(), ()> = foo::spawn();
+ let _: Result<(), u32> = bar::spawn(0);
+ let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
}
#[task]
diff --git a/examples/t-stask-main.rs b/examples/t-stask-main.rs
index 74335c18..3337c7d3 100644
--- a/examples/t-stask-main.rs
+++ b/examples/t-stask-main.rs
@@ -8,9 +8,9 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
- #[init(spawn = [taskmain])]
- fn init(cx: init::Context) -> init::LateResources {
- cx.spawn.taskmain().ok();
+ #[init]
+ fn init(_: init::Context) -> init::LateResources {
+ taskmain::spawn().ok();
init::LateResources {}
}
diff --git a/examples/task.rs b/examples/task.rs
index 80a9c431..f3d916f3 100644
--- a/examples/task.rs
+++ b/examples/task.rs
@@ -10,27 +10,27 @@ use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
mod app {
- #[init(spawn = [foo])]
- fn init(c: init::Context) -> init::LateResources {
- c.spawn.foo().unwrap();
+ #[init]
+ fn init(_: init::Context) -> init::LateResources {
+ foo::spawn().unwrap();
init::LateResources {}
}
- #[task(spawn = [bar, baz])]
- fn foo(c: foo::Context) {
+ #[task]
+ fn foo(_: foo::Context) {
hprintln!("foo - start").unwrap();
// spawns `bar` onto the task scheduler
// `foo` and `bar` have the same priority so `bar` will not run until
// after `foo` terminates
- c.spawn.bar().unwrap();
+ bar::spawn().unwrap();
hprintln!("foo - middle").unwrap();
// spawns `baz` onto the task scheduler
// `baz` has higher priority than `foo` so it immediately preempts `foo`
- c.spawn.baz().unwrap();
+ baz::spawn().unwrap();
hprintln!("foo - end").unwrap();
}
diff --git a/examples/types.rs b/examples/types.rs
index 251d004c..b55a98c6 100644
--- a/examples/types.rs
+++ b/examples/types.rs
@@ -17,44 +17,35 @@ mod app {
shared: u32,
}
- #[init(schedule = [foo], spawn = [foo])]
+ #[init]
fn init(cx: init::Context) -> init::LateResources {
let _: cyccnt::Instant = cx.start;
let _: rtic::Peripherals = cx.core;
let _: lm3s6965::Peripherals = cx.device;
- let _: init::Schedule = cx.schedule;
- let _: init::Spawn = cx.spawn;
debug::exit(debug::EXIT_SUCCESS);
init::LateResources {}
}
- #[idle(schedule = [foo], spawn = [foo])]
- fn idle(cx: idle::Context) -> ! {
- let _: idle::Schedule = cx.schedule;
- let _: idle::Spawn = cx.spawn;
-
+ #[idle]
+ fn idle(_: idle::Context) -> ! {
loop {
cortex_m::asm::nop();
}
}
- #[task(binds = UART0, resources = [shared], schedule = [foo], spawn = [foo])]
+ #[task(binds = UART0, resources = [shared])]
fn uart0(cx: uart0::Context) {
let _: cyccnt::Instant = cx.start;
let _: resources::shared = cx.resources.shared;
- let _: uart0::Schedule = cx.schedule;
- let _: uart0::Spawn = cx.spawn;
}
- #[task(priority = 2, resources = [shared], schedule = [foo], spawn = [foo])]
+ #[task(priority = 2, resources = [shared])]
fn foo(cx: foo::Context) {
let _: cyccnt::Instant = cx.scheduled;
let _: &mut u32 = cx.resources.shared;
let _: foo::Resources = cx.resources;
- let _: foo::Schedule = cx.schedule;
- let _: foo::Spawn = cx.spawn;
}
// RTIC requires that unused interrupts are declared in an extern block when