aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJorge Aparicio <jorge@japaric.io>2019-06-20 06:19:59 +0200
committerJorge Aparicio <jorge@japaric.io>2019-06-20 06:19:59 +0200
commit4e51bb68b976c6bb6a9a989dc560d2a8123a84ca (patch)
tree5c14f21f904c15034d477c7e4400e01d212a9f2a /examples
parentb150ab29e25637e41ba5de81f6cbbdfe24834a3f (diff)
RFC #207
Diffstat (limited to 'examples')
-rw-r--r--examples/baseline.rs4
-rw-r--r--examples/binds.rs2
-rw-r--r--examples/capacity.rs4
-rw-r--r--examples/generics.rs8
-rw-r--r--examples/interrupt.rs4
-rw-r--r--examples/late.rs4
-rw-r--r--examples/lock.rs12
-rw-r--r--examples/pool.rs4
-rw-r--r--examples/resource.rs8
-rw-r--r--examples/shared-with-init.rs4
-rw-r--r--examples/static.rs8
-rw-r--r--examples/t-binds.rs6
-rw-r--r--examples/t-resource.rs8
-rw-r--r--examples/t-schedule.rs8
-rw-r--r--examples/t-spawn.rs8
-rw-r--r--examples/types.rs16
16 files changed, 55 insertions, 53 deletions
diff --git a/examples/baseline.rs b/examples/baseline.rs
index cc9b412..3a8ab0e 100644
--- a/examples/baseline.rs
+++ b/examples/baseline.rs
@@ -35,8 +35,8 @@ const APP: () = {
}
}
- #[interrupt(spawn = [foo])]
- fn UART0(c: UART0::Context) {
+ #[task(binds = UART0, spawn = [foo])]
+ fn uart0(c: uart0::Context) {
hprintln!("UART0(baseline = {:?})", c.start).unwrap();
// `foo` inherits the baseline of `UART0`: its `start` time
diff --git a/examples/binds.rs b/examples/binds.rs
index 1959d75..b10cb43 100644
--- a/examples/binds.rs
+++ b/examples/binds.rs
@@ -30,7 +30,7 @@ const APP: () = {
loop {}
}
- #[interrupt(binds = UART0)]
+ #[task(binds = UART0)]
fn foo(_: foo::Context) {
static mut TIMES: u32 = 0;
diff --git a/examples/capacity.rs b/examples/capacity.rs
index e1a835c..ebc86b8 100644
--- a/examples/capacity.rs
+++ b/examples/capacity.rs
@@ -16,8 +16,8 @@ const APP: () = {
rtfm::pend(Interrupt::UART0);
}
- #[interrupt(spawn = [foo, bar])]
- fn UART0(c: UART0::Context) {
+ #[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();
diff --git a/examples/generics.rs b/examples/generics.rs
index a35ba23..562470d 100644
--- a/examples/generics.rs
+++ b/examples/generics.rs
@@ -20,8 +20,8 @@ const APP: () = {
rtfm::pend(Interrupt::UART1);
}
- #[interrupt(resources = [SHARED])]
- fn UART0(c: UART0::Context) {
+ #[task(binds = UART0, resources = [SHARED])]
+ fn uart0(c: uart0::Context) {
static mut STATE: u32 = 0;
hprintln!("UART0(STATE = {})", *STATE).unwrap();
@@ -33,8 +33,8 @@ const APP: () = {
debug::exit(debug::EXIT_SUCCESS);
}
- #[interrupt(priority = 2, resources = [SHARED])]
- fn UART1(c: UART1::Context) {
+ #[task(binds = UART1, priority = 2, resources = [SHARED])]
+ fn uart1(c: uart1::Context) {
static mut STATE: u32 = 0;
hprintln!("UART1(STATE = {})", *STATE).unwrap();
diff --git a/examples/interrupt.rs b/examples/interrupt.rs
index 3fe8ff3..f0069b8 100644
--- a/examples/interrupt.rs
+++ b/examples/interrupt.rs
@@ -33,8 +33,8 @@ const APP: () = {
loop {}
}
- #[interrupt]
- fn UART0(_: UART0::Context) {
+ #[task(binds = 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 4d48a6a..19807ff 100644
--- a/examples/late.rs
+++ b/examples/late.rs
@@ -47,8 +47,8 @@ const APP: () = {
}
}
- #[interrupt(resources = [P])]
- fn UART0(c: UART0::Context) {
+ #[task(binds = UART0, resources = [P])]
+ fn uart0(c: uart0::Context) {
c.resources.P.enqueue(42).unwrap();
}
};
diff --git a/examples/lock.rs b/examples/lock.rs
index b7d36b4..17b6a58 100644
--- a/examples/lock.rs
+++ b/examples/lock.rs
@@ -19,8 +19,8 @@ const APP: () = {
}
// when omitted priority is assumed to be `1`
- #[interrupt(resources = [SHARED])]
- fn GPIOA(mut c: GPIOA::Context) {
+ #[task(binds = GPIOA, resources = [SHARED])]
+ fn gpioa(mut c: gpioa::Context) {
hprintln!("A").unwrap();
// the lower priority task requires a critical section to access the data
@@ -44,16 +44,16 @@ const APP: () = {
debug::exit(debug::EXIT_SUCCESS);
}
- #[interrupt(priority = 2, resources = [SHARED])]
- fn GPIOB(c: GPIOB::Context) {
+ #[task(binds = GPIOB, priority = 2, resources = [SHARED])]
+ fn gpiob(c: gpiob::Context) {
// the higher priority task does *not* need a critical section
*c.resources.SHARED += 1;
hprintln!("D - SHARED = {}", *c.resources.SHARED).unwrap();
}
- #[interrupt(priority = 3)]
- fn GPIOC(_: GPIOC::Context) {
+ #[task(binds = GPIOC, priority = 3)]
+ fn gpioc(_: gpioc::Context) {
hprintln!("C").unwrap();
}
};
diff --git a/examples/pool.rs b/examples/pool.rs
index db321b5..8c44cb1 100644
--- a/examples/pool.rs
+++ b/examples/pool.rs
@@ -29,8 +29,8 @@ const APP: () = {
rtfm::pend(Interrupt::I2C0);
}
- #[interrupt(priority = 2, spawn = [foo, bar])]
- fn I2C0(c: I2C0::Context) {
+ #[task(binds = I2C0, priority = 2, spawn = [foo, bar])]
+ fn i2c0(c: i2c0::Context) {
// claim a memory block, leave it uninitialized and ..
let x = P::alloc().unwrap().freeze();
diff --git a/examples/resource.rs b/examples/resource.rs
index 8268950..661f8c3 100644
--- a/examples/resource.rs
+++ b/examples/resource.rs
@@ -31,16 +31,16 @@ const APP: () = {
}
// `SHARED` can be access from this context
- #[interrupt(resources = [SHARED])]
- fn UART0(c: UART0::Context) {
+ #[task(binds = UART0, resources = [SHARED])]
+ fn uart0(c: uart0::Context) {
*c.resources.SHARED += 1;
hprintln!("UART0: SHARED = {}", c.resources.SHARED).unwrap();
}
// `SHARED` can be access from this context
- #[interrupt(resources = [SHARED])]
- fn UART1(c: UART1::Context) {
+ #[task(binds = UART1, resources = [SHARED])]
+ fn uart1(c: uart1::Context) {
*c.resources.SHARED += 1;
hprintln!("UART1: SHARED = {}", c.resources.SHARED).unwrap();
diff --git a/examples/shared-with-init.rs b/examples/shared-with-init.rs
index 1640ca9..ed73c8b 100644
--- a/examples/shared-with-init.rs
+++ b/examples/shared-with-init.rs
@@ -25,8 +25,8 @@ const APP: () = {
rtfm::pend(Interrupt::UART0);
}
- #[interrupt(resources = [SHARED])]
- fn UART0(c: UART0::Context) {
+ #[task(binds = UART0, resources = [SHARED])]
+ fn uart0(c: uart0::Context) {
if let Some(message) = c.resources.SHARED.take() {
// `message` has been received
drop(message);
diff --git a/examples/static.rs b/examples/static.rs
index eeb522f..5eb7b19 100644
--- a/examples/static.rs
+++ b/examples/static.rs
@@ -23,15 +23,15 @@ const APP: () = {
init::LateResources { KEY: 0xdeadbeef }
}
- #[interrupt(resources = [KEY])]
- fn UART0(c: UART0::Context) {
+ #[task(binds = UART0, resources = [KEY])]
+ 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(c: UART1::Context) {
+ #[task(binds = UART1, priority = 2, resources = [KEY])]
+ fn uart1(c: uart1::Context) {
hprintln!("UART1(KEY = {:#x})", c.resources.KEY).unwrap();
}
};
diff --git a/examples/t-binds.rs b/examples/t-binds.rs
index b4693a4..dda8e20 100644
--- a/examples/t-binds.rs
+++ b/examples/t-binds.rs
@@ -12,12 +12,14 @@ const APP: () = {
#[init]
fn init(_: init::Context) {}
- #[exception(binds = SVCall)]
+ // Cortex-M exception
+ #[task(binds = SVCall)]
fn foo(c: foo::Context) {
foo_trampoline(c)
}
- #[interrupt(binds = UART0)]
+ // LM3S6965 interrupt
+ #[task(binds = UART0)]
fn bar(c: bar::Context) {
bar_trampoline(c)
}
diff --git a/examples/t-resource.rs b/examples/t-resource.rs
index 40dc2a6..adcc04b 100644
--- a/examples/t-resource.rs
+++ b/examples/t-resource.rs
@@ -51,8 +51,8 @@ const APP: () = {
loop {}
}
- #[interrupt(resources = [O3, S1, S2, S3])]
- fn UART0(c: UART0::Context) {
+ #[task(binds = UART0, resources = [O3, S1, S2, S3])]
+ fn uart0(c: uart0::Context) {
// owned by interrupt == `&mut`
let _: &mut u32 = c.resources.O3;
@@ -66,8 +66,8 @@ const APP: () = {
let _: &u32 = c.resources.S3;
}
- #[interrupt(resources = [S2, O5])]
- fn UART1(c: UART1::Context) {
+ #[task(binds = UART1, resources = [S2, O5])]
+ fn uart1(c: uart1::Context) {
// owned by interrupt == `&` if read-only
let _: &u32 = c.resources.O5;
diff --git a/examples/t-schedule.rs b/examples/t-schedule.rs
index 67ff358..e6035b3 100644
--- a/examples/t-schedule.rs
+++ b/examples/t-schedule.rs
@@ -26,15 +26,15 @@ const APP: () = {
loop {}
}
- #[exception(schedule = [foo, bar, baz])]
- fn SVCall(c: SVCall::Context) {
+ #[task(binds = SVCall, schedule = [foo, bar, baz])]
+ 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);
}
- #[interrupt(schedule = [foo, bar, baz])]
- fn UART0(c: UART0::Context) {
+ #[task(binds = UART0, schedule = [foo, bar, baz])]
+ 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);
diff --git a/examples/t-spawn.rs b/examples/t-spawn.rs
index 6bb9b31..682b9b8 100644
--- a/examples/t-spawn.rs
+++ b/examples/t-spawn.rs
@@ -25,15 +25,15 @@ const APP: () = {
loop {}
}
- #[exception(spawn = [foo, bar, baz])]
- fn SVCall(c: SVCall::Context) {
+ #[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);
}
- #[interrupt(spawn = [foo, bar, baz])]
- fn UART0(c: UART0::Context) {
+ #[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);
diff --git a/examples/types.rs b/examples/types.rs
index 2e72f0a..3e9c7ea 100644
--- a/examples/types.rs
+++ b/examples/types.rs
@@ -24,19 +24,19 @@ const APP: () = {
debug::exit(debug::EXIT_SUCCESS);
}
- #[exception(schedule = [foo], spawn = [foo])]
- fn SVCall(c: SVCall::Context) {
+ #[task(binds = SVCall, schedule = [foo], spawn = [foo])]
+ fn svcall(c: svcall::Context) {
let _: Instant = c.start;
- let _: SVCall::Schedule = c.schedule;
- let _: SVCall::Spawn = c.spawn;
+ let _: svcall::Schedule = c.schedule;
+ let _: svcall::Spawn = c.spawn;
}
- #[interrupt(resources = [SHARED], schedule = [foo], spawn = [foo])]
- fn UART0(c: UART0::Context) {
+ #[task(binds = UART0, resources = [SHARED], schedule = [foo], spawn = [foo])]
+ 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;
+ let _: uart0::Schedule = c.schedule;
+ let _: uart0::Spawn = c.spawn;
}
#[task(priority = 2, resources = [SHARED], schedule = [foo], spawn = [foo])]