mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-25 21:19:35 +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
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
|
@ -251,7 +251,6 @@ jobs:
|
|||
capacity
|
||||
|
||||
types
|
||||
not-send
|
||||
not-sync
|
||||
shared-with-init
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -21,5 +21,5 @@ proc-macro = true
|
|||
proc-macro2 = "1"
|
||||
quote = "1"
|
||||
syn = "1"
|
||||
rtic-syntax = { path = "../../rtic-syntax", version = "0.4.0" }
|
||||
rtic-syntax = { git = "https://github.com/rtic-rs/rtic-syntax", branch = "no_spawn_no_schedule", version = "0.4.0" }
|
||||
|
||||
|
|
|
@ -15,11 +15,7 @@ mod post_init;
|
|||
mod pre_init;
|
||||
mod resources;
|
||||
mod resources_struct;
|
||||
// mod schedule;
|
||||
// mod schedule_body;
|
||||
mod software_tasks;
|
||||
// mod spawn;
|
||||
// mod spawn_body;
|
||||
mod timer_queue;
|
||||
mod util;
|
||||
|
||||
|
@ -115,17 +111,12 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
|||
) = software_tasks::codegen(app, analysis, extra);
|
||||
|
||||
let mod_app_dispatchers = dispatchers::codegen(app, analysis, extra);
|
||||
|
||||
// let mod_app_spawn = spawn::codegen(app, analysis, extra);
|
||||
|
||||
let mod_app_timer_queue = timer_queue::codegen(app, analysis, extra);
|
||||
|
||||
// let mod_app_schedule = schedule::codegen(app, extra);
|
||||
|
||||
let user_imports = app.user_imports.clone();
|
||||
let user_code = app.user_code.clone();
|
||||
let user_imports = &app.user_imports;
|
||||
let user_code = &app.user_code;
|
||||
let name = &app.name;
|
||||
let device = extra.device;
|
||||
|
||||
quote!(
|
||||
#(#user)*
|
||||
|
||||
|
@ -170,12 +161,8 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
|||
|
||||
#(#mod_app_dispatchers)*
|
||||
|
||||
// #(#mod_app_spawn)*
|
||||
|
||||
#(#mod_app_timer_queue)*
|
||||
|
||||
// #(#mod_app_schedule)*
|
||||
|
||||
#(#mains)*
|
||||
}
|
||||
)
|
||||
|
|
|
@ -32,9 +32,7 @@ pub fn codegen(
|
|||
let mut hardware_tasks_imports = vec![];
|
||||
|
||||
for (name, task) in &app.hardware_tasks {
|
||||
let (let_instant, instant) = if extra.monotonic.is_some() {
|
||||
let m = extra.monotonic();
|
||||
|
||||
let (let_instant, instant) = if let Some(m) = extra.monotonic {
|
||||
(
|
||||
Some(quote!(let instant = <#m as rtic::Monotonic>::now();)),
|
||||
Some(quote!(, instant)),
|
||||
|
|
|
@ -62,8 +62,13 @@ pub fn codegen(
|
|||
root_idle.push(locals);
|
||||
}
|
||||
|
||||
root_idle.push(module::codegen(Context::Idle, needs_lt, app,analysis, extra));
|
||||
|
||||
root_idle.push(module::codegen(
|
||||
Context::Idle,
|
||||
needs_lt,
|
||||
app,
|
||||
analysis,
|
||||
extra,
|
||||
));
|
||||
|
||||
let attrs = &idle.attrs;
|
||||
let context = &idle.context;
|
||||
|
|
|
@ -21,9 +21,7 @@ pub fn codegen(
|
|||
let mut lt = None;
|
||||
match ctxt {
|
||||
Context::Init => {
|
||||
if extra.monotonic.is_some() {
|
||||
let m = extra.monotonic();
|
||||
|
||||
if let Some(m) = extra.monotonic {
|
||||
fields.push(quote!(
|
||||
/// System start time = `Instant(0 /* cycles */)`
|
||||
pub start: <#m as rtic::Monotonic>::Instant
|
||||
|
@ -67,9 +65,7 @@ pub fn codegen(
|
|||
Context::Idle => {}
|
||||
|
||||
Context::HardwareTask(..) => {
|
||||
if extra.monotonic.is_some() {
|
||||
let m = extra.monotonic();
|
||||
|
||||
if let Some(m) = extra.monotonic {
|
||||
fields.push(quote!(
|
||||
/// Time at which this handler started executing
|
||||
pub start: <#m as rtic::Monotonic>::Instant
|
||||
|
@ -82,9 +78,7 @@ pub fn codegen(
|
|||
}
|
||||
|
||||
Context::SoftwareTask(..) => {
|
||||
if extra.monotonic.is_some() {
|
||||
let m = extra.monotonic();
|
||||
|
||||
if let Some(m) = extra.monotonic {
|
||||
fields.push(quote!(
|
||||
/// The time at which this task was scheduled to run
|
||||
pub scheduled: <#m as rtic::Monotonic>::Instant
|
||||
|
@ -242,11 +236,10 @@ pub fn codegen(
|
|||
}));
|
||||
|
||||
// Schedule caller
|
||||
if extra.monotonic.is_some() {
|
||||
if let Some(m) = extra.monotonic {
|
||||
let instants = util::instants_ident(name);
|
||||
|
||||
let tq = util::tq_ident();
|
||||
let m = extra.monotonic();
|
||||
let t = util::schedule_t_ident();
|
||||
|
||||
items.push(quote!(
|
||||
|
@ -288,10 +281,16 @@ pub fn codegen(
|
|||
}
|
||||
|
||||
if !items.is_empty() {
|
||||
let user_imports = &app.user_imports;
|
||||
|
||||
quote!(
|
||||
#[allow(non_snake_case)]
|
||||
#[doc = #doc]
|
||||
pub mod #name {
|
||||
#(
|
||||
#[allow(unused_imports)]
|
||||
#user_imports
|
||||
)*
|
||||
#(#items)*
|
||||
}
|
||||
)
|
||||
|
|
|
@ -12,12 +12,8 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
|||
stmts.push(quote!(rtic::export::interrupt::disable();));
|
||||
|
||||
// Populate the FreeQueue
|
||||
for fq in &app.software_tasks {
|
||||
// Get the task name
|
||||
let name = fq.0;
|
||||
let task = fq.1;
|
||||
for (name, task) in &app.software_tasks {
|
||||
let cap = task.args.capacity;
|
||||
|
||||
let fq_ident = util::fq_ident(name);
|
||||
|
||||
stmts.push(quote!(
|
||||
|
|
|
@ -60,8 +60,7 @@ pub fn codegen(
|
|||
.map(|_| quote!(core::mem::MaybeUninit::uninit()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if extra.monotonic.is_some() {
|
||||
let m = extra.monotonic();
|
||||
if let Some(m) = extra.monotonic {
|
||||
let instants = util::instants_ident(name);
|
||||
|
||||
let uninit = mk_uninit();
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::{analyze::Analysis, check::Extra, codegen::util};
|
|||
pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream2> {
|
||||
let mut items = vec![];
|
||||
|
||||
if extra.monotonic.is_some() {
|
||||
if let Some(m) = extra.monotonic {
|
||||
let t = util::schedule_t_ident();
|
||||
|
||||
// Enumeration of `schedule`-able tasks
|
||||
|
@ -42,7 +42,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
|||
// Static variable and resource proxy
|
||||
{
|
||||
let doc = format!("Timer queue");
|
||||
let m = extra.monotonic();
|
||||
let cap = app
|
||||
.software_tasks
|
||||
.iter()
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
#![no_main]
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
||||
mod app {
|
||||
#[task(binds = SysTick)]
|
||||
fn sys_tick(_: sys_tick::Context) {}
|
||||
|
||||
#[task(schedule = [foo])]
|
||||
fn foo(_: foo::Context) {}
|
||||
}
|
||||
|
|
|
@ -31,11 +31,11 @@ error[E0425]: cannot find value `FOO` in this scope
|
|||
error: duplicate lang item in crate `panic_halt` (which `$CRATE` depends on): `panic_impl`.
|
||||
|
|
||||
= note: the lang item is first defined in crate `std` (which `$CRATE` depends on)
|
||||
= note: first definition in `std` loaded from /usr/share/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-cf0f33af3a901778.rlib
|
||||
= note: second definition in `panic_halt` loaded from $DIR/target/tests/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_halt-ba6f0ab3439cbc7e.rmeta
|
||||
= note: first definition in `std` loaded from /usr/share/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-f14aca24435a5414.rlib
|
||||
= note: second definition in `panic_halt` loaded from $DIR/target/tests/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_halt-33949299fdfa2375.rmeta
|
||||
|
||||
error: duplicate lang item in crate `panic_semihosting`: `panic_impl`.
|
||||
|
|
||||
= note: the lang item is first defined in crate `panic_halt` (which `$CRATE` depends on)
|
||||
= note: first definition in `panic_halt` loaded from $DIR/target/tests/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_halt-ba6f0ab3439cbc7e.rmeta
|
||||
= note: second definition in `panic_semihosting` loaded from $DIR/target/tests/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_semihosting-805015f4a2d05965.rmeta
|
||||
= note: first definition in `panic_halt` loaded from $DIR/target/tests/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_halt-33949299fdfa2375.rmeta
|
||||
= note: second definition in `panic_semihosting` loaded from $DIR/target/tests/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_semihosting-f97442f9ee5cfc78.rmeta
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error: duplicate lang item in crate `panic_halt` (which `$CRATE` depends on): `panic_impl`.
|
||||
|
|
||||
= note: the lang item is first defined in crate `std` (which `$CRATE` depends on)
|
||||
= note: first definition in `std` loaded from /usr/share/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-cf0f33af3a901778.rlib
|
||||
= note: second definition in `panic_halt` loaded from $DIR/target/tests/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_halt-ba6f0ab3439cbc7e.rmeta
|
||||
= note: first definition in `std` loaded from /usr/share/rust/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-f14aca24435a5414.rlib
|
||||
= note: second definition in `panic_halt` loaded from $DIR/target/tests/target/x86_64-unknown-linux-gnu/debug/deps/libpanic_halt-33949299fdfa2375.rmeta
|
||||
|
||||
error[E0609]: no field `o1` on type `initResources<'_>`
|
||||
--> $DIR/resources-cfg.rs:47:21
|
||||
|
|
Loading…
Reference in a new issue