aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/baseline.rs5
-rw-r--r--examples/binds.rs3
-rw-r--r--examples/capacity.rs3
-rw-r--r--examples/cfg.rs9
-rw-r--r--examples/generics.rs13
-rw-r--r--examples/idle.rs3
-rw-r--r--examples/init.rs7
-rw-r--r--examples/interrupt.rs3
-rw-r--r--examples/late.rs9
-rw-r--r--examples/lock.rs5
-rw-r--r--examples/message.rs3
-rw-r--r--examples/not-send.rs7
-rw-r--r--examples/not-sync.rs3
-rw-r--r--examples/periodic.rs7
-rw-r--r--examples/pool.rs3
-rw-r--r--examples/ramfunc.rs3
-rw-r--r--examples/resource.rs7
-rw-r--r--examples/schedule.rs7
-rw-r--r--examples/shared-with-init.rs3
-rw-r--r--examples/smallest.rs9
-rw-r--r--examples/static.rs7
-rw-r--r--examples/t-binds.rs30
-rw-r--r--examples/t-cfg.rs47
-rw-r--r--examples/t-late-not-send.rs36
-rw-r--r--examples/t-resource.rs77
-rw-r--r--examples/t-schedule.rs59
-rw-r--r--examples/t-spawn.rs58
-rw-r--r--examples/task.rs3
-rw-r--r--examples/types.rs9
29 files changed, 360 insertions, 78 deletions
diff --git a/examples/baseline.rs b/examples/baseline.rs
index d743107d..cc9b412c 100644
--- a/examples/baseline.rs
+++ b/examples/baseline.rs
@@ -5,13 +5,12 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
+use panic_semihosting as _;
// NOTE: does NOT properly work on QEMU
-#[rtfm::app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965, monotonic = rtfm::cyccnt::CYCCNT)]
const APP: () = {
#[init(spawn = [foo])]
fn init(c: init::Context) {
diff --git a/examples/binds.rs b/examples/binds.rs
index 3d2d9b54..1959d759 100644
--- a/examples/binds.rs
+++ b/examples/binds.rs
@@ -5,10 +5,9 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
+use panic_semihosting as _;
// `examples/interrupt.rs` rewritten to use `binds`
#[rtfm::app(device = lm3s6965)]
diff --git a/examples/capacity.rs b/examples/capacity.rs
index 07edd9b8..e1a835ca 100644
--- a/examples/capacity.rs
+++ b/examples/capacity.rs
@@ -5,10 +5,9 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
+use panic_semihosting as _;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
diff --git a/examples/cfg.rs b/examples/cfg.rs
index 03f9dbdc..b1f65cfd 100644
--- a/examples/cfg.rs
+++ b/examples/cfg.rs
@@ -5,10 +5,9 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
#[cfg(debug_assertions)]
use cortex_m_semihosting::hprintln;
+use panic_semihosting as _;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
@@ -21,12 +20,12 @@ const APP: () = {
}
#[task(priority = 3, resources = [COUNT], spawn = [log])]
- fn foo(c: foo::Context) {
+ fn foo(_c: foo::Context) {
#[cfg(debug_assertions)]
{
- *c.resources.COUNT += 1;
+ *_c.resources.COUNT += 1;
- c.spawn.log(*c.resources.COUNT).ok();
+ _c.spawn.log(*_c.resources.COUNT).ok();
}
// this wouldn't compile in `release` mode
diff --git a/examples/generics.rs b/examples/generics.rs
index e624da39..a35ba237 100644
--- a/examples/generics.rs
+++ b/examples/generics.rs
@@ -5,11 +5,10 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
-use rtfm::Mutex;
+use panic_semihosting as _;
+use rtfm::{Exclusive, Mutex};
#[rtfm::app(device = lm3s6965)]
const APP: () = {
@@ -35,17 +34,15 @@ const APP: () = {
}
#[interrupt(priority = 2, resources = [SHARED])]
- fn UART1(mut c: UART1::Context) {
+ fn UART1(c: UART1::Context) {
static mut STATE: u32 = 0;
hprintln!("UART1(STATE = {})", *STATE).unwrap();
- // just to show that `SHARED` can be accessed directly and ..
+ // just to show that `SHARED` can be accessed directly
*c.resources.SHARED += 0;
- // .. also through a (no-op) `lock`
- c.resources.SHARED.lock(|shared| *shared += 0);
- advance(STATE, c.resources.SHARED);
+ advance(STATE, Exclusive(c.resources.SHARED));
}
};
diff --git a/examples/idle.rs b/examples/idle.rs
index d10cc43e..c6f676b0 100644
--- a/examples/idle.rs
+++ b/examples/idle.rs
@@ -5,9 +5,8 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
+use panic_semihosting as _;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
diff --git a/examples/init.rs b/examples/init.rs
index df687794..361db4b7 100644
--- a/examples/init.rs
+++ b/examples/init.rs
@@ -5,18 +5,17 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
+use panic_semihosting as _;
-#[rtfm::app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965, peripherals = true)]
const APP: () = {
#[init]
fn init(c: init::Context) {
static mut X: u32 = 0;
// Cortex-M peripherals
- let _core: rtfm::Peripherals = c.core;
+ let _core: cortex_m::Peripherals = c.core;
// Device specific peripherals
let _device: lm3s6965::Peripherals = c.device;
diff --git a/examples/interrupt.rs b/examples/interrupt.rs
index dd6efa0d..3fe8ff35 100644
--- a/examples/interrupt.rs
+++ b/examples/interrupt.rs
@@ -5,10 +5,9 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
+use panic_semihosting as _;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
diff --git a/examples/late.rs b/examples/late.rs
index 0074fb32..4d48a6a2 100644
--- a/examples/late.rs
+++ b/examples/late.rs
@@ -5,20 +5,21 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
use heapless::{
consts::*,
spsc::{Consumer, Producer, Queue},
};
use lm3s6965::Interrupt;
+use panic_semihosting as _;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
// Late resources
- static mut P: Producer<'static, u32, U4> = ();
- static mut C: Consumer<'static, u32, U4> = ();
+ extern "C" {
+ static mut P: Producer<'static, u32, U4>;
+ static mut C: Consumer<'static, u32, U4>;
+ }
#[init]
fn init(_: init::Context) -> init::LateResources {
diff --git a/examples/lock.rs b/examples/lock.rs
index 814c7364..b7d36b41 100644
--- a/examples/lock.rs
+++ b/examples/lock.rs
@@ -5,10 +5,9 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
+use panic_semihosting as _;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
@@ -46,7 +45,7 @@ const APP: () = {
}
#[interrupt(priority = 2, resources = [SHARED])]
- fn GPIOB(mut c: GPIOB::Context) {
+ fn GPIOB(c: GPIOB::Context) {
// the higher priority task does *not* need a critical section
*c.resources.SHARED += 1;
diff --git a/examples/message.rs b/examples/message.rs
index 1fd3b9d4..8bfed523 100644
--- a/examples/message.rs
+++ b/examples/message.rs
@@ -5,9 +5,8 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
+use panic_semihosting as _;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
diff --git a/examples/not-send.rs b/examples/not-send.rs
index c1b6bcdd..f240e511 100644
--- a/examples/not-send.rs
+++ b/examples/not-send.rs
@@ -5,11 +5,10 @@
#![no_main]
#![no_std]
-extern crate panic_halt;
-
use core::marker::PhantomData;
use cortex_m_semihosting::debug;
+use panic_halt as _;
use rtfm::app;
pub struct NotSend {
@@ -38,13 +37,13 @@ const APP: () = {
}
#[task(priority = 2, resources = [SHARED])]
- fn baz(mut c: baz::Context) {
+ 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(mut c: quux::Context) {
+ fn quux(c: quux::Context) {
// scenario 2
let _not_send = c.resources.SHARED.take().unwrap();
diff --git a/examples/not-sync.rs b/examples/not-sync.rs
index bc714065..6b499111 100644
--- a/examples/not-sync.rs
+++ b/examples/not-sync.rs
@@ -5,11 +5,10 @@
#![no_main]
#![no_std]
-extern crate panic_halt;
-
use core::marker::PhantomData;
use cortex_m_semihosting::debug;
+use panic_halt as _;
pub struct NotSync {
_0: PhantomData<*const ()>,
diff --git a/examples/periodic.rs b/examples/periodic.rs
index f7841183..b8910db2 100644
--- a/examples/periodic.rs
+++ b/examples/periodic.rs
@@ -5,15 +5,14 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::hprintln;
-use rtfm::Instant;
+use panic_semihosting as _;
+use rtfm::cyccnt::{Instant, U32Ext};
const PERIOD: u32 = 8_000_000;
// NOTE: does NOT work on QEMU!
-#[rtfm::app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965, monotonic = rtfm::cyccnt::CYCCNT)]
const APP: () = {
#[init(schedule = [foo])]
fn init(c: init::Context) {
diff --git a/examples/pool.rs b/examples/pool.rs
index 0b594b19..db321b53 100644
--- a/examples/pool.rs
+++ b/examples/pool.rs
@@ -5,14 +5,13 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
use heapless::{
pool,
pool::singleton::{Box, Pool},
};
use lm3s6965::Interrupt;
+use panic_semihosting as _;
use rtfm::app;
// Declare a pool of 128-byte memory blocks
diff --git a/examples/ramfunc.rs b/examples/ramfunc.rs
index 4b0d69c7..c38635ff 100644
--- a/examples/ramfunc.rs
+++ b/examples/ramfunc.rs
@@ -5,9 +5,8 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
+use panic_semihosting as _;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
diff --git a/examples/resource.rs b/examples/resource.rs
index 06bdf395..82689504 100644
--- a/examples/resource.rs
+++ b/examples/resource.rs
@@ -5,10 +5,9 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
+use panic_semihosting as _;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
@@ -33,7 +32,7 @@ const APP: () = {
// `SHARED` can be access from this context
#[interrupt(resources = [SHARED])]
- fn UART0(mut c: UART0::Context) {
+ fn UART0(c: UART0::Context) {
*c.resources.SHARED += 1;
hprintln!("UART0: SHARED = {}", c.resources.SHARED).unwrap();
@@ -41,7 +40,7 @@ const APP: () = {
// `SHARED` can be access from this context
#[interrupt(resources = [SHARED])]
- fn UART1(mut c: UART1::Context) {
+ fn UART1(c: UART1::Context) {
*c.resources.SHARED += 1;
hprintln!("UART1: SHARED = {}", c.resources.SHARED).unwrap();
diff --git a/examples/schedule.rs b/examples/schedule.rs
index eaafb4c9..1cf2b1ea 100644
--- a/examples/schedule.rs
+++ b/examples/schedule.rs
@@ -5,13 +5,12 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::hprintln;
-use rtfm::Instant;
+use panic_halt as _;
+use rtfm::cyccnt::{Instant, U32Ext as _};
// NOTE: does NOT work on QEMU!
-#[rtfm::app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965, monotonic = rtfm::cyccnt::CYCCNT)]
const APP: () = {
#[init(schedule = [foo, bar])]
fn init(c: init::Context) {
diff --git a/examples/shared-with-init.rs b/examples/shared-with-init.rs
index 0fb9191c..1640ca9b 100644
--- a/examples/shared-with-init.rs
+++ b/examples/shared-with-init.rs
@@ -5,10 +5,9 @@
#![no_main]
#![no_std]
-extern crate panic_halt;
-
use cortex_m_semihosting::debug;
use lm3s6965::Interrupt;
+use panic_halt as _;
use rtfm::app;
pub struct MustBeSend;
diff --git a/examples/smallest.rs b/examples/smallest.rs
index c1537168..e4228061 100644
--- a/examples/smallest.rs
+++ b/examples/smallest.rs
@@ -5,13 +5,8 @@
#![no_main]
#![no_std]
-// panic-handler crate
-extern crate panic_semihosting;
-
+use panic_semihosting as _; // panic handler
use rtfm::app;
#[app(device = lm3s6965)]
-const APP: () = {
- #[init]
- fn init(_: init::Context) {}
-};
+const APP: () = {};
diff --git a/examples/static.rs b/examples/static.rs
index 2e3b5b41..eeb522f5 100644
--- a/examples/static.rs
+++ b/examples/static.rs
@@ -5,14 +5,15 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
+use panic_semihosting as _;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
- static KEY: u32 = ();
+ extern "C" {
+ static KEY: u32;
+ }
#[init]
fn init(_: init::Context) -> init::LateResources {
diff --git a/examples/t-binds.rs b/examples/t-binds.rs
new file mode 100644
index 00000000..b4693a47
--- /dev/null
+++ b/examples/t-binds.rs
@@ -0,0 +1,30 @@
+//! [compile-pass] Check that `binds` works as advertised
+
+#![deny(unsafe_code)]
+#![deny(warnings)]
+#![no_main]
+#![no_std]
+
+use panic_halt as _;
+
+#[rtfm::app(device = lm3s6965)]
+const APP: () = {
+ #[init]
+ fn init(_: init::Context) {}
+
+ #[exception(binds = SVCall)]
+ fn foo(c: foo::Context) {
+ foo_trampoline(c)
+ }
+
+ #[interrupt(binds = UART0)]
+ fn bar(c: bar::Context) {
+ bar_trampoline(c)
+ }
+};
+
+#[allow(dead_code)]
+fn foo_trampoline(_: foo::Context) {}
+
+#[allow(dead_code)]
+fn bar_trampoline(_: bar::Context) {}
diff --git a/examples/t-cfg.rs b/examples/t-cfg.rs
new file mode 100644
index 00000000..158eef55
--- /dev/null
+++ b/examples/t-cfg.rs
@@ -0,0 +1,47 @@
+//! [compile-pass] check that `#[cfg]` attributes are respected
+
+#![no_main]
+#![no_std]
+
+use panic_halt as _;
+
+#[rtfm::app(device = lm3s6965, monotonic = rtfm::cyccnt::CYCCNT)]
+const APP: () = {
+ #[cfg(never)]
+ static mut FOO: u32 = 0;
+
+ #[init]
+ fn init(_: init::Context) {
+ #[cfg(never)]
+ static mut BAR: u32 = 0;
+ }
+
+ #[idle]
+ fn idle(_: idle::Context) -> ! {
+ #[cfg(never)]
+ static mut BAR: u32 = 0;
+
+ loop {}
+ }
+
+ #[task(resources = [FOO], schedule = [quux], spawn = [quux])]
+ fn foo(_: foo::Context) {
+ #[cfg(never)]
+ static mut BAR: u32 = 0;
+ }
+
+ #[task(priority = 3, resources = [FOO], schedule = [quux], spawn = [quux])]
+ fn bar(_: bar::Context) {
+ #[cfg(never)]
+ static mut BAR: u32 = 0;
+ }
+
+ #[cfg(never)]
+ #[task]
+ fn quux(_: quux::Context) {}
+
+ extern "C" {
+ fn UART0();
+ fn UART1();
+ }
+};
diff --git a/examples/t-late-not-send.rs b/examples/t-late-not-send.rs
new file mode 100644
index 00000000..55a053df
--- /dev/null
+++ b/examples/t-late-not-send.rs
@@ -0,0 +1,36 @@
+//! [compile-pass] late resources don't need to be `Send` if they are owned by `idle`
+
+#![no_main]
+#![no_std]
+
+use core::marker::PhantomData;
+
+use panic_halt as _;
+
+pub struct NotSend {
+ _0: PhantomData<*const ()>,
+}
+
+#[rtfm::app(device = lm3s6965)]
+const APP: () = {
+ extern "C" {
+ static mut X: NotSend;
+ }
+
+ static mut Y: Option<NotSend> = None;
+
+ #[init(resources = [Y])]
+ fn init(c: init::Context) -> init::LateResources {
+ // equivalent to late resource initialization
+ *c.resources.Y = Some(NotSend { _0: PhantomData });
+
+ init::LateResources {
+ X: NotSend { _0: PhantomData },
+ }
+ }
+
+ #[idle(resources = [X, Y])]
+ fn idle(_: idle::Context) -> ! {
+ loop {}
+ }
+};
diff --git a/examples/t-resource.rs b/examples/t-resource.rs
new file mode 100644
index 00000000..40dc2a65
--- /dev/null
+++ b/examples/t-resource.rs
@@ -0,0 +1,77 @@
+//! [compile-pass] Check code generation of resources
+
+#![deny(unsafe_code)]
+#![deny(warnings)]
+#![no_main]
+#![no_std]
+
+use panic_halt as _;
+
+#[rtfm::app(device = lm3s6965)]
+const APP: () = {
+ static mut O1: u32 = 0; // init
+ static mut O2: u32 = 0; // idle
+ static mut O3: u32 = 0; // EXTI0
+ static O4: u32 = 0; // idle
+ static O5: u32 = 0; // EXTI1
+ static O6: u32 = 0; // init
+
+ static mut S1: u32 = 0; // idle & EXTI0
+ static mut S2: u32 = 0; // EXTI0 & EXTI1
+ static S3: u32 = 0;
+
+ #[init(resources = [O1, O4, O5, O6, S3])]
+ fn init(c: init::Context) {
+ // owned by `init` == `&'static mut`
+ let _: &'static mut u32 = c.resources.O1;
+
+ // owned by `init` == `&'static` if read-only
+ let _: &'static u32 = c.resources.O6;
+
+ // `init` has exclusive access to all resources
+ let _: &mut u32 = c.resources.O4;
+ let _: &mut u32 = c.resources.O5;
+ let _: &mut u32 = c.resources.S3;
+ }
+
+ #[idle(resources = [O2, O4, S1, S3])]
+ fn idle(mut c: idle::Context) -> ! {
+ // owned by `idle` == `&'static mut`
+ let _: &'static mut u32 = c.resources.O2;
+
+ // owned by `idle` == `&'static` if read-only
+ let _: &'static u32 = c.resources.O4;
+
+ // shared with `idle` == `Mutex`
+ c.resources.S1.lock(|_| {});
+
+ // `&` if read-only
+ let _: &u32 = c.resources.S3;
+
+ loop {}
+ }
+
+ #[interrupt(resources = [O3, S1, S2, S3])]
+ fn UART0(c: UART0::Context) {
+ // owned by interrupt == `&mut`
+ let _: &mut u32 = c.resources.O3;
+
+ // no `Mutex` proxy when access from highest priority task
+ let _: &mut u32 = c.resources.S1;
+
+ // no `Mutex` proxy when co-owned by cooperative (same priority) tasks
+ let _: &mut u32 = c.resources.S2;
+
+ // `&` if read-only
+ let _: &u32 = c.resources.S3;
+ }
+
+ #[interrupt(resources = [S2, O5])]
+ fn UART1(c: UART1::Context) {
+ // owned by interrupt == `&` if read-only
+ let _: &u32 = c.resources.O5;
+
+ // no `Mutex` proxy when co-owned by cooperative (same priority) tasks
+ let _: &mut u32 = c.resources.S2;
+ }
+};
diff --git a/examples/t-schedule.rs b/examples/t-schedule.rs
new file mode 100644
index 00000000..67ff358b
--- /dev/null
+++ b/examples/t-schedule.rs
@@ -0,0 +1,59 @@
+//! [compile-pass] Check `schedule` code generation
+
+#![deny(unsafe_code)]
+#![deny(warnings)]
+#![no_main]
+#![no_std]
+
+use panic_halt as _;
+use rtfm::cyccnt::{Instant, U32Ext as _};
+
+#[rtfm::app(device = lm3s6965, monotonic = rtfm::cyccnt::CYCCNT)]
+const APP: () = {
+ #[init(schedule = [foo, bar, baz])]
+ fn init(c: init::Context) {
+ 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);
+ }
+
+ #[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);
+
+ loop {}
+ }
+
+ #[exception(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) {
+ 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);
+ }
+
+ #[task(schedule = [foo, bar, baz])]
+ 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);
+ }
+
+ #[task]
+ fn bar(_: bar::Context, _x: u32) {}
+
+ #[task]
+ fn baz(_: baz::Context, _x: u32, _y: u32) {}
+
+ extern "C" {
+ fn UART1();
+ }
+};
diff --git a/examples/t-spawn.rs b/examples/t-spawn.rs
new file mode 100644
index 00000000..6bb9b31f
--- /dev/null
+++ b/examples/t-spawn.rs
@@ -0,0 +1,58 @@
+//! [compile-pass] Check code generation of `spawn`
+
+#![deny(unsafe_code)]
+#![deny(warnings)]
+#![no_main]
+#![no_std]
+
+use panic_halt as _;
+
+#[rtfm::app(device = lm3s6965)]
+const APP: () = {
+ #[init(spawn = [foo, bar, baz])]
+ fn init(c: init::Context) {
+ let _: Result<(), ()> = c.spawn.foo();
+ let _: Result<(), u32> = c.spawn.bar(0);
+ let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
+ }
+
+ #[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);
+
+ loop {}
+ }
+
+ #[exception(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) {
+ let _: Result<(), ()> = c.spawn.foo();
+ let _: Result<(), u32> = c.spawn.bar(0);
+ let _: Result<(), (u32, u32)> = c.spawn.baz(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 bar(_: bar::Context, _x: u32) {}
+
+ #[task]
+ fn baz(_: baz::Context, _x: u32, _y: u32) {}
+
+ extern "C" {
+ fn UART1();
+ }
+};
diff --git a/examples/task.rs b/examples/task.rs
index 5bb32acb..43f7e569 100644
--- a/examples/task.rs
+++ b/examples/task.rs
@@ -5,9 +5,8 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::{debug, hprintln};
+use panic_semihosting as _;
#[rtfm::app(device = lm3s6965)]
const APP: () = {
diff --git a/examples/types.rs b/examples/types.rs
index c3dd89ca..2e72f0a0 100644
--- a/examples/types.rs
+++ b/examples/types.rs
@@ -5,12 +5,11 @@
#![no_main]
#![no_std]
-extern crate panic_semihosting;
-
use cortex_m_semihosting::debug;
-use rtfm::{Exclusive, Instant};
+use panic_semihosting as _;
+use rtfm::cyccnt::Instant;
-#[rtfm::app(device = lm3s6965)]
+#[rtfm::app(device = lm3s6965, peripherals = true, monotonic = rtfm::cyccnt::CYCCNT)]
const APP: () = {
static mut SHARED: u32 = 0;
@@ -43,7 +42,7 @@ const APP: () = {
#[task(priority = 2, resources = [SHARED], schedule = [foo], spawn = [foo])]
fn foo(c: foo::Context) {
let _: Instant = c.scheduled;
- let _: Exclusive<u32> = c.resources.SHARED;
+ let _: &mut u32 = c.resources.SHARED;
let _: foo::Resources = c.resources;
let _: foo::Schedule = c.schedule;
let _: foo::Spawn = c.spawn;