diff options
| author | Emil Fresk <emil.fresk@gmail.com> | 2020-10-11 19:41:57 +0200 |
|---|---|---|
| committer | Emil Fresk <emil.fresk@gmail.com> | 2020-10-11 20:35:50 +0200 |
| commit | 5b8e6a22ab68e316e11641dedf5b39e20878c7b7 (patch) | |
| tree | 1bdc1812ca24203f3b99f381b1e9f8c89f60be24 | |
| parent | 524273c96a978299b64e51a9cdcc007585a0f170 (diff) | |
Fixing examples and tests, modules now import user imports correctly
Fmt
Correct syntax crate
UI test fix
Fix build script
Cleanup
More cleanup
28 files changed, 148 insertions, 246 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8da9867..def72c9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -251,7 +251,6 @@ jobs: capacity types - not-send not-sync shared-with-init diff --git a/examples/baseline.rs b/examples/baseline.rs index 3ab40db..0b7e3ea 100644 --- a/examples/baseline.rs +++ b/examples/baseline.rs @@ -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 diff --git a/examples/capacity.rs b/examples/capacity.rs index ba8b15b..f903acb 100644 --- a/examples/capacity.rs +++ b/examples/capacity.rs @@ -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(); - - c.spawn.bar().unwrap(); + #[task(binds = UART0)] + fn uart0(_: uart0::Context) { + foo::spawn(0).unwrap(); + foo::spawn(1).unwrap(); + foo::spawn(2).unwrap(); + foo::spawn(3).unwrap(); + + bar::spawn().unwrap(); } #[task(capacity = 4)] diff --git a/examples/cfg.rs b/examples/cfg.rs index d49f54c..c8892ea 100644 --- a/examples/cfg.rs +++ b/examples/cfg.rs @@ -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 diff --git a/examples/double_schedule.rs b/examples/double_schedule.rs index b1b78b8..d242c57 100644 --- a/examples/double_schedule.rs +++ b/examples/double_schedule.rs @@ -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" { diff --git a/examples/message.rs b/examples/message.rs index f973672..5ff6288 100644 --- a/examples/message.rs +++ b/examples/message.rs @@ -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 diff --git a/examples/not-send.rs b/examples/not-send.rs deleted file mode 100644 index 18071fc..0000000 --- a/examples/not-send.rs +++ /dev/null @@ -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(); - } -} diff --git a/examples/periodic.rs b/examples/periodic.rs index d3aedd3..95cd145 100644 --- a/examples/periodic.rs +++ b/examples/periodic.rs @@ -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 diff --git a/examples/pool.rs b/examples/pool.rs index cdbabca..2ad9984 100644 --- a/examples/pool.rs +++ b/examples/pool.rs @@ -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] diff --git a/examples/ramfunc.rs b/examples/ramfunc.rs index 5ff167a..84d633d 100644 --- a/examples/ramfunc.rs +++ b/examples/ramfunc.rs @@ -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" { diff --git a/examples/spawn.rs b/examples/spawn.rs index 23fa178..0720bf9 100644 --- a/examples/spawn.rs +++ b/examples/spawn.rs @@ -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(); diff --git a/examples/t-cfg.rs b/examples/t-cfg.rs index 3da20d4..7076f5d 100644 --- a/examples/t-cfg.rs +++ b/examples/t-cfg.rs @@ -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; diff --git a/examples/t-schedule.rs b/examples/t-schedule.rs index d5a6d3f..7c2c420 100644 --- a/examples/t-schedule.rs +++ b/examples/t-schedule.rs @@ -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] diff --git a/examples/t-spawn.rs b/examples/t-spawn.rs index efb748b..cf850e4 100644 --- a/examples/t-spawn.rs +++ b/examples/t-spawn.rs @@ -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] diff --git a/examples/t-stask-main.rs b/examples/t-stask-main.rs index 74335c1..3337c7d 100644 --- a/examples/t-stask-main.rs +++ b/examples/t-stask-main.rs @@ -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 {} } diff --git a/examples/task.rs b/examples/task.rs index 80a9c43..f3d916f 100644 --- a/examples/task.rs +++ b/examples/task.rs @@ -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(); } diff --git a/examples/types.rs b/examples/types.rs index 251d004..b55a98c 100644 --- a/examples/types.rs +++ b/examples/types.rs @@ -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 diff --git a/macros/Cargo.toml b/macros/Cargo.toml index f8a0523..1413c6f 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -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" } diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs index 2be265d..9ea6165 100644 --- a/macros/src/codegen.rs +++ b/macros/src/codegen.rs @@ -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)* } ) diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs index d8c228e..ebfa69b 100644 --- a/macros/src/codegen/hardware_tasks.rs +++ b/macros/src/codegen/hardware_tasks.rs @@ -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)), diff --git a/macros/src/codegen/idle.rs b/macros/src/codegen/idle.rs index 78fac96..5e73329 100644 --- a/macros/src/codegen/idle.rs +++ b/macros/src/codegen/idle.rs @@ -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; diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index 979c63c..e3b0ed9 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -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)* } ) diff --git a/macros/src/codegen/pre_init.rs b/macros/src/codegen/pre_init.rs index bc87b1d..02afdf9 100644 --- a/macros/src/codegen/pre_init.rs +++ b/macros/src/codegen/pre_init.rs @@ -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!( diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index f841a86..9918dea 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -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(); diff --git a/macros/src/codegen/timer_queue.rs b/macros/src/codegen/timer_queue.rs index e7d710c..ae86436 100644 --- a/macros/src/codegen/timer_queue.rs +++ b/macros/src/codegen/timer_queue.rs @@ -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() diff --git a/ui/single/exception-systick-used.rs b/ui/single/exception-systick-used.rs index 1c30b70..9e94c73 100644 --- a/ui/single/exception-systick-used.rs +++ b/ui/single/exception-systick-used.rs @@ -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) {} } diff --git a/ui/single/locals-cfg.stderr b/ui/single/locals-cfg.stderr index e58bd93..53cdacc 100644 --- a/ui/single/locals-cfg.stderr +++ b/ui/single/locals-cfg.stderr @@ -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 diff --git a/ui/single/resources-cfg.stderr b/ui/single/resources-cfg.stderr index 17f08d8..0b0c749 100644 --- a/ui/single/resources-cfg.stderr +++ b/ui/single/resources-cfg.stderr @@ -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 |
