mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-12-01 16:04:33 +01:00
update examples
This commit is contained in:
parent
a452700628
commit
1b4b006bab
23 changed files with 159 additions and 235 deletions
|
@ -9,24 +9,23 @@ extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
use lm3s6965::Interrupt;
|
use lm3s6965::Interrupt;
|
||||||
use rtfm::app;
|
|
||||||
|
|
||||||
// NOTE: does NOT properly work on QEMU
|
// NOTE: does NOT properly work on QEMU
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init(spawn = [foo])]
|
#[init(spawn = [foo])]
|
||||||
fn init() {
|
fn init(c: init::Context) {
|
||||||
hprintln!("init(baseline = {:?})", start).unwrap();
|
hprintln!("init(baseline = {:?})", c.start).unwrap();
|
||||||
|
|
||||||
// `foo` inherits the baseline of `init`: `Instant(0)`
|
// `foo` inherits the baseline of `init`: `Instant(0)`
|
||||||
spawn.foo().unwrap();
|
c.spawn.foo().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(schedule = [foo])]
|
#[task(schedule = [foo])]
|
||||||
fn foo() {
|
fn foo(c: foo::Context) {
|
||||||
static mut ONCE: bool = true;
|
static mut ONCE: bool = true;
|
||||||
|
|
||||||
hprintln!("foo(baseline = {:?})", scheduled).unwrap();
|
hprintln!("foo(baseline = {:?})", c.scheduled).unwrap();
|
||||||
|
|
||||||
if *ONCE {
|
if *ONCE {
|
||||||
*ONCE = false;
|
*ONCE = false;
|
||||||
|
@ -38,11 +37,11 @@ const APP: () = {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt(spawn = [foo])]
|
#[interrupt(spawn = [foo])]
|
||||||
fn UART0() {
|
fn UART0(c: UART0::Context) {
|
||||||
hprintln!("UART0(baseline = {:?})", start).unwrap();
|
hprintln!("UART0(baseline = {:?})", c.start).unwrap();
|
||||||
|
|
||||||
// `foo` inherits the baseline of `UART0`: its `start` time
|
// `foo` inherits the baseline of `UART0`: its `start` time
|
||||||
spawn.foo().unwrap();
|
c.spawn.foo().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -9,20 +9,19 @@ extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
use lm3s6965::Interrupt;
|
use lm3s6965::Interrupt;
|
||||||
use rtfm::app;
|
|
||||||
|
|
||||||
// `examples/interrupt.rs` rewritten to use `binds`
|
// `examples/interrupt.rs` rewritten to use `binds`
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init]
|
#[init]
|
||||||
fn init() {
|
fn init(_: init::Context) {
|
||||||
rtfm::pend(Interrupt::UART0);
|
rtfm::pend(Interrupt::UART0);
|
||||||
|
|
||||||
hprintln!("init").unwrap();
|
hprintln!("init").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[idle]
|
#[idle]
|
||||||
fn idle() -> ! {
|
fn idle(_: idle::Context) -> ! {
|
||||||
hprintln!("idle").unwrap();
|
hprintln!("idle").unwrap();
|
||||||
|
|
||||||
rtfm::pend(Interrupt::UART0);
|
rtfm::pend(Interrupt::UART0);
|
||||||
|
@ -33,7 +32,7 @@ const APP: () = {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt(binds = UART0)]
|
#[interrupt(binds = UART0)]
|
||||||
fn foo() {
|
fn foo(_: foo::Context) {
|
||||||
static mut TIMES: u32 = 0;
|
static mut TIMES: u32 = 0;
|
||||||
|
|
||||||
*TIMES += 1;
|
*TIMES += 1;
|
||||||
|
|
|
@ -9,32 +9,31 @@ extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
use lm3s6965::Interrupt;
|
use lm3s6965::Interrupt;
|
||||||
use rtfm::app;
|
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init]
|
#[init]
|
||||||
fn init() {
|
fn init(_: init::Context) {
|
||||||
rtfm::pend(Interrupt::UART0);
|
rtfm::pend(Interrupt::UART0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt(spawn = [foo, bar])]
|
#[interrupt(spawn = [foo, bar])]
|
||||||
fn UART0() {
|
fn UART0(c: UART0::Context) {
|
||||||
spawn.foo(0).unwrap();
|
c.spawn.foo(0).unwrap();
|
||||||
spawn.foo(1).unwrap();
|
c.spawn.foo(1).unwrap();
|
||||||
spawn.foo(2).unwrap();
|
c.spawn.foo(2).unwrap();
|
||||||
spawn.foo(3).unwrap();
|
c.spawn.foo(3).unwrap();
|
||||||
|
|
||||||
spawn.bar().unwrap();
|
c.spawn.bar().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(capacity = 4)]
|
#[task(capacity = 4)]
|
||||||
fn foo(x: u32) {
|
fn foo(_: foo::Context, x: u32) {
|
||||||
hprintln!("foo({})", x).unwrap();
|
hprintln!("foo({})", x).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task]
|
#[task]
|
||||||
fn bar() {
|
fn bar(_: bar::Context) {
|
||||||
hprintln!("bar").unwrap();
|
hprintln!("bar").unwrap();
|
||||||
|
|
||||||
debug::exit(debug::EXIT_SUCCESS);
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
|
|
|
@ -9,25 +9,24 @@ extern crate panic_semihosting;
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
use cortex_m_semihosting::hprintln;
|
use cortex_m_semihosting::hprintln;
|
||||||
use rtfm::app;
|
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[cfg(debug_assertions)] // <- `true` when using the `dev` profile
|
#[cfg(debug_assertions)] // <- `true` when using the `dev` profile
|
||||||
static mut COUNT: u32 = 0;
|
static mut COUNT: u32 = 0;
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init() {
|
fn init(_: init::Context) {
|
||||||
// ..
|
// ..
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(priority = 3, resources = [COUNT], spawn = [log])]
|
#[task(priority = 3, resources = [COUNT], spawn = [log])]
|
||||||
fn foo() {
|
fn foo(c: foo::Context) {
|
||||||
#[cfg(debug_assertions)]
|
#[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
|
// this wouldn't compile in `release` mode
|
||||||
|
@ -38,7 +37,7 @@ const APP: () = {
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
#[task]
|
#[task]
|
||||||
fn log(n: u32) {
|
fn log(_: log::Context, n: u32) {
|
||||||
hprintln!(
|
hprintln!(
|
||||||
"foo has been called {} time{}",
|
"foo has been called {} time{}",
|
||||||
n,
|
n,
|
||||||
|
|
|
@ -9,25 +9,25 @@ extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
use lm3s6965::Interrupt;
|
use lm3s6965::Interrupt;
|
||||||
use rtfm::{app, Mutex};
|
use rtfm::Mutex;
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
static mut SHARED: u32 = 0;
|
static mut SHARED: u32 = 0;
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init() {
|
fn init(_: init::Context) {
|
||||||
rtfm::pend(Interrupt::UART0);
|
rtfm::pend(Interrupt::UART0);
|
||||||
rtfm::pend(Interrupt::UART1);
|
rtfm::pend(Interrupt::UART1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt(resources = [SHARED])]
|
#[interrupt(resources = [SHARED])]
|
||||||
fn UART0() {
|
fn UART0(c: UART0::Context) {
|
||||||
static mut STATE: u32 = 0;
|
static mut STATE: u32 = 0;
|
||||||
|
|
||||||
hprintln!("UART0(STATE = {})", *STATE).unwrap();
|
hprintln!("UART0(STATE = {})", *STATE).unwrap();
|
||||||
|
|
||||||
advance(STATE, resources.SHARED);
|
advance(STATE, c.resources.SHARED);
|
||||||
|
|
||||||
rtfm::pend(Interrupt::UART1);
|
rtfm::pend(Interrupt::UART1);
|
||||||
|
|
||||||
|
@ -35,17 +35,17 @@ const APP: () = {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt(priority = 2, resources = [SHARED])]
|
#[interrupt(priority = 2, resources = [SHARED])]
|
||||||
fn UART1() {
|
fn UART1(mut c: UART1::Context) {
|
||||||
static mut STATE: u32 = 0;
|
static mut STATE: u32 = 0;
|
||||||
|
|
||||||
hprintln!("UART1(STATE = {})", *STATE).unwrap();
|
hprintln!("UART1(STATE = {})", *STATE).unwrap();
|
||||||
|
|
||||||
// just to show that `SHARED` can be accessed directly and ..
|
// just to show that `SHARED` can be accessed directly and ..
|
||||||
*resources.SHARED += 0;
|
*c.resources.SHARED += 0;
|
||||||
// .. also through a (no-op) `lock`
|
// .. 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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,17 +8,16 @@
|
||||||
extern crate panic_semihosting;
|
extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
use rtfm::app;
|
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init]
|
#[init]
|
||||||
fn init() {
|
fn init(_: init::Context) {
|
||||||
hprintln!("init").unwrap();
|
hprintln!("init").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[idle]
|
#[idle]
|
||||||
fn idle() -> ! {
|
fn idle(_: idle::Context) -> ! {
|
||||||
static mut X: u32 = 0;
|
static mut X: u32 = 0;
|
||||||
|
|
||||||
// Safe access to local `static mut` variable
|
// Safe access to local `static mut` variable
|
||||||
|
|
|
@ -8,19 +8,18 @@
|
||||||
extern crate panic_semihosting;
|
extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
use rtfm::app;
|
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init]
|
#[init]
|
||||||
fn init() {
|
fn init(c: init::Context) {
|
||||||
static mut X: u32 = 0;
|
static mut X: u32 = 0;
|
||||||
|
|
||||||
// Cortex-M peripherals
|
// Cortex-M peripherals
|
||||||
let _core: rtfm::Peripherals = core;
|
let _core: rtfm::Peripherals = c.core;
|
||||||
|
|
||||||
// Device specific peripherals
|
// Device specific peripherals
|
||||||
let _device: lm3s6965::Peripherals = device;
|
let _device: lm3s6965::Peripherals = c.device;
|
||||||
|
|
||||||
// Safe access to local `static mut` variable
|
// Safe access to local `static mut` variable
|
||||||
let _x: &'static mut u32 = X;
|
let _x: &'static mut u32 = X;
|
||||||
|
|
|
@ -9,12 +9,11 @@ extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
use lm3s6965::Interrupt;
|
use lm3s6965::Interrupt;
|
||||||
use rtfm::app;
|
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init]
|
#[init]
|
||||||
fn init() {
|
fn init(_: init::Context) {
|
||||||
// Pends the UART0 interrupt but its handler won't run until *after*
|
// Pends the UART0 interrupt but its handler won't run until *after*
|
||||||
// `init` returns because interrupts are disabled
|
// `init` returns because interrupts are disabled
|
||||||
rtfm::pend(Interrupt::UART0);
|
rtfm::pend(Interrupt::UART0);
|
||||||
|
@ -23,7 +22,7 @@ const APP: () = {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[idle]
|
#[idle]
|
||||||
fn idle() -> ! {
|
fn idle(_: idle::Context) -> ! {
|
||||||
// interrupts are enabled again; the `UART0` handler runs at this point
|
// interrupts are enabled again; the `UART0` handler runs at this point
|
||||||
|
|
||||||
hprintln!("idle").unwrap();
|
hprintln!("idle").unwrap();
|
||||||
|
@ -36,7 +35,7 @@ const APP: () = {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt]
|
#[interrupt]
|
||||||
fn UART0() {
|
fn UART0(_: UART0::Context) {
|
||||||
static mut TIMES: u32 = 0;
|
static mut TIMES: u32 = 0;
|
||||||
|
|
||||||
// Safe access to local `static mut` variable
|
// Safe access to local `static mut` variable
|
||||||
|
|
|
@ -13,16 +13,15 @@ use heapless::{
|
||||||
spsc::{Consumer, Producer, Queue},
|
spsc::{Consumer, Producer, Queue},
|
||||||
};
|
};
|
||||||
use lm3s6965::Interrupt;
|
use lm3s6965::Interrupt;
|
||||||
use rtfm::app;
|
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
// Late resources
|
// Late resources
|
||||||
static mut P: Producer<'static, u32, U4> = ();
|
static mut P: Producer<'static, u32, U4> = ();
|
||||||
static mut C: Consumer<'static, u32, U4> = ();
|
static mut C: Consumer<'static, u32, U4> = ();
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init() -> init::LateResources {
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
// NOTE: we use `Option` here to work around the lack of
|
// NOTE: we use `Option` here to work around the lack of
|
||||||
// a stable `const` constructor
|
// a stable `const` constructor
|
||||||
static mut Q: Option<Queue<u32, U4>> = None;
|
static mut Q: Option<Queue<u32, U4>> = None;
|
||||||
|
@ -35,9 +34,9 @@ const APP: () = {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[idle(resources = [C])]
|
#[idle(resources = [C])]
|
||||||
fn idle() -> ! {
|
fn idle(c: idle::Context) -> ! {
|
||||||
loop {
|
loop {
|
||||||
if let Some(byte) = resources.C.dequeue() {
|
if let Some(byte) = c.resources.C.dequeue() {
|
||||||
hprintln!("received message: {}", byte).unwrap();
|
hprintln!("received message: {}", byte).unwrap();
|
||||||
|
|
||||||
debug::exit(debug::EXIT_SUCCESS);
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
|
@ -48,7 +47,7 @@ const APP: () = {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt(resources = [P])]
|
#[interrupt(resources = [P])]
|
||||||
fn UART0() {
|
fn UART0(c: UART0::Context) {
|
||||||
resources.P.enqueue(42).unwrap();
|
c.resources.P.enqueue(42).unwrap();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,24 +9,23 @@ extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
use lm3s6965::Interrupt;
|
use lm3s6965::Interrupt;
|
||||||
use rtfm::app;
|
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
static mut SHARED: u32 = 0;
|
static mut SHARED: u32 = 0;
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init() {
|
fn init(_: init::Context) {
|
||||||
rtfm::pend(Interrupt::GPIOA);
|
rtfm::pend(Interrupt::GPIOA);
|
||||||
}
|
}
|
||||||
|
|
||||||
// when omitted priority is assumed to be `1`
|
// when omitted priority is assumed to be `1`
|
||||||
#[interrupt(resources = [SHARED])]
|
#[interrupt(resources = [SHARED])]
|
||||||
fn GPIOA() {
|
fn GPIOA(mut c: GPIOA::Context) {
|
||||||
hprintln!("A").unwrap();
|
hprintln!("A").unwrap();
|
||||||
|
|
||||||
// the lower priority task requires a critical section to access the data
|
// 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)
|
// data can only be modified within this critical section (closure)
|
||||||
*shared += 1;
|
*shared += 1;
|
||||||
|
|
||||||
|
@ -47,15 +46,15 @@ const APP: () = {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt(priority = 2, resources = [SHARED])]
|
#[interrupt(priority = 2, resources = [SHARED])]
|
||||||
fn GPIOB() {
|
fn GPIOB(mut c: GPIOB::Context) {
|
||||||
// the higher priority task does *not* need a critical section
|
// 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)]
|
#[interrupt(priority = 3)]
|
||||||
fn GPIOC() {
|
fn GPIOC(_: GPIOC::Context) {
|
||||||
hprintln!("C").unwrap();
|
hprintln!("C").unwrap();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,41 +8,40 @@
|
||||||
extern crate panic_semihosting;
|
extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
use rtfm::app;
|
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init(spawn = [foo])]
|
#[init(spawn = [foo])]
|
||||||
fn init() {
|
fn init(c: init::Context) {
|
||||||
spawn.foo(/* no message */).unwrap();
|
c.spawn.foo(/* no message */).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(spawn = [bar])]
|
#[task(spawn = [bar])]
|
||||||
fn foo() {
|
fn foo(c: foo::Context) {
|
||||||
static mut COUNT: u32 = 0;
|
static mut COUNT: u32 = 0;
|
||||||
|
|
||||||
hprintln!("foo").unwrap();
|
hprintln!("foo").unwrap();
|
||||||
|
|
||||||
spawn.bar(*COUNT).unwrap();
|
c.spawn.bar(*COUNT).unwrap();
|
||||||
*COUNT += 1;
|
*COUNT += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(spawn = [baz])]
|
#[task(spawn = [baz])]
|
||||||
fn bar(x: u32) {
|
fn bar(c: bar::Context, x: u32) {
|
||||||
hprintln!("bar({})", x).unwrap();
|
hprintln!("bar({})", x).unwrap();
|
||||||
|
|
||||||
spawn.baz(x + 1, x + 2).unwrap();
|
c.spawn.baz(x + 1, x + 2).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(spawn = [foo])]
|
#[task(spawn = [foo])]
|
||||||
fn baz(x: u32, y: u32) {
|
fn baz(c: baz::Context, x: u32, y: u32) {
|
||||||
hprintln!("baz({}, {})", x, y).unwrap();
|
hprintln!("baz({}, {})", x, y).unwrap();
|
||||||
|
|
||||||
if x + y > 4 {
|
if x + y > 4 {
|
||||||
debug::exit(debug::EXIT_SUCCESS);
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
spawn.foo().unwrap();
|
c.spawn.foo().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -21,32 +21,32 @@ const APP: () = {
|
||||||
static mut SHARED: Option<NotSend> = None;
|
static mut SHARED: Option<NotSend> = None;
|
||||||
|
|
||||||
#[init(spawn = [baz, quux])]
|
#[init(spawn = [baz, quux])]
|
||||||
fn init() {
|
fn init(c: init::Context) {
|
||||||
spawn.baz().unwrap();
|
c.spawn.baz().unwrap();
|
||||||
spawn.quux().unwrap();
|
c.spawn.quux().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(spawn = [bar])]
|
#[task(spawn = [bar])]
|
||||||
fn foo() {
|
fn foo(c: foo::Context) {
|
||||||
// scenario 1: message passed to task that runs at the same priority
|
// 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]
|
#[task]
|
||||||
fn bar(_x: NotSend) {
|
fn bar(_: bar::Context, _x: NotSend) {
|
||||||
// scenario 1
|
// scenario 1
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(priority = 2, resources = [SHARED])]
|
#[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
|
// 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])]
|
#[task(priority = 2, resources = [SHARED])]
|
||||||
fn quux() {
|
fn quux(mut c: quux::Context) {
|
||||||
// scenario 2
|
// scenario 2
|
||||||
let _not_send = resources.SHARED.take().unwrap();
|
let _not_send = c.resources.SHARED.take().unwrap();
|
||||||
|
|
||||||
debug::exit(debug::EXIT_SUCCESS);
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,29 +10,28 @@ extern crate panic_halt;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
use cortex_m_semihosting::debug;
|
use cortex_m_semihosting::debug;
|
||||||
use rtfm::app;
|
|
||||||
|
|
||||||
pub struct NotSync {
|
pub struct NotSync {
|
||||||
_0: PhantomData<*const ()>,
|
_0: PhantomData<*const ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
static SHARED: NotSync = NotSync { _0: PhantomData };
|
static SHARED: NotSync = NotSync { _0: PhantomData };
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init() {
|
fn init(_: init::Context) {
|
||||||
debug::exit(debug::EXIT_SUCCESS);
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(resources = [SHARED])]
|
#[task(resources = [SHARED])]
|
||||||
fn foo() {
|
fn foo(c: foo::Context) {
|
||||||
let _: &NotSync = resources.SHARED;
|
let _: &NotSync = c.resources.SHARED;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(resources = [SHARED])]
|
#[task(resources = [SHARED])]
|
||||||
fn bar() {
|
fn bar(c: bar::Context) {
|
||||||
let _: &NotSync = resources.SHARED;
|
let _: &NotSync = c.resources.SHARED;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -8,24 +8,24 @@
|
||||||
extern crate panic_semihosting;
|
extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::hprintln;
|
use cortex_m_semihosting::hprintln;
|
||||||
use rtfm::{app, Instant};
|
use rtfm::Instant;
|
||||||
|
|
||||||
const PERIOD: u32 = 8_000_000;
|
const PERIOD: u32 = 8_000_000;
|
||||||
|
|
||||||
// NOTE: does NOT work on QEMU!
|
// NOTE: does NOT work on QEMU!
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init(schedule = [foo])]
|
#[init(schedule = [foo])]
|
||||||
fn init() {
|
fn init(c: init::Context) {
|
||||||
schedule.foo(Instant::now() + PERIOD.cycles()).unwrap();
|
c.schedule.foo(Instant::now() + PERIOD.cycles()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(schedule = [foo])]
|
#[task(schedule = [foo])]
|
||||||
fn foo() {
|
fn foo(c: foo::Context) {
|
||||||
let now = Instant::now();
|
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" {
|
extern "C" {
|
||||||
|
|
|
@ -8,18 +8,17 @@
|
||||||
extern crate panic_semihosting;
|
extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
use rtfm::app;
|
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init(spawn = [bar])]
|
#[init(spawn = [bar])]
|
||||||
fn init() {
|
fn init(c: init::Context) {
|
||||||
spawn.bar().unwrap();
|
c.spawn.bar().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
#[task]
|
#[task]
|
||||||
fn foo() {
|
fn foo(_: foo::Context) {
|
||||||
hprintln!("foo").unwrap();
|
hprintln!("foo").unwrap();
|
||||||
|
|
||||||
debug::exit(debug::EXIT_SUCCESS);
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
|
@ -29,8 +28,8 @@ const APP: () = {
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
#[link_section = ".data.bar"]
|
#[link_section = ".data.bar"]
|
||||||
#[task(priority = 2, spawn = [foo])]
|
#[task(priority = 2, spawn = [foo])]
|
||||||
fn bar() {
|
fn bar(c: bar::Context) {
|
||||||
spawn.foo().unwrap();
|
c.spawn.foo().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -9,21 +9,20 @@ extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
use lm3s6965::Interrupt;
|
use lm3s6965::Interrupt;
|
||||||
use rtfm::app;
|
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
// A resource
|
// A resource
|
||||||
static mut SHARED: u32 = 0;
|
static mut SHARED: u32 = 0;
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init() {
|
fn init(_: init::Context) {
|
||||||
rtfm::pend(Interrupt::UART0);
|
rtfm::pend(Interrupt::UART0);
|
||||||
rtfm::pend(Interrupt::UART1);
|
rtfm::pend(Interrupt::UART1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[idle]
|
#[idle]
|
||||||
fn idle() -> ! {
|
fn idle(_: idle::Context) -> ! {
|
||||||
debug::exit(debug::EXIT_SUCCESS);
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
|
|
||||||
// error: `SHARED` can't be accessed from this context
|
// error: `SHARED` can't be accessed from this context
|
||||||
|
@ -34,17 +33,17 @@ const APP: () = {
|
||||||
|
|
||||||
// `SHARED` can be access from this context
|
// `SHARED` can be access from this context
|
||||||
#[interrupt(resources = [SHARED])]
|
#[interrupt(resources = [SHARED])]
|
||||||
fn UART0() {
|
fn UART0(mut c: UART0::Context) {
|
||||||
*resources.SHARED += 1;
|
*c.resources.SHARED += 1;
|
||||||
|
|
||||||
hprintln!("UART0: SHARED = {}", resources.SHARED).unwrap();
|
hprintln!("UART0: SHARED = {}", c.resources.SHARED).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// `SHARED` can be access from this context
|
// `SHARED` can be access from this context
|
||||||
#[interrupt(resources = [SHARED])]
|
#[interrupt(resources = [SHARED])]
|
||||||
fn UART1() {
|
fn UART1(mut c: UART1::Context) {
|
||||||
*resources.SHARED += 1;
|
*c.resources.SHARED += 1;
|
||||||
|
|
||||||
hprintln!("UART1: SHARED = {}", resources.SHARED).unwrap();
|
hprintln!("UART1: SHARED = {}", c.resources.SHARED).unwrap();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,31 +8,31 @@
|
||||||
extern crate panic_semihosting;
|
extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::hprintln;
|
use cortex_m_semihosting::hprintln;
|
||||||
use rtfm::{app, Instant};
|
use rtfm::Instant;
|
||||||
|
|
||||||
// NOTE: does NOT work on QEMU!
|
// NOTE: does NOT work on QEMU!
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init(schedule = [foo, bar])]
|
#[init(schedule = [foo, bar])]
|
||||||
fn init() {
|
fn init(c: init::Context) {
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
|
|
||||||
hprintln!("init @ {:?}", now).unwrap();
|
hprintln!("init @ {:?}", now).unwrap();
|
||||||
|
|
||||||
// Schedule `foo` to run 8e6 cycles (clock cycles) in the future
|
// 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` 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]
|
#[task]
|
||||||
fn foo() {
|
fn foo(_: foo::Context) {
|
||||||
hprintln!("foo @ {:?}", Instant::now()).unwrap();
|
hprintln!("foo @ {:?}", Instant::now()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task]
|
#[task]
|
||||||
fn bar() {
|
fn bar(_: bar::Context) {
|
||||||
hprintln!("bar @ {:?}", Instant::now()).unwrap();
|
hprintln!("bar @ {:?}", Instant::now()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,17 +18,17 @@ const APP: () = {
|
||||||
static mut SHARED: Option<MustBeSend> = None;
|
static mut SHARED: Option<MustBeSend> = None;
|
||||||
|
|
||||||
#[init(resources = [SHARED])]
|
#[init(resources = [SHARED])]
|
||||||
fn init() {
|
fn init(c: init::Context) {
|
||||||
// this `message` will be sent to task `UART0`
|
// this `message` will be sent to task `UART0`
|
||||||
let message = MustBeSend;
|
let message = MustBeSend;
|
||||||
*resources.SHARED = Some(message);
|
*c.resources.SHARED = Some(message);
|
||||||
|
|
||||||
rtfm::pend(Interrupt::UART0);
|
rtfm::pend(Interrupt::UART0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt(resources = [SHARED])]
|
#[interrupt(resources = [SHARED])]
|
||||||
fn UART0() {
|
fn UART0(c: UART0::Context) {
|
||||||
if let Some(message) = resources.SHARED.take() {
|
if let Some(message) = c.resources.SHARED.take() {
|
||||||
// `message` has been received
|
// `message` has been received
|
||||||
drop(message);
|
drop(message);
|
||||||
|
|
||||||
|
|
|
@ -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();
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -13,5 +13,5 @@ use rtfm::app;
|
||||||
#[app(device = lm3s6965)]
|
#[app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init]
|
#[init]
|
||||||
fn init() {}
|
fn init(_: init::Context) {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,14 +9,13 @@ extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
use lm3s6965::Interrupt;
|
use lm3s6965::Interrupt;
|
||||||
use rtfm::app;
|
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
static KEY: u32 = ();
|
static KEY: u32 = ();
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init() -> init::LateResources {
|
fn init(_: init::Context) -> init::LateResources {
|
||||||
rtfm::pend(Interrupt::UART0);
|
rtfm::pend(Interrupt::UART0);
|
||||||
rtfm::pend(Interrupt::UART1);
|
rtfm::pend(Interrupt::UART1);
|
||||||
|
|
||||||
|
@ -24,14 +23,14 @@ const APP: () = {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt(resources = [KEY])]
|
#[interrupt(resources = [KEY])]
|
||||||
fn UART0() {
|
fn UART0(c: UART0::Context) {
|
||||||
hprintln!("UART0(KEY = {:#x})", resources.KEY).unwrap();
|
hprintln!("UART0(KEY = {:#x})", c.resources.KEY).unwrap();
|
||||||
|
|
||||||
debug::exit(debug::EXIT_SUCCESS);
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt(priority = 2, resources = [KEY])]
|
#[interrupt(priority = 2, resources = [KEY])]
|
||||||
fn UART1() {
|
fn UART1(c: UART1::Context) {
|
||||||
hprintln!("UART1(KEY = {:#x})", resources.KEY).unwrap();
|
hprintln!("UART1(KEY = {:#x})", c.resources.KEY).unwrap();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,38 +8,37 @@
|
||||||
extern crate panic_semihosting;
|
extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::{debug, hprintln};
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
use rtfm::app;
|
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
#[init(spawn = [foo])]
|
#[init(spawn = [foo])]
|
||||||
fn init() {
|
fn init(c: init::Context) {
|
||||||
spawn.foo().unwrap();
|
c.spawn.foo().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(spawn = [bar, baz])]
|
#[task(spawn = [bar, baz])]
|
||||||
fn foo() {
|
fn foo(c: foo::Context) {
|
||||||
hprintln!("foo").unwrap();
|
hprintln!("foo").unwrap();
|
||||||
|
|
||||||
// spawns `bar` onto the task scheduler
|
// spawns `bar` onto the task scheduler
|
||||||
// `foo` and `bar` have the same priority so `bar` will not run until
|
// `foo` and `bar` have the same priority so `bar` will not run until
|
||||||
// after `foo` terminates
|
// after `foo` terminates
|
||||||
spawn.bar().unwrap();
|
c.spawn.bar().unwrap();
|
||||||
|
|
||||||
// spawns `baz` onto the task scheduler
|
// spawns `baz` onto the task scheduler
|
||||||
// `baz` has higher priority than `foo` so it immediately preempts `foo`
|
// `baz` has higher priority than `foo` so it immediately preempts `foo`
|
||||||
spawn.baz().unwrap();
|
c.spawn.baz().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task]
|
#[task]
|
||||||
fn bar() {
|
fn bar(_: bar::Context) {
|
||||||
hprintln!("bar").unwrap();
|
hprintln!("bar").unwrap();
|
||||||
|
|
||||||
debug::exit(debug::EXIT_SUCCESS);
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(priority = 2)]
|
#[task(priority = 2)]
|
||||||
fn baz() {
|
fn baz(_: baz::Context) {
|
||||||
hprintln!("baz").unwrap();
|
hprintln!("baz").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,45 +8,45 @@
|
||||||
extern crate panic_semihosting;
|
extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m_semihosting::debug;
|
use cortex_m_semihosting::debug;
|
||||||
use rtfm::{app, Exclusive, Instant};
|
use rtfm::{Exclusive, Instant};
|
||||||
|
|
||||||
#[app(device = lm3s6965)]
|
#[rtfm::app(device = lm3s6965)]
|
||||||
const APP: () = {
|
const APP: () = {
|
||||||
static mut SHARED: u32 = 0;
|
static mut SHARED: u32 = 0;
|
||||||
|
|
||||||
#[init(schedule = [foo], spawn = [foo])]
|
#[init(schedule = [foo], spawn = [foo])]
|
||||||
fn init() {
|
fn init(c: init::Context) {
|
||||||
let _: Instant = start;
|
let _: Instant = c.start;
|
||||||
let _: rtfm::Peripherals = core;
|
let _: rtfm::Peripherals = c.core;
|
||||||
let _: lm3s6965::Peripherals = device;
|
let _: lm3s6965::Peripherals = c.device;
|
||||||
let _: init::Schedule = schedule;
|
let _: init::Schedule = c.schedule;
|
||||||
let _: init::Spawn = spawn;
|
let _: init::Spawn = c.spawn;
|
||||||
|
|
||||||
debug::exit(debug::EXIT_SUCCESS);
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[exception(schedule = [foo], spawn = [foo])]
|
#[exception(schedule = [foo], spawn = [foo])]
|
||||||
fn SVCall() {
|
fn SVCall(c: SVCall::Context) {
|
||||||
let _: Instant = start;
|
let _: Instant = c.start;
|
||||||
let _: SVCall::Schedule = schedule;
|
let _: SVCall::Schedule = c.schedule;
|
||||||
let _: SVCall::Spawn = spawn;
|
let _: SVCall::Spawn = c.spawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[interrupt(resources = [SHARED], schedule = [foo], spawn = [foo])]
|
#[interrupt(resources = [SHARED], schedule = [foo], spawn = [foo])]
|
||||||
fn UART0() {
|
fn UART0(c: UART0::Context) {
|
||||||
let _: Instant = start;
|
let _: Instant = c.start;
|
||||||
let _: resources::SHARED = resources.SHARED;
|
let _: resources::SHARED = c.resources.SHARED;
|
||||||
let _: UART0::Schedule = schedule;
|
let _: UART0::Schedule = c.schedule;
|
||||||
let _: UART0::Spawn = spawn;
|
let _: UART0::Spawn = c.spawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(priority = 2, resources = [SHARED], schedule = [foo], spawn = [foo])]
|
#[task(priority = 2, resources = [SHARED], schedule = [foo], spawn = [foo])]
|
||||||
fn foo() {
|
fn foo(c: foo::Context) {
|
||||||
let _: Instant = scheduled;
|
let _: Instant = c.scheduled;
|
||||||
let _: Exclusive<u32> = resources.SHARED;
|
let _: Exclusive<u32> = c.resources.SHARED;
|
||||||
let _: foo::Resources = resources;
|
let _: foo::Resources = c.resources;
|
||||||
let _: foo::Schedule = schedule;
|
let _: foo::Schedule = c.schedule;
|
||||||
let _: foo::Spawn = spawn;
|
let _: foo::Spawn = c.spawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
Loading…
Reference in a new issue