aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--examples/baseline.rs19
-rw-r--r--examples/binds.rs9
-rw-r--r--examples/capacity.rs21
-rw-r--r--examples/cfg.rs13
-rw-r--r--examples/generics.rs18
-rw-r--r--examples/idle.rs7
-rw-r--r--examples/init.rs9
-rw-r--r--examples/interrupt.rs9
-rw-r--r--examples/late.rs13
-rw-r--r--examples/lock.rs17
-rw-r--r--examples/message.rs19
-rw-r--r--examples/not-send.rs20
-rw-r--r--examples/not-sync.rs13
-rw-r--r--examples/periodic.rs14
-rw-r--r--examples/ramfunc.rs13
-rw-r--r--examples/resource.rs19
-rw-r--r--examples/schedule.rs14
-rw-r--r--examples/shared-with-init.rs8
-rw-r--r--examples/singleton.rs61
-rw-r--r--examples/smallest.rs2
-rw-r--r--examples/static.rs13
-rw-r--r--examples/task.rs17
-rw-r--r--examples/types.rs46
23 files changed, 159 insertions, 235 deletions
diff --git a/examples/baseline.rs b/examples/baseline.rs
index fdf36838..d743107d 100644
--- a/examples/baseline.rs
+++ b/examples/baseline.rs
@@ -9,24 +9,23 @@ extern crate panic_semihosting;
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
-use rtfm::app;
// NOTE: does NOT properly work on QEMU
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init(spawn = [foo])]
- fn init() {
- hprintln!("init(baseline = {:?})", start).unwrap();
+ fn init(c: init::Context) {
+ hprintln!("init(baseline = {:?})", c.start).unwrap();
// `foo` inherits the baseline of `init`: `Instant(0)`
- spawn.foo().unwrap();
+ c.spawn.foo().unwrap();
}
#[task(schedule = [foo])]
- fn foo() {
+ fn foo(c: foo::Context) {
static mut ONCE: bool = true;
- hprintln!("foo(baseline = {:?})", scheduled).unwrap();
+ hprintln!("foo(baseline = {:?})", c.scheduled).unwrap();
if *ONCE {
*ONCE = false;
@@ -38,11 +37,11 @@ const APP: () = {
}
#[interrupt(spawn = [foo])]
- fn UART0() {
- hprintln!("UART0(baseline = {:?})", start).unwrap();
+ fn UART0(c: UART0::Context) {
+ hprintln!("UART0(baseline = {:?})", c.start).unwrap();
// `foo` inherits the baseline of `UART0`: its `start` time
- spawn.foo().unwrap();
+ c.spawn.foo().unwrap();
}
extern "C" {
diff --git a/examples/binds.rs b/examples/binds.rs
index a8b386fb..3d2d9b54 100644
--- a/examples/binds.rs
+++ b/examples/binds.rs
@@ -9,20 +9,19 @@ extern crate panic_semihosting;
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
-use rtfm::app;
// `examples/interrupt.rs` rewritten to use `binds`
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init]
- fn init() {
+ fn init(_: init::Context) {
rtfm::pend(Interrupt::UART0);
hprintln!("init").unwrap();
}
#[idle]
- fn idle() -> ! {
+ fn idle(_: idle::Context) -> ! {
hprintln!("idle").unwrap();
rtfm::pend(Interrupt::UART0);
@@ -33,7 +32,7 @@ const APP: () = {
}
#[interrupt(binds = UART0)]
- fn foo() {
+ fn foo(_: foo::Context) {
static mut TIMES: u32 = 0;
*TIMES += 1;
diff --git a/examples/capacity.rs b/examples/capacity.rs
index a7132ba0..07edd9b8 100644
--- a/examples/capacity.rs
+++ b/examples/capacity.rs
@@ -9,32 +9,31 @@ extern crate panic_semihosting;
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
-use rtfm::app;
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init]
- fn init() {
+ fn init(_: init::Context) {
rtfm::pend(Interrupt::UART0);
}
#[interrupt(spawn = [foo, bar])]
- fn UART0() {
- spawn.foo(0).unwrap();
- spawn.foo(1).unwrap();
- spawn.foo(2).unwrap();
- spawn.foo(3).unwrap();
+ 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();
- spawn.bar().unwrap();
+ c.spawn.bar().unwrap();
}
#[task(capacity = 4)]
- fn foo(x: u32) {
+ fn foo(_: foo::Context, x: u32) {
hprintln!("foo({})", x).unwrap();
}
#[task]
- fn bar() {
+ fn bar(_: bar::Context) {
hprintln!("bar").unwrap();
debug::exit(debug::EXIT_SUCCESS);
diff --git a/examples/cfg.rs b/examples/cfg.rs
index 3f4ca904..03f9dbdc 100644
--- a/examples/cfg.rs
+++ b/examples/cfg.rs
@@ -9,25 +9,24 @@ extern crate panic_semihosting;
#[cfg(debug_assertions)]
use cortex_m_semihosting::hprintln;
-use rtfm::app;
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[cfg(debug_assertions)] // <- `true` when using the `dev` profile
static mut COUNT: u32 = 0;
#[init]
- fn init() {
+ fn init(_: init::Context) {
// ..
}
#[task(priority = 3, resources = [COUNT], spawn = [log])]
- fn foo() {
+ fn foo(c: foo::Context) {
#[cfg(debug_assertions)]
{
- *resources.COUNT += 1;
+ *c.resources.COUNT += 1;
- spawn.log(*resources.COUNT).ok();
+ c.spawn.log(*c.resources.COUNT).ok();
}
// this wouldn't compile in `release` mode
@@ -38,7 +37,7 @@ const APP: () = {
#[cfg(debug_assertions)]
#[task]
- fn log(n: u32) {
+ fn log(_: log::Context, n: u32) {
hprintln!(
"foo has been called {} time{}",
n,
diff --git a/examples/generics.rs b/examples/generics.rs
index c8ce8393..e624da39 100644
--- a/examples/generics.rs
+++ b/examples/generics.rs
@@ -9,25 +9,25 @@ extern crate panic_semihosting;
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
-use rtfm::{app, Mutex};
+use rtfm::Mutex;
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
static mut SHARED: u32 = 0;
#[init]
- fn init() {
+ fn init(_: init::Context) {
rtfm::pend(Interrupt::UART0);
rtfm::pend(Interrupt::UART1);
}
#[interrupt(resources = [SHARED])]
- fn UART0() {
+ fn UART0(c: UART0::Context) {
static mut STATE: u32 = 0;
hprintln!("UART0(STATE = {})", *STATE).unwrap();
- advance(STATE, resources.SHARED);
+ advance(STATE, c.resources.SHARED);
rtfm::pend(Interrupt::UART1);
@@ -35,17 +35,17 @@ const APP: () = {
}
#[interrupt(priority = 2, resources = [SHARED])]
- fn UART1() {
+ fn UART1(mut c: UART1::Context) {
static mut STATE: u32 = 0;
hprintln!("UART1(STATE = {})", *STATE).unwrap();
// just to show that `SHARED` can be accessed directly and ..
- *resources.SHARED += 0;
+ *c.resources.SHARED += 0;
// .. also through a (no-op) `lock`
- resources.SHARED.lock(|shared| *shared += 0);
+ c.resources.SHARED.lock(|shared| *shared += 0);
- advance(STATE, resources.SHARED);
+ advance(STATE, c.resources.SHARED);
}
};
diff --git a/examples/idle.rs b/examples/idle.rs
index 1f21a37f..d10cc43e 100644
--- a/examples/idle.rs
+++ b/examples/idle.rs
@@ -8,17 +8,16 @@
extern crate panic_semihosting;
use cortex_m_semihosting::{debug, hprintln};
-use rtfm::app;
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init]
- fn init() {
+ fn init(_: init::Context) {
hprintln!("init").unwrap();
}
#[idle]
- fn idle() -> ! {
+ fn idle(_: idle::Context) -> ! {
static mut X: u32 = 0;
// Safe access to local `static mut` variable
diff --git a/examples/init.rs b/examples/init.rs
index be6cfe3e..df687794 100644
--- a/examples/init.rs
+++ b/examples/init.rs
@@ -8,19 +8,18 @@
extern crate panic_semihosting;
use cortex_m_semihosting::{debug, hprintln};
-use rtfm::app;
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init]
- fn init() {
+ fn init(c: init::Context) {
static mut X: u32 = 0;
// Cortex-M peripherals
- let _core: rtfm::Peripherals = core;
+ let _core: rtfm::Peripherals = c.core;
// Device specific peripherals
- let _device: lm3s6965::Peripherals = device;
+ let _device: lm3s6965::Peripherals = c.device;
// Safe access to local `static mut` variable
let _x: &'static mut u32 = X;
diff --git a/examples/interrupt.rs b/examples/interrupt.rs
index 3c669d9e..dd6efa0d 100644
--- a/examples/interrupt.rs
+++ b/examples/interrupt.rs
@@ -9,12 +9,11 @@ extern crate panic_semihosting;
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
-use rtfm::app;
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init]
- fn init() {
+ fn init(_: init::Context) {
// Pends the UART0 interrupt but its handler won't run until *after*
// `init` returns because interrupts are disabled
rtfm::pend(Interrupt::UART0);
@@ -23,7 +22,7 @@ const APP: () = {
}
#[idle]
- fn idle() -> ! {
+ fn idle(_: idle::Context) -> ! {
// interrupts are enabled again; the `UART0` handler runs at this point
hprintln!("idle").unwrap();
@@ -36,7 +35,7 @@ const APP: () = {
}
#[interrupt]
- fn UART0() {
+ fn UART0(_: UART0::Context) {
static mut TIMES: u32 = 0;
// Safe access to local `static mut` variable
diff --git a/examples/late.rs b/examples/late.rs
index 622008a7..0074fb32 100644
--- a/examples/late.rs
+++ b/examples/late.rs
@@ -13,16 +13,15 @@ use heapless::{
spsc::{Consumer, Producer, Queue},
};
use lm3s6965::Interrupt;
-use rtfm::app;
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
// Late resources
static mut P: Producer<'static, u32, U4> = ();
static mut C: Consumer<'static, u32, U4> = ();
#[init]
- fn init() -> init::LateResources {
+ 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;
@@ -35,9 +34,9 @@ const APP: () = {
}
#[idle(resources = [C])]
- fn idle() -> ! {
+ fn idle(c: idle::Context) -> ! {
loop {
- if let Some(byte) = resources.C.dequeue() {
+ if let Some(byte) = c.resources.C.dequeue() {
hprintln!("received message: {}", byte).unwrap();
debug::exit(debug::EXIT_SUCCESS);
@@ -48,7 +47,7 @@ const APP: () = {
}
#[interrupt(resources = [P])]
- fn UART0() {
- resources.P.enqueue(42).unwrap();
+ fn UART0(c: UART0::Context) {
+ c.resources.P.enqueue(42).unwrap();
}
};
diff --git a/examples/lock.rs b/examples/lock.rs
index 4ca862e3..814c7364 100644
--- a/examples/lock.rs
+++ b/examples/lock.rs
@@ -9,24 +9,23 @@ extern crate panic_semihosting;
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
-use rtfm::app;
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
static mut SHARED: u32 = 0;
#[init]
- fn init() {
+ fn init(_: init::Context) {
rtfm::pend(Interrupt::GPIOA);
}
// when omitted priority is assumed to be `1`
#[interrupt(resources = [SHARED])]
- fn GPIOA() {
+ fn GPIOA(mut c: GPIOA::Context) {
hprintln!("A").unwrap();
// the lower priority task requires a critical section to access the data
- resources.SHARED.lock(|shared| {
+ c.resources.SHARED.lock(|shared| {
// data can only be modified within this critical section (closure)
*shared += 1;
@@ -47,15 +46,15 @@ const APP: () = {
}
#[interrupt(priority = 2, resources = [SHARED])]
- fn GPIOB() {
+ fn GPIOB(mut c: GPIOB::Context) {
// the higher priority task does *not* need a critical section
- *resources.SHARED += 1;
+ *c.resources.SHARED += 1;
- hprintln!("D - SHARED = {}", *resources.SHARED).unwrap();
+ hprintln!("D - SHARED = {}", *c.resources.SHARED).unwrap();
}
#[interrupt(priority = 3)]
- fn GPIOC() {
+ fn GPIOC(_: GPIOC::Context) {
hprintln!("C").unwrap();
}
};
diff --git a/examples/message.rs b/examples/message.rs
index b5d68a60..1fd3b9d4 100644
--- a/examples/message.rs
+++ b/examples/message.rs
@@ -8,41 +8,40 @@
extern crate panic_semihosting;
use cortex_m_semihosting::{debug, hprintln};
-use rtfm::app;
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init(spawn = [foo])]
- fn init() {
- spawn.foo(/* no message */).unwrap();
+ fn init(c: init::Context) {
+ c.spawn.foo(/* no message */).unwrap();
}
#[task(spawn = [bar])]
- fn foo() {
+ fn foo(c: foo::Context) {
static mut COUNT: u32 = 0;
hprintln!("foo").unwrap();
- spawn.bar(*COUNT).unwrap();
+ c.spawn.bar(*COUNT).unwrap();
*COUNT += 1;
}
#[task(spawn = [baz])]
- fn bar(x: u32) {
+ fn bar(c: bar::Context, x: u32) {
hprintln!("bar({})", x).unwrap();
- spawn.baz(x + 1, x + 2).unwrap();
+ c.spawn.baz(x + 1, x + 2).unwrap();
}
#[task(spawn = [foo])]
- fn baz(x: u32, y: u32) {
+ fn baz(c: baz::Context, x: u32, y: u32) {
hprintln!("baz({}, {})", x, y).unwrap();
if x + y > 4 {
debug::exit(debug::EXIT_SUCCESS);
}
- spawn.foo().unwrap();
+ c.spawn.foo().unwrap();
}
extern "C" {
diff --git a/examples/not-send.rs b/examples/not-send.rs
index be78c332..c1b6bcdd 100644
--- a/examples/not-send.rs
+++ b/examples/not-send.rs
@@ -21,32 +21,32 @@ const APP: () = {
static mut SHARED: Option<NotSend> = None;
#[init(spawn = [baz, quux])]
- fn init() {
- spawn.baz().unwrap();
- spawn.quux().unwrap();
+ fn init(c: init::Context) {
+ c.spawn.baz().unwrap();
+ c.spawn.quux().unwrap();
}
#[task(spawn = [bar])]
- fn foo() {
+ fn foo(c: foo::Context) {
// scenario 1: message passed to task that runs at the same priority
- spawn.bar(NotSend { _0: PhantomData }).ok();
+ c.spawn.bar(NotSend { _0: PhantomData }).ok();
}
#[task]
- fn bar(_x: NotSend) {
+ fn bar(_: bar::Context, _x: NotSend) {
// scenario 1
}
#[task(priority = 2, resources = [SHARED])]
- fn baz() {
+ fn baz(mut c: baz::Context) {
// scenario 2: resource shared between tasks that run at the same priority
- *resources.SHARED = Some(NotSend { _0: PhantomData });
+ *c.resources.SHARED = Some(NotSend { _0: PhantomData });
}
#[task(priority = 2, resources = [SHARED])]
- fn quux() {
+ fn quux(mut c: quux::Context) {
// scenario 2
- let _not_send = resources.SHARED.take().unwrap();
+ let _not_send = c.resources.SHARED.take().unwrap();
debug::exit(debug::EXIT_SUCCESS);
}
diff --git a/examples/not-sync.rs b/examples/not-sync.rs
index d94e0a04..bc714065 100644
--- a/examples/not-sync.rs
+++ b/examples/not-sync.rs
@@ -10,29 +10,28 @@ extern crate panic_halt;
use core::marker::PhantomData;
use cortex_m_semihosting::debug;
-use rtfm::app;
pub struct NotSync {
_0: PhantomData<*const ()>,
}
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
static SHARED: NotSync = NotSync { _0: PhantomData };
#[init]
- fn init() {
+ fn init(_: init::Context) {
debug::exit(debug::EXIT_SUCCESS);
}
#[task(resources = [SHARED])]
- fn foo() {
- let _: &NotSync = resources.SHARED;
+ fn foo(c: foo::Context) {
+ let _: &NotSync = c.resources.SHARED;
}
#[task(resources = [SHARED])]
- fn bar() {
- let _: &NotSync = resources.SHARED;
+ fn bar(c: bar::Context) {
+ let _: &NotSync = c.resources.SHARED;
}
extern "C" {
diff --git a/examples/periodic.rs b/examples/periodic.rs
index ba2b4933..f7841183 100644
--- a/examples/periodic.rs
+++ b/examples/periodic.rs
@@ -8,24 +8,24 @@
extern crate panic_semihosting;
use cortex_m_semihosting::hprintln;
-use rtfm::{app, Instant};
+use rtfm::Instant;
const PERIOD: u32 = 8_000_000;
// NOTE: does NOT work on QEMU!
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init(schedule = [foo])]
- fn init() {
- schedule.foo(Instant::now() + PERIOD.cycles()).unwrap();
+ fn init(c: init::Context) {
+ c.schedule.foo(Instant::now() + PERIOD.cycles()).unwrap();
}
#[task(schedule = [foo])]
- fn foo() {
+ fn foo(c: foo::Context) {
let now = Instant::now();
- hprintln!("foo(scheduled = {:?}, now = {:?})", scheduled, now).unwrap();
+ hprintln!("foo(scheduled = {:?}, now = {:?})", c.scheduled, now).unwrap();
- schedule.foo(scheduled + PERIOD.cycles()).unwrap();
+ c.schedule.foo(c.scheduled + PERIOD.cycles()).unwrap();
}
extern "C" {
diff --git a/examples/ramfunc.rs b/examples/ramfunc.rs
index 37ea82a7..4b0d69c7 100644
--- a/examples/ramfunc.rs
+++ b/examples/ramfunc.rs
@@ -8,18 +8,17 @@
extern crate panic_semihosting;
use cortex_m_semihosting::{debug, hprintln};
-use rtfm::app;
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init(spawn = [bar])]
- fn init() {
- spawn.bar().unwrap();
+ fn init(c: init::Context) {
+ c.spawn.bar().unwrap();
}
#[inline(never)]
#[task]
- fn foo() {
+ fn foo(_: foo::Context) {
hprintln!("foo").unwrap();
debug::exit(debug::EXIT_SUCCESS);
@@ -29,8 +28,8 @@ const APP: () = {
#[inline(never)]
#[link_section = ".data.bar"]
#[task(priority = 2, spawn = [foo])]
- fn bar() {
- spawn.foo().unwrap();
+ fn bar(c: bar::Context) {
+ c.spawn.foo().unwrap();
}
extern "C" {
diff --git a/examples/resource.rs b/examples/resource.rs
index 5ddab9e8..06bdf395 100644
--- a/examples/resource.rs
+++ b/examples/resource.rs
@@ -9,21 +9,20 @@ extern crate panic_semihosting;
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
-use rtfm::app;
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
// A resource
static mut SHARED: u32 = 0;
#[init]
- fn init() {
+ fn init(_: init::Context) {
rtfm::pend(Interrupt::UART0);
rtfm::pend(Interrupt::UART1);
}
#[idle]
- fn idle() -> ! {
+ fn idle(_: idle::Context) -> ! {
debug::exit(debug::EXIT_SUCCESS);
// error: `SHARED` can't be accessed from this context
@@ -34,17 +33,17 @@ const APP: () = {
// `SHARED` can be access from this context
#[interrupt(resources = [SHARED])]
- fn UART0() {
- *resources.SHARED += 1;
+ fn UART0(mut c: UART0::Context) {
+ *c.resources.SHARED += 1;
- hprintln!("UART0: SHARED = {}", resources.SHARED).unwrap();
+ hprintln!("UART0: SHARED = {}", c.resources.SHARED).unwrap();
}
// `SHARED` can be access from this context
#[interrupt(resources = [SHARED])]
- fn UART1() {
- *resources.SHARED += 1;
+ fn UART1(mut c: UART1::Context) {
+ *c.resources.SHARED += 1;
- hprintln!("UART1: SHARED = {}", resources.SHARED).unwrap();
+ hprintln!("UART1: SHARED = {}", c.resources.SHARED).unwrap();
}
};
diff --git a/examples/schedule.rs b/examples/schedule.rs
index fd633473..eaafb4c9 100644
--- a/examples/schedule.rs
+++ b/examples/schedule.rs
@@ -8,31 +8,31 @@
extern crate panic_semihosting;
use cortex_m_semihosting::hprintln;
-use rtfm::{app, Instant};
+use rtfm::Instant;
// NOTE: does NOT work on QEMU!
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init(schedule = [foo, bar])]
- fn init() {
+ fn init(c: init::Context) {
let now = Instant::now();
hprintln!("init @ {:?}", now).unwrap();
// Schedule `foo` to run 8e6 cycles (clock cycles) in the future
- schedule.foo(now + 8_000_000.cycles()).unwrap();
+ c.schedule.foo(now + 8_000_000.cycles()).unwrap();
// Schedule `bar` to run 4e6 cycles in the future
- schedule.bar(now + 4_000_000.cycles()).unwrap();
+ c.schedule.bar(now + 4_000_000.cycles()).unwrap();
}
#[task]
- fn foo() {
+ fn foo(_: foo::Context) {
hprintln!("foo @ {:?}", Instant::now()).unwrap();
}
#[task]
- fn bar() {
+ fn bar(_: bar::Context) {
hprintln!("bar @ {:?}", Instant::now()).unwrap();
}
diff --git a/examples/shared-with-init.rs b/examples/shared-with-init.rs
index 5ddd2cc3..0fb9191c 100644
--- a/examples/shared-with-init.rs
+++ b/examples/shared-with-init.rs
@@ -18,17 +18,17 @@ const APP: () = {
static mut SHARED: Option<MustBeSend> = None;
#[init(resources = [SHARED])]
- fn init() {
+ fn init(c: init::Context) {
// this `message` will be sent to task `UART0`
let message = MustBeSend;
- *resources.SHARED = Some(message);
+ *c.resources.SHARED = Some(message);
rtfm::pend(Interrupt::UART0);
}
#[interrupt(resources = [SHARED])]
- fn UART0() {
- if let Some(message) = resources.SHARED.take() {
+ fn UART0(c: UART0::Context) {
+ if let Some(message) = c.resources.SHARED.take() {
// `message` has been received
drop(message);
diff --git a/examples/singleton.rs b/examples/singleton.rs
deleted file mode 100644
index 9e48e541..00000000
--- a/examples/singleton.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-//! examples/singleton.rs
-
-#![deny(unsafe_code)]
-#![deny(warnings)]
-#![no_main]
-#![no_std]
-
-extern crate panic_semihosting;
-
-use alloc_singleton::stable::pool::{Box, Pool};
-use cortex_m_semihosting::{debug, hprintln};
-use lm3s6965::Interrupt;
-use rtfm::app;
-
-#[app(device = lm3s6965)]
-const APP: () = {
- #[Singleton(Send)]
- static mut M: [u32; 2] = [0; 2];
-
- static mut P: Pool<M> = ();
-
- #[init(resources = [M])]
- fn init() -> init::LateResources {
- rtfm::pend(Interrupt::I2C0);
-
- init::LateResources {
- P: Pool::new(resources.M),
- }
- }
-
- #[interrupt(
- priority = 2,
- resources = [P],
- spawn = [foo, bar],
- )]
- fn I2C0() {
- spawn.foo(resources.P.alloc(1).unwrap()).unwrap();
- spawn.bar(resources.P.alloc(2).unwrap()).unwrap();
- }
-
- #[task(resources = [P])]
- fn foo(x: Box<M>) {
- hprintln!("foo({})", x).unwrap();
-
- resources.P.lock(|p| p.dealloc(x));
-
- debug::exit(debug::EXIT_SUCCESS);
- }
-
- #[task(priority = 2, resources = [P])]
- fn bar(x: Box<M>) {
- hprintln!("bar({})", x).unwrap();
-
- resources.P.dealloc(x);
- }
-
- extern "C" {
- fn UART0();
- fn UART1();
- }
-};
diff --git a/examples/smallest.rs b/examples/smallest.rs
index e4d86be9..c1537168 100644
--- a/examples/smallest.rs
+++ b/examples/smallest.rs
@@ -13,5 +13,5 @@ use rtfm::app;
#[app(device = lm3s6965)]
const APP: () = {
#[init]
- fn init() {}
+ fn init(_: init::Context) {}
};
diff --git a/examples/static.rs b/examples/static.rs
index 0309b681..2e3b5b41 100644
--- a/examples/static.rs
+++ b/examples/static.rs
@@ -9,14 +9,13 @@ extern crate panic_semihosting;
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
-use rtfm::app;
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
static KEY: u32 = ();
#[init]
- fn init() -> init::LateResources {
+ fn init(_: init::Context) -> init::LateResources {
rtfm::pend(Interrupt::UART0);
rtfm::pend(Interrupt::UART1);
@@ -24,14 +23,14 @@ const APP: () = {
}
#[interrupt(resources = [KEY])]
- fn UART0() {
- hprintln!("UART0(KEY = {:#x})", resources.KEY).unwrap();
+ fn UART0(c: UART0::Context) {
+ hprintln!("UART0(KEY = {:#x})", c.resources.KEY).unwrap();
debug::exit(debug::EXIT_SUCCESS);
}
#[interrupt(priority = 2, resources = [KEY])]
- fn UART1() {
- hprintln!("UART1(KEY = {:#x})", resources.KEY).unwrap();
+ fn UART1(c: UART1::Context) {
+ hprintln!("UART1(KEY = {:#x})", c.resources.KEY).unwrap();
}
};
diff --git a/examples/task.rs b/examples/task.rs
index 4f168bb8..5bb32acb 100644
--- a/examples/task.rs
+++ b/examples/task.rs
@@ -8,38 +8,37 @@
extern crate panic_semihosting;
use cortex_m_semihosting::{debug, hprintln};
-use rtfm::app;
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
#[init(spawn = [foo])]
- fn init() {
- spawn.foo().unwrap();
+ fn init(c: init::Context) {
+ c.spawn.foo().unwrap();
}
#[task(spawn = [bar, baz])]
- fn foo() {
+ fn foo(c: foo::Context) {
hprintln!("foo").unwrap();
// spawns `bar` onto the task scheduler
// `foo` and `bar` have the same priority so `bar` will not run until
// after `foo` terminates
- spawn.bar().unwrap();
+ c.spawn.bar().unwrap();
// spawns `baz` onto the task scheduler
// `baz` has higher priority than `foo` so it immediately preempts `foo`
- spawn.baz().unwrap();
+ c.spawn.baz().unwrap();
}
#[task]
- fn bar() {
+ fn bar(_: bar::Context) {
hprintln!("bar").unwrap();
debug::exit(debug::EXIT_SUCCESS);
}
#[task(priority = 2)]
- fn baz() {
+ fn baz(_: baz::Context) {
hprintln!("baz").unwrap();
}
diff --git a/examples/types.rs b/examples/types.rs
index c1b8cd69..c3dd89ca 100644
--- a/examples/types.rs
+++ b/examples/types.rs
@@ -8,45 +8,45 @@
extern crate panic_semihosting;
use cortex_m_semihosting::debug;
-use rtfm::{app, Exclusive, Instant};
+use rtfm::{Exclusive, Instant};
-#[app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965)]
const APP: () = {
static mut SHARED: u32 = 0;
#[init(schedule = [foo], spawn = [foo])]
- fn init() {
- let _: Instant = start;
- let _: rtfm::Peripherals = core;
- let _: lm3s6965::Peripherals = device;
- let _: init::Schedule = schedule;
- let _: init::Spawn = spawn;
+ fn init(c: init::Context) {
+ let _: Instant = c.start;
+ let _: rtfm::Peripherals = c.core;
+ let _: lm3s6965::Peripherals = c.device;
+ let _: init::Schedule = c.schedule;
+ let _: init::Spawn = c.spawn;
debug::exit(debug::EXIT_SUCCESS);
}
#[exception(schedule = [foo], spawn = [foo])]
- fn SVCall() {
- let _: Instant = start;
- let _: SVCall::Schedule = schedule;
- let _: SVCall::Spawn = spawn;
+ fn SVCall(c: SVCall::Context) {
+ let _: Instant = c.start;
+ let _: SVCall::Schedule = c.schedule;
+ let _: SVCall::Spawn = c.spawn;
}
#[interrupt(resources = [SHARED], schedule = [foo], spawn = [foo])]
- fn UART0() {
- let _: Instant = start;
- let _: resources::SHARED = resources.SHARED;
- let _: UART0::Schedule = schedule;
- let _: UART0::Spawn = spawn;
+ fn UART0(c: UART0::Context) {
+ let _: Instant = c.start;
+ let _: resources::SHARED = c.resources.SHARED;
+ let _: UART0::Schedule = c.schedule;
+ let _: UART0::Spawn = c.spawn;
}
#[task(priority = 2, resources = [SHARED], schedule = [foo], spawn = [foo])]
- fn foo() {
- let _: Instant = scheduled;
- let _: Exclusive<u32> = resources.SHARED;
- let _: foo::Resources = resources;
- let _: foo::Schedule = schedule;
- let _: foo::Spawn = spawn;
+ fn foo(c: foo::Context) {
+ let _: Instant = c.scheduled;
+ let _: Exclusive<u32> = c.resources.SHARED;
+ let _: foo::Resources = c.resources;
+ let _: foo::Schedule = c.schedule;
+ let _: foo::Spawn = c.spawn;
}
extern "C" {