mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-17 21:35:20 +01:00
Fixing examples and tests, modules now import user imports correctly
Fmt Correct syntax crate UI test fix Fix build script Cleanup More cleanup
This commit is contained in:
parent
524273c96a
commit
5b8e6a22ab
28 changed files with 147 additions and 245 deletions
|
|
@ -12,19 +12,19 @@ use panic_semihosting as _;
|
|||
// NOTE: does NOT properly work on QEMU
|
||||
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
||||
mod app {
|
||||
#[init(spawn = [foo])]
|
||||
#[init]
|
||||
fn init(cx: init::Context) -> init::LateResources {
|
||||
// omitted: initialization of `CYCCNT`
|
||||
|
||||
hprintln!("init(baseline = {:?})", cx.start).unwrap();
|
||||
|
||||
// `foo` inherits the baseline of `init`: `Instant(0)`
|
||||
cx.spawn.foo().unwrap();
|
||||
foo::spawn().unwrap();
|
||||
|
||||
init::LateResources {}
|
||||
}
|
||||
|
||||
#[task(schedule = [foo])]
|
||||
#[task]
|
||||
fn foo(cx: foo::Context) {
|
||||
static mut ONCE: bool = true;
|
||||
|
||||
|
|
@ -39,12 +39,12 @@ mod app {
|
|||
}
|
||||
}
|
||||
|
||||
#[task(binds = UART0, spawn = [foo])]
|
||||
#[task(binds = UART0)]
|
||||
fn uart0(cx: uart0::Context) {
|
||||
hprintln!("UART0(baseline = {:?})", cx.start).unwrap();
|
||||
|
||||
// `foo` inherits the baseline of `UART0`: its `start` time
|
||||
cx.spawn.foo().unwrap();
|
||||
foo::spawn().unwrap();
|
||||
}
|
||||
|
||||
// RTIC requires that unused interrupts are declared in an extern block when
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ mod app {
|
|||
init::LateResources {}
|
||||
}
|
||||
|
||||
#[task(binds = UART0, spawn = [foo, bar])]
|
||||
fn uart0(c: uart0::Context) {
|
||||
c.spawn.foo(0).unwrap();
|
||||
c.spawn.foo(1).unwrap();
|
||||
c.spawn.foo(2).unwrap();
|
||||
c.spawn.foo(3).unwrap();
|
||||
#[task(binds = UART0)]
|
||||
fn uart0(_: uart0::Context) {
|
||||
foo::spawn(0).unwrap();
|
||||
foo::spawn(1).unwrap();
|
||||
foo::spawn(2).unwrap();
|
||||
foo::spawn(3).unwrap();
|
||||
|
||||
c.spawn.bar().unwrap();
|
||||
bar::spawn().unwrap();
|
||||
}
|
||||
|
||||
#[task(capacity = 4)]
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ mod app {
|
|||
count: u32,
|
||||
}
|
||||
|
||||
#[init(spawn = [foo])]
|
||||
fn init(cx: init::Context) -> init::LateResources {
|
||||
cx.spawn.foo().unwrap();
|
||||
cx.spawn.foo().unwrap();
|
||||
#[init]
|
||||
fn init(_: init::Context) -> init::LateResources {
|
||||
foo::spawn().unwrap();
|
||||
foo::spawn().unwrap();
|
||||
|
||||
init::LateResources {}
|
||||
}
|
||||
|
|
@ -36,13 +36,13 @@ mod app {
|
|||
}
|
||||
}
|
||||
|
||||
#[task(capacity = 2, resources = [count], spawn = [log])]
|
||||
#[task(capacity = 2, resources = [count])]
|
||||
fn foo(_cx: foo::Context) {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
*_cx.resources.count += 1;
|
||||
|
||||
_cx.spawn.log(*_cx.resources.count).unwrap();
|
||||
log::spawn(*_cx.resources.count).unwrap();
|
||||
}
|
||||
|
||||
// this wouldn't compile in `release` mode
|
||||
|
|
|
|||
|
|
@ -16,21 +16,21 @@ mod app {
|
|||
nothing: (),
|
||||
}
|
||||
|
||||
#[init(spawn = [task1])]
|
||||
fn init(cx: init::Context) -> init::LateResources {
|
||||
cx.spawn.task1().ok();
|
||||
#[init]
|
||||
fn init(_: init::Context) -> init::LateResources {
|
||||
task1::spawn().ok();
|
||||
|
||||
init::LateResources { nothing: () }
|
||||
}
|
||||
|
||||
#[task(schedule = [task2])]
|
||||
#[task]
|
||||
fn task1(_cx: task1::Context) {
|
||||
_cx.schedule.task2(_cx.scheduled + 100.cycles()).ok();
|
||||
task2::schedule(_cx.scheduled + 100.cycles()).ok();
|
||||
}
|
||||
|
||||
#[task(schedule = [task1])]
|
||||
#[task]
|
||||
fn task2(_cx: task2::Context) {
|
||||
_cx.schedule.task1(_cx.scheduled + 100.cycles()).ok();
|
||||
task1::schedule(_cx.scheduled + 100.cycles()).ok();
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
|||
|
|
@ -10,39 +10,39 @@ use panic_semihosting as _;
|
|||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[init(spawn = [foo])]
|
||||
fn init(c: init::Context) -> init::LateResources {
|
||||
c.spawn.foo(/* no message */).unwrap();
|
||||
#[init]
|
||||
fn init(_: init::Context) -> init::LateResources {
|
||||
foo::spawn(/* no message */).unwrap();
|
||||
|
||||
init::LateResources {}
|
||||
}
|
||||
|
||||
#[task(spawn = [bar])]
|
||||
fn foo(c: foo::Context) {
|
||||
#[task]
|
||||
fn foo(_: foo::Context) {
|
||||
static mut COUNT: u32 = 0;
|
||||
|
||||
hprintln!("foo").unwrap();
|
||||
|
||||
c.spawn.bar(*COUNT).unwrap();
|
||||
bar::spawn(*COUNT).unwrap();
|
||||
*COUNT += 1;
|
||||
}
|
||||
|
||||
#[task(spawn = [baz])]
|
||||
fn bar(c: bar::Context, x: u32) {
|
||||
#[task]
|
||||
fn bar(_: bar::Context, x: u32) {
|
||||
hprintln!("bar({})", x).unwrap();
|
||||
|
||||
c.spawn.baz(x + 1, x + 2).unwrap();
|
||||
baz::spawn(x + 1, x + 2).unwrap();
|
||||
}
|
||||
|
||||
#[task(spawn = [foo])]
|
||||
fn baz(c: baz::Context, x: u32, y: u32) {
|
||||
#[task]
|
||||
fn baz(_: baz::Context, x: u32, y: u32) {
|
||||
hprintln!("baz({}, {})", x, y).unwrap();
|
||||
|
||||
if x + y > 4 {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
c.spawn.foo().unwrap();
|
||||
foo::spawn().unwrap();
|
||||
}
|
||||
|
||||
// RTIC requires that unused interrupts are declared in an extern block when
|
||||
|
|
|
|||
|
|
@ -1,68 +0,0 @@
|
|||
//! `examples/not-send.rs`
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use panic_halt as _;
|
||||
use rtic::app;
|
||||
|
||||
pub struct NotSend {
|
||||
_0: PhantomData<*const ()>,
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
mod app {
|
||||
use super::NotSend;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[init(None)]
|
||||
shared: Option<NotSend>,
|
||||
}
|
||||
|
||||
#[init(spawn = [baz, quux])]
|
||||
fn init(c: init::Context) -> init::LateResources {
|
||||
c.spawn.baz().unwrap();
|
||||
c.spawn.quux().unwrap();
|
||||
|
||||
init::LateResources {}
|
||||
}
|
||||
|
||||
#[task(spawn = [bar])]
|
||||
fn foo(c: foo::Context) {
|
||||
// scenario 1: message passed to task that runs at the same priority
|
||||
c.spawn.bar(NotSend { _0: PhantomData }).ok();
|
||||
}
|
||||
|
||||
#[task]
|
||||
fn bar(_: bar::Context, _x: NotSend) {
|
||||
// scenario 1
|
||||
}
|
||||
|
||||
#[task(priority = 2, resources = [shared])]
|
||||
fn baz(c: baz::Context) {
|
||||
// scenario 2: resource shared between tasks that run at the same priority
|
||||
*c.resources.shared = Some(NotSend { _0: PhantomData });
|
||||
}
|
||||
|
||||
#[task(priority = 2, resources = [shared])]
|
||||
fn quux(c: quux::Context) {
|
||||
// scenario 2
|
||||
let _not_send = c.resources.shared.take().unwrap();
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
// RTIC requires that unused interrupts are declared in an extern block when
|
||||
// using software tasks; these free interrupts will be used to dispatch the
|
||||
// software tasks.
|
||||
extern "C" {
|
||||
fn SSI0();
|
||||
fn QEI0();
|
||||
}
|
||||
}
|
||||
|
|
@ -15,21 +15,21 @@ const PERIOD: u32 = 8_000_000;
|
|||
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
||||
mod app {
|
||||
|
||||
#[init(schedule = [foo])]
|
||||
#[init]
|
||||
fn init(cx: init::Context) -> init::LateResources {
|
||||
// omitted: initialization of `CYCCNT`
|
||||
|
||||
cx.schedule.foo(cx.start + PERIOD.cycles()).unwrap();
|
||||
foo::schedule(cx.start + PERIOD.cycles()).unwrap();
|
||||
|
||||
init::LateResources {}
|
||||
}
|
||||
|
||||
#[task(schedule = [foo])]
|
||||
#[task]
|
||||
fn foo(cx: foo::Context) {
|
||||
let now = Instant::now();
|
||||
hprintln!("foo(scheduled = {:?}, now = {:?})", cx.scheduled, now).unwrap();
|
||||
|
||||
cx.schedule.foo(cx.scheduled + PERIOD.cycles()).unwrap();
|
||||
foo::schedule(cx.scheduled + PERIOD.cycles()).unwrap();
|
||||
}
|
||||
|
||||
// RTIC requires that unused interrupts are declared in an extern block when
|
||||
|
|
|
|||
|
|
@ -36,16 +36,16 @@ mod app {
|
|||
init::LateResources {}
|
||||
}
|
||||
|
||||
#[task(binds = I2C0, priority = 2, spawn = [foo, bar])]
|
||||
fn i2c0(c: i2c0::Context) {
|
||||
#[task(binds = I2C0, priority = 2)]
|
||||
fn i2c0(_: i2c0::Context) {
|
||||
// claim a memory block, leave it uninitialized and ..
|
||||
let x = P::alloc().unwrap().freeze();
|
||||
|
||||
// .. send it to the `foo` task
|
||||
c.spawn.foo(x).ok().unwrap();
|
||||
foo::spawn(x).ok().unwrap();
|
||||
|
||||
// send another block to the task `bar`
|
||||
c.spawn.bar(P::alloc().unwrap().freeze()).ok().unwrap();
|
||||
bar::spawn(P::alloc().unwrap().freeze()).ok().unwrap();
|
||||
}
|
||||
|
||||
#[task]
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ use panic_semihosting as _;
|
|||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[init(spawn = [bar])]
|
||||
fn init(c: init::Context) -> init::LateResources {
|
||||
c.spawn.bar().unwrap();
|
||||
#[init]
|
||||
fn init(_: init::Context) -> init::LateResources {
|
||||
foo::spawn().unwrap();
|
||||
|
||||
init::LateResources {}
|
||||
}
|
||||
|
|
@ -28,9 +28,9 @@ mod app {
|
|||
// run this task from RAM
|
||||
#[inline(never)]
|
||||
#[link_section = ".data.bar"]
|
||||
#[task(priority = 2, spawn = [foo])]
|
||||
fn bar(c: bar::Context) {
|
||||
c.spawn.foo().unwrap();
|
||||
#[task(priority = 2)]
|
||||
fn bar(_: bar::Context) {
|
||||
foo::spawn().unwrap();
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use panic_semihosting as _;
|
|||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[init(spawn = [foo])]
|
||||
#[init]
|
||||
fn init(_c: init::Context) -> init::LateResources {
|
||||
foo::spawn(1, 2).unwrap();
|
||||
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@ mod app {
|
|||
}
|
||||
}
|
||||
|
||||
#[task(resources = [foo], schedule = [quux], spawn = [quux])]
|
||||
#[task(resources = [foo])]
|
||||
fn foo(_: foo::Context) {
|
||||
#[cfg(never)]
|
||||
static mut BAR: u32 = 0;
|
||||
}
|
||||
|
||||
#[task(priority = 3, resources = [foo], schedule = [quux], spawn = [quux])]
|
||||
#[task(priority = 3, resources = [foo])]
|
||||
fn bar(_: bar::Context) {
|
||||
#[cfg(never)]
|
||||
static mut BAR: u32 = 0;
|
||||
|
|
|
|||
|
|
@ -10,45 +10,45 @@ use rtic::cyccnt::{Instant, U32Ext as _};
|
|||
|
||||
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
||||
mod app {
|
||||
#[init(schedule = [foo, bar, baz])]
|
||||
#[init]
|
||||
fn init(c: init::Context) -> init::LateResources {
|
||||
let _: Result<(), ()> = c.schedule.foo(c.start + 10.cycles());
|
||||
let _: Result<(), u32> = c.schedule.bar(c.start + 20.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 30.cycles(), 0, 1);
|
||||
let _: Result<(), ()> = foo::schedule(c.start + 10.cycles());
|
||||
let _: Result<(), u32> = bar::schedule(c.start + 20.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = baz::schedule(c.start + 30.cycles(), 0, 1);
|
||||
|
||||
init::LateResources {}
|
||||
}
|
||||
|
||||
#[idle(schedule = [foo, bar, baz])]
|
||||
fn idle(c: idle::Context) -> ! {
|
||||
let _: Result<(), ()> = c.schedule.foo(Instant::now() + 40.cycles());
|
||||
let _: Result<(), u32> = c.schedule.bar(Instant::now() + 50.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = c.schedule.baz(Instant::now() + 60.cycles(), 0, 1);
|
||||
#[idle]
|
||||
fn idle(_: idle::Context) -> ! {
|
||||
let _: Result<(), ()> = foo::schedule(Instant::now() + 40.cycles());
|
||||
let _: Result<(), u32> = bar::schedule(Instant::now() + 50.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = baz::schedule(Instant::now() + 60.cycles(), 0, 1);
|
||||
|
||||
loop {
|
||||
cortex_m::asm::nop();
|
||||
}
|
||||
}
|
||||
|
||||
#[task(binds = SVCall, schedule = [foo, bar, baz])]
|
||||
#[task(binds = SVCall)]
|
||||
fn svcall(c: svcall::Context) {
|
||||
let _: Result<(), ()> = c.schedule.foo(c.start + 70.cycles());
|
||||
let _: Result<(), u32> = c.schedule.bar(c.start + 80.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 90.cycles(), 0, 1);
|
||||
let _: Result<(), ()> = foo::schedule(c.start + 70.cycles());
|
||||
let _: Result<(), u32> = bar::schedule(c.start + 80.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = baz::schedule(c.start + 90.cycles(), 0, 1);
|
||||
}
|
||||
|
||||
#[task(binds = UART0, schedule = [foo, bar, baz])]
|
||||
#[task(binds = UART0)]
|
||||
fn uart0(c: uart0::Context) {
|
||||
let _: Result<(), ()> = c.schedule.foo(c.start + 100.cycles());
|
||||
let _: Result<(), u32> = c.schedule.bar(c.start + 110.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 120.cycles(), 0, 1);
|
||||
let _: Result<(), ()> = foo::schedule(c.start + 100.cycles());
|
||||
let _: Result<(), u32> = bar::schedule(c.start + 110.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = baz::schedule(c.start + 120.cycles(), 0, 1);
|
||||
}
|
||||
|
||||
#[task(schedule = [foo, bar, baz])]
|
||||
#[task]
|
||||
fn foo(c: foo::Context) {
|
||||
let _: Result<(), ()> = c.schedule.foo(c.scheduled + 130.cycles());
|
||||
let _: Result<(), u32> = c.schedule.bar(c.scheduled + 140.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = c.schedule.baz(c.scheduled + 150.cycles(), 0, 1);
|
||||
let _: Result<(), ()> = foo::schedule(c.scheduled + 130.cycles());
|
||||
let _: Result<(), u32> = bar::schedule(c.scheduled + 140.cycles(), 0);
|
||||
let _: Result<(), (u32, u32)> = baz::schedule(c.scheduled + 150.cycles(), 0, 1);
|
||||
}
|
||||
|
||||
#[task]
|
||||
|
|
|
|||
|
|
@ -9,45 +9,45 @@ use panic_halt as _;
|
|||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[init(spawn = [foo, bar, baz])]
|
||||
fn init(c: init::Context) -> init::LateResources {
|
||||
let _: Result<(), ()> = c.spawn.foo();
|
||||
let _: Result<(), u32> = c.spawn.bar(0);
|
||||
let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
|
||||
#[init]
|
||||
fn init(_: init::Context) -> init::LateResources {
|
||||
let _: Result<(), ()> = foo::spawn();
|
||||
let _: Result<(), u32> = bar::spawn(0);
|
||||
let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
|
||||
|
||||
init::LateResources {}
|
||||
}
|
||||
|
||||
#[idle(spawn = [foo, bar, baz])]
|
||||
fn idle(c: idle::Context) -> ! {
|
||||
let _: Result<(), ()> = c.spawn.foo();
|
||||
let _: Result<(), u32> = c.spawn.bar(0);
|
||||
let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
|
||||
#[idle]
|
||||
fn idle(_: idle::Context) -> ! {
|
||||
let _: Result<(), ()> = foo::spawn();
|
||||
let _: Result<(), u32> = bar::spawn(0);
|
||||
let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
|
||||
|
||||
loop {
|
||||
cortex_m::asm::nop();
|
||||
}
|
||||
}
|
||||
|
||||
#[task(binds = SVCall, spawn = [foo, bar, baz])]
|
||||
fn svcall(c: svcall::Context) {
|
||||
let _: Result<(), ()> = c.spawn.foo();
|
||||
let _: Result<(), u32> = c.spawn.bar(0);
|
||||
let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
|
||||
#[task(binds = SVCall)]
|
||||
fn svcall(_: svcall::Context) {
|
||||
let _: Result<(), ()> = foo::spawn();
|
||||
let _: Result<(), u32> = bar::spawn(0);
|
||||
let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
|
||||
}
|
||||
|
||||
#[task(binds = UART0, spawn = [foo, bar, baz])]
|
||||
fn uart0(c: uart0::Context) {
|
||||
let _: Result<(), ()> = c.spawn.foo();
|
||||
let _: Result<(), u32> = c.spawn.bar(0);
|
||||
let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
|
||||
#[task(binds = UART0)]
|
||||
fn uart0(_: uart0::Context) {
|
||||
let _: Result<(), ()> = foo::spawn();
|
||||
let _: Result<(), u32> = bar::spawn(0);
|
||||
let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
|
||||
}
|
||||
|
||||
#[task(spawn = [foo, bar, baz])]
|
||||
fn foo(c: foo::Context) {
|
||||
let _: Result<(), ()> = c.spawn.foo();
|
||||
let _: Result<(), u32> = c.spawn.bar(0);
|
||||
let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1);
|
||||
#[task]
|
||||
fn foo(_: foo::Context) {
|
||||
let _: Result<(), ()> = foo::spawn();
|
||||
let _: Result<(), u32> = bar::spawn(0);
|
||||
let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
|
||||
}
|
||||
|
||||
#[task]
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ use panic_semihosting as _;
|
|||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[init(spawn = [taskmain])]
|
||||
fn init(cx: init::Context) -> init::LateResources {
|
||||
cx.spawn.taskmain().ok();
|
||||
#[init]
|
||||
fn init(_: init::Context) -> init::LateResources {
|
||||
taskmain::spawn().ok();
|
||||
|
||||
init::LateResources {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,27 +10,27 @@ use panic_semihosting as _;
|
|||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[init(spawn = [foo])]
|
||||
fn init(c: init::Context) -> init::LateResources {
|
||||
c.spawn.foo().unwrap();
|
||||
#[init]
|
||||
fn init(_: init::Context) -> init::LateResources {
|
||||
foo::spawn().unwrap();
|
||||
|
||||
init::LateResources {}
|
||||
}
|
||||
|
||||
#[task(spawn = [bar, baz])]
|
||||
fn foo(c: foo::Context) {
|
||||
#[task]
|
||||
fn foo(_: foo::Context) {
|
||||
hprintln!("foo - start").unwrap();
|
||||
|
||||
// spawns `bar` onto the task scheduler
|
||||
// `foo` and `bar` have the same priority so `bar` will not run until
|
||||
// after `foo` terminates
|
||||
c.spawn.bar().unwrap();
|
||||
bar::spawn().unwrap();
|
||||
|
||||
hprintln!("foo - middle").unwrap();
|
||||
|
||||
// spawns `baz` onto the task scheduler
|
||||
// `baz` has higher priority than `foo` so it immediately preempts `foo`
|
||||
c.spawn.baz().unwrap();
|
||||
baz::spawn().unwrap();
|
||||
|
||||
hprintln!("foo - end").unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,44 +17,35 @@ mod app {
|
|||
shared: u32,
|
||||
}
|
||||
|
||||
#[init(schedule = [foo], spawn = [foo])]
|
||||
#[init]
|
||||
fn init(cx: init::Context) -> init::LateResources {
|
||||
let _: cyccnt::Instant = cx.start;
|
||||
let _: rtic::Peripherals = cx.core;
|
||||
let _: lm3s6965::Peripherals = cx.device;
|
||||
let _: init::Schedule = cx.schedule;
|
||||
let _: init::Spawn = cx.spawn;
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
|
||||
init::LateResources {}
|
||||
}
|
||||
|
||||
#[idle(schedule = [foo], spawn = [foo])]
|
||||
fn idle(cx: idle::Context) -> ! {
|
||||
let _: idle::Schedule = cx.schedule;
|
||||
let _: idle::Spawn = cx.spawn;
|
||||
|
||||
#[idle]
|
||||
fn idle(_: idle::Context) -> ! {
|
||||
loop {
|
||||
cortex_m::asm::nop();
|
||||
}
|
||||
}
|
||||
|
||||
#[task(binds = UART0, resources = [shared], schedule = [foo], spawn = [foo])]
|
||||
#[task(binds = UART0, resources = [shared])]
|
||||
fn uart0(cx: uart0::Context) {
|
||||
let _: cyccnt::Instant = cx.start;
|
||||
let _: resources::shared = cx.resources.shared;
|
||||
let _: uart0::Schedule = cx.schedule;
|
||||
let _: uart0::Spawn = cx.spawn;
|
||||
}
|
||||
|
||||
#[task(priority = 2, resources = [shared], schedule = [foo], spawn = [foo])]
|
||||
#[task(priority = 2, resources = [shared])]
|
||||
fn foo(cx: foo::Context) {
|
||||
let _: cyccnt::Instant = cx.scheduled;
|
||||
let _: &mut u32 = cx.resources.shared;
|
||||
let _: foo::Resources = cx.resources;
|
||||
let _: foo::Schedule = cx.schedule;
|
||||
let _: foo::Spawn = cx.spawn;
|
||||
}
|
||||
|
||||
// RTIC requires that unused interrupts are declared in an extern block when
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue