diff --git a/rtic/examples/async-channel-done.rs b/rtic/examples/async-channel-done.rs index 1c32d32b9e..04d94ff66a 100644 --- a/rtic/examples/async-channel-done.rs +++ b/rtic/examples/async-channel-done.rs @@ -1,9 +1,10 @@ //! examples/async-channel-done.rs -#![deny(unsafe_code)] -#![deny(warnings)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/async-channel-no-receiver.rs b/rtic/examples/async-channel-no-receiver.rs index 02e6a22caa..ccf0070361 100644 --- a/rtic/examples/async-channel-no-receiver.rs +++ b/rtic/examples/async-channel-no-receiver.rs @@ -1,9 +1,10 @@ //! examples/async-channel-no-receiver.rs -#![deny(unsafe_code)] -#![deny(warnings)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/async-channel-no-sender.rs b/rtic/examples/async-channel-no-sender.rs index 0bdc7cb5ee..0705ecdb26 100644 --- a/rtic/examples/async-channel-no-sender.rs +++ b/rtic/examples/async-channel-no-sender.rs @@ -1,9 +1,10 @@ //! examples/async-channel-no-sender.rs -#![deny(unsafe_code)] -#![deny(warnings)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/async-channel-try.rs b/rtic/examples/async-channel-try.rs index 4c369edbf4..26c8a4fb37 100644 --- a/rtic/examples/async-channel-try.rs +++ b/rtic/examples/async-channel-try.rs @@ -1,9 +1,10 @@ //! examples/async-channel-try.rs -#![deny(unsafe_code)] -#![deny(warnings)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/async-channel.rs b/rtic/examples/async-channel.rs index 58eeee87a7..d85b3b55a6 100644 --- a/rtic/examples/async-channel.rs +++ b/rtic/examples/async-channel.rs @@ -1,9 +1,10 @@ //! examples/async-channel.rs -#![deny(unsafe_code)] -#![deny(warnings)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/async-delay.rs b/rtic/examples/async-delay.rs index 03206aeb43..ba6ec54191 100644 --- a/rtic/examples/async-delay.rs +++ b/rtic/examples/async-delay.rs @@ -3,6 +3,7 @@ #![no_main] #![no_std] #![deny(warnings)] +#![deny(unsafe_code)] #![deny(missing_docs)] #![feature(type_alias_impl_trait)] diff --git a/rtic/examples/async-infinite-loop.no_rs b/rtic/examples/async-infinite-loop.no_rs deleted file mode 100644 index a95f9986f8..0000000000 --- a/rtic/examples/async-infinite-loop.no_rs +++ /dev/null @@ -1,53 +0,0 @@ -#![no_main] -#![no_std] -#![feature(type_alias_impl_trait)] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0, UART0], peripherals = true)] -mod app { - use cortex_m_semihosting::{debug, hprintln}; - use systick_monotonic::*; - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[monotonic(binds = SysTick, default = true)] - type MyMono = Systick<100>; - - #[init] - fn init(cx: init::Context) -> (Shared, Local) { - hprintln!("init").unwrap(); - - foo::spawn().ok(); - - (Shared {}, Local {}) - } - - #[idle] - fn idle(_: idle::Context) -> ! { - loop { - cortex_m::asm::wfi(); // put the MCU in sleep mode until interrupt occurs - } - } - - // Infinite loops are not allowed in RTIC, however in async tasks they are - if there is an - // await inside the loop. - #[task] - async fn foo(_cx: foo::Context) { - let mut i = 0; - loop { - if i == 5 { - debug::exit(debug::EXIT_SUCCESS); - } - - hprintln!("hello from async {}", i).ok(); - monotonics::delay(100.millis()).await; // This makes it okey! - - i += 1; - } - } -} diff --git a/rtic/examples/async-task-multiple-prios.rs b/rtic/examples/async-task-multiple-prios.rs index 5c9674d768..88f4cf4547 100644 --- a/rtic/examples/async-task-multiple-prios.rs +++ b/rtic/examples/async-task-multiple-prios.rs @@ -2,8 +2,10 @@ #![no_main] #![no_std] -#![feature(type_alias_impl_trait)] +#![deny(warnings)] +#![deny(unsafe_code)] #![deny(missing_docs)] +#![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/async-task.rs b/rtic/examples/async-task.rs index 7730c54d59..b70151a289 100644 --- a/rtic/examples/async-task.rs +++ b/rtic/examples/async-task.rs @@ -2,8 +2,10 @@ #![no_main] #![no_std] -#![feature(type_alias_impl_trait)] +#![deny(warnings)] +#![deny(unsafe_code)] #![deny(missing_docs)] +#![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/async-timeout.no_rs b/rtic/examples/async-timeout.no_rs deleted file mode 100644 index 3f68df744d..0000000000 --- a/rtic/examples/async-timeout.no_rs +++ /dev/null @@ -1,87 +0,0 @@ -#![no_main] -#![no_std] -#![feature(type_alias_impl_trait)] - -use panic_semihosting as _; - -// NOTES: -// -// - Async tasks cannot have `#[lock_free]` resources, as they can interleve and each async -// task can have a mutable reference stored. -// - Spawning an async task equates to it being polled once. - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0, UART0], peripherals = true)] -mod app { - use core::{ - future::Future, - pin::Pin, - task::{Context, Poll}, - }; - use cortex_m_semihosting::{debug, hprintln}; - use systick_monotonic::*; - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[monotonic(binds = SysTick, default = true)] - type MyMono = Systick<100>; - - #[init] - fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { - hprintln!("init").unwrap(); - - foo::spawn().ok(); - bar::spawn().ok(); - - ( - Shared {}, - Local {}, - init::Monotonics(Systick::new(cx.core.SYST, 12_000_000)), - ) - } - - #[idle] - fn idle(_: idle::Context) -> ! { - loop { - cortex_m::asm::wfi(); // put the MCU in sleep mode until interrupt occurs - } - } - - #[task] - async fn foo(_cx: foo::Context) { - hprintln!("hello from foo").ok(); - - // This will not timeout - match monotonics::timeout_after(monotonics::delay(100.millis()), 200.millis()).await { - Ok(_) => hprintln!("foo no timeout").ok(), - Err(_) => hprintln!("foo timeout").ok(), - }; - } - - #[task] - async fn bar(_cx: bar::Context) { - hprintln!("hello from bar").ok(); - - // This will timeout - match monotonics::timeout_after(NeverEndingFuture {}, 300.millis()).await { - Ok(_) => hprintln!("bar no timeout").ok(), - Err(_) => hprintln!("bar timeout").ok(), - }; - - debug::exit(debug::EXIT_SUCCESS); - } - - pub struct NeverEndingFuture {} - - impl Future for NeverEndingFuture { - type Output = (); - - fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll { - // Never finish - Poll::Pending - } - } -} diff --git a/rtic/examples/async-timeout.rs b/rtic/examples/async-timeout.rs index 810bdeb8cf..fda385aae5 100644 --- a/rtic/examples/async-timeout.rs +++ b/rtic/examples/async-timeout.rs @@ -3,6 +3,7 @@ #![no_main] #![no_std] #![deny(warnings)] +#![deny(unsafe_code)] #![deny(missing_docs)] #![feature(type_alias_impl_trait)] diff --git a/rtic/examples/big-struct-opt.rs b/rtic/examples/big-struct-opt.rs index 408a2dec92..4326247a8b 100644 --- a/rtic/examples/big-struct-opt.rs +++ b/rtic/examples/big-struct-opt.rs @@ -5,8 +5,9 @@ #![no_main] #![no_std] -#![feature(type_alias_impl_trait)] +#![deny(warnings)] #![deny(missing_docs)] +#![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/binds.rs b/rtic/examples/binds.rs index cf078ffe9e..b101d541e2 100644 --- a/rtic/examples/binds.rs +++ b/rtic/examples/binds.rs @@ -1,9 +1,9 @@ //! examples/binds.rs -#![deny(unsafe_code)] -#![deny(warnings)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] #![deny(missing_docs)] use panic_semihosting as _; diff --git a/rtic/examples/cancel-reschedule.no_rs b/rtic/examples/cancel-reschedule.no_rs deleted file mode 100644 index a38a9c4eae..0000000000 --- a/rtic/examples/cancel-reschedule.no_rs +++ /dev/null @@ -1,73 +0,0 @@ -//! examples/cancel-reschedule.rs - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] -mod app { - use cortex_m_semihosting::{debug, hprintln}; - use systick_monotonic::*; - - #[monotonic(binds = SysTick, default = true)] - type MyMono = Systick<100>; // 100 Hz / 10 ms granularity - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { - let systick = cx.core.SYST; - - // Initialize the monotonic (SysTick rate in QEMU is 12 MHz) - let mono = Systick::new(systick, 12_000_000); - - hprintln!("init").ok(); - - // Schedule `foo` to run 1 second in the future - foo::spawn_after(1.secs()).unwrap(); - - ( - Shared {}, - Local {}, - init::Monotonics(mono), // Give the monotonic to RTIC - ) - } - - #[task] - fn foo(_: foo::Context) { - hprintln!("foo").ok(); - - // Schedule `bar` to run 2 seconds in the future (1 second after foo runs) - let spawn_handle = baz::spawn_after(2.secs()).unwrap(); - bar::spawn_after(1.secs(), spawn_handle, false).unwrap(); // Change to true - } - - #[task] - fn bar(_: bar::Context, baz_handle: baz::SpawnHandle, do_reschedule: bool) { - hprintln!("bar").ok(); - - if do_reschedule { - // Reschedule baz 2 seconds from now, instead of the original 1 second - // from now. - baz_handle.reschedule_after(2.secs()).unwrap(); - // Or baz_handle.reschedule_at(/* time */) - } else { - // Or cancel it - baz_handle.cancel().unwrap(); - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - } - } - - #[task] - fn baz(_: baz::Context) { - hprintln!("baz").ok(); - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - } -} diff --git a/rtic/examples/capacity.no_rs b/rtic/examples/capacity.no_rs deleted file mode 100644 index a617269869..0000000000 --- a/rtic/examples/capacity.no_rs +++ /dev/null @@ -1,49 +0,0 @@ -//! examples/capacity.rs - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] -mod app { - use cortex_m_semihosting::{debug, hprintln}; - use lm3s6965::Interrupt; - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - rtic::pend(Interrupt::UART0); - - (Shared {}, Local {}, init::Monotonics()) - } - - #[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)] - fn foo(_: foo::Context, x: u32) { - hprintln!("foo({})", x).unwrap(); - } - - #[task] - fn bar(_: bar::Context) { - hprintln!("bar").unwrap(); - - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - } -} diff --git a/rtic/examples/cfg-whole-task.no_rs b/rtic/examples/cfg-whole-task.no_rs deleted file mode 100644 index f41866db47..0000000000 --- a/rtic/examples/cfg-whole-task.no_rs +++ /dev/null @@ -1,94 +0,0 @@ -//! examples/cfg-whole-task.rs - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0, QEI0])] -mod app { - use cortex_m_semihosting::debug; - #[cfg(debug_assertions)] - use cortex_m_semihosting::hprintln; - - #[shared] - struct Shared { - count: u32, - #[cfg(never)] - unused: u32, - } - - #[local] - struct Local {} - - #[init] - fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - foo::spawn().unwrap(); - foo::spawn().unwrap(); - - ( - Shared { - count: 0, - #[cfg(never)] - unused: 1, - }, - Local {}, - init::Monotonics(), - ) - } - - #[idle] - fn idle(_: idle::Context) -> ! { - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - - loop { - cortex_m::asm::nop(); - } - } - - #[task(capacity = 2, shared = [count])] - fn foo(mut _cx: foo::Context) { - #[cfg(debug_assertions)] - { - _cx.shared.count.lock(|count| *count += 1); - - log::spawn(_cx.shared.count.lock(|count| *count)).unwrap(); - } - - // this wouldn't compile in `release` mode - // *_cx.shared.count += 1; - - // .. - } - - // The whole task should disappear, - // currently still present in the Tasks enum - #[cfg(never)] - #[task(capacity = 2, shared = [count])] - fn foo2(mut _cx: foo2::Context) { - #[cfg(debug_assertions)] - { - _cx.shared.count.lock(|count| *count += 10); - - log::spawn(_cx.shared.count.lock(|count| *count)).unwrap(); - } - - // this wouldn't compile in `release` mode - // *_cx.shared.count += 1; - - // .. - } - - #[cfg(debug_assertions)] - #[task(capacity = 2)] - fn log(_: log::Context, n: u32) { - hprintln!( - "foo has been called {} time{}", - n, - if n == 1 { "" } else { "s" } - ) - .ok(); - } -} diff --git a/rtic/examples/common.no_rs b/rtic/examples/common.no_rs deleted file mode 100644 index 1fe671e61a..0000000000 --- a/rtic/examples/common.no_rs +++ /dev/null @@ -1,102 +0,0 @@ -//! examples/common.rs - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0, QEI0])] -mod app { - use cortex_m_semihosting::{debug, hprintln}; - use systick_monotonic::*; // Implements the `Monotonic` trait - - // A monotonic timer to enable scheduling in RTIC - #[monotonic(binds = SysTick, default = true)] - type MyMono = Systick<100>; // 100 Hz / 10 ms granularity - - // Resources shared between tasks - #[shared] - struct Shared { - s1: u32, - s2: i32, - } - - // Local resources to specific tasks (cannot be shared) - #[local] - struct Local { - l1: u8, - l2: i8, - } - - #[init] - fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { - let systick = cx.core.SYST; - - // Initialize the monotonic (SysTick rate in QEMU is 12 MHz) - let mono = Systick::new(systick, 12_000_000); - - // Spawn the task `foo` directly after `init` finishes - foo::spawn().unwrap(); - - // Spawn the task `bar` 1 second after `init` finishes, this is enabled - // by the `#[monotonic(..)]` above - bar::spawn_after(1.secs()).unwrap(); - - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - - ( - // Initialization of shared resources - Shared { s1: 0, s2: 1 }, - // Initialization of task local resources - Local { l1: 2, l2: 3 }, - // Move the monotonic timer to the RTIC run-time, this enables - // scheduling - init::Monotonics(mono), - ) - } - - // Background task, runs whenever no other tasks are running - #[idle] - fn idle(_: idle::Context) -> ! { - loop { - continue; - } - } - - // Software task, not bound to a hardware interrupt. - // This task takes the task local resource `l1` - // The resources `s1` and `s2` are shared between all other tasks. - #[task(shared = [s1, s2], local = [l1])] - fn foo(_: foo::Context) { - // This task is only spawned once in `init`, hence this task will run - // only once - - hprintln!("foo").ok(); - } - - // Software task, also not bound to a hardware interrupt - // This task takes the task local resource `l2` - // The resources `s1` and `s2` are shared between all other tasks. - #[task(shared = [s1, s2], local = [l2])] - fn bar(_: bar::Context) { - hprintln!("bar").ok(); - - // Run `bar` once per second - bar::spawn_after(1.secs()).unwrap(); - } - - // Hardware task, bound to a hardware interrupt - // The resources `s1` and `s2` are shared between all other tasks. - #[task(binds = UART0, priority = 3, shared = [s1, s2])] - fn uart0_interrupt(_: uart0_interrupt::Context) { - // This task is bound to the interrupt `UART0` and will run - // whenever the interrupt fires - - // Note that RTIC does NOT clear the interrupt flag, this is up to the - // user - - hprintln!("UART0 interrupt!").ok(); - } -} diff --git a/rtic/examples/common.rs b/rtic/examples/common.rs index f07b69c54d..ed6cb7dd8f 100644 --- a/rtic/examples/common.rs +++ b/rtic/examples/common.rs @@ -1,10 +1,11 @@ //! examples/common.rs -#![feature(type_alias_impl_trait)] -#![deny(unsafe_code)] -#![deny(missing_docs)] -#![deny(warnings)] + #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] +#![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/complex.rs b/rtic/examples/complex.rs index c1e9c6c6e0..a4fe659fdd 100644 --- a/rtic/examples/complex.rs +++ b/rtic/examples/complex.rs @@ -1,10 +1,10 @@ //! examples/complex.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] use panic_semihosting as _; diff --git a/rtic/examples/declared_locals.rs b/rtic/examples/declared_locals.rs index c845191024..b1bb9f4dea 100644 --- a/rtic/examples/declared_locals.rs +++ b/rtic/examples/declared_locals.rs @@ -1,10 +1,10 @@ //! examples/declared_locals.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] use panic_semihosting as _; diff --git a/rtic/examples/destructure.rs b/rtic/examples/destructure.rs index 81eff3b412..b5d564bc5e 100644 --- a/rtic/examples/destructure.rs +++ b/rtic/examples/destructure.rs @@ -1,10 +1,10 @@ //! examples/destructure.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/extern_binds.rs b/rtic/examples/extern_binds.rs index 142a11d0b1..f03a8a9c45 100644 --- a/rtic/examples/extern_binds.rs +++ b/rtic/examples/extern_binds.rs @@ -1,10 +1,10 @@ //! examples/extern_binds.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] use cortex_m_semihosting::hprintln; use panic_semihosting as _; diff --git a/rtic/examples/extern_spawn.rs b/rtic/examples/extern_spawn.rs index b2b95b9da4..2ab5550cbb 100644 --- a/rtic/examples/extern_spawn.rs +++ b/rtic/examples/extern_spawn.rs @@ -1,10 +1,10 @@ //! examples/extern_spawn.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use cortex_m_semihosting::{debug, hprintln}; diff --git a/rtic/examples/generics.rs b/rtic/examples/generics.rs index 2f23cce94f..dd042a31c9 100644 --- a/rtic/examples/generics.rs +++ b/rtic/examples/generics.rs @@ -1,10 +1,10 @@ //! examples/generics.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] use cortex_m_semihosting::hprintln; use panic_semihosting as _; diff --git a/rtic/examples/hardware.rs b/rtic/examples/hardware.rs index 62ae0d66b6..b4c6b6c9ca 100644 --- a/rtic/examples/hardware.rs +++ b/rtic/examples/hardware.rs @@ -1,10 +1,10 @@ //! examples/hardware.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] use panic_semihosting as _; diff --git a/rtic/examples/idle-wfi.rs b/rtic/examples/idle-wfi.rs index 8134ce3e0f..72aaa952ec 100644 --- a/rtic/examples/idle-wfi.rs +++ b/rtic/examples/idle-wfi.rs @@ -1,10 +1,10 @@ //! examples/idle-wfi.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] use panic_semihosting as _; diff --git a/rtic/examples/idle.rs b/rtic/examples/idle.rs index 0c4bd044d0..414981851b 100644 --- a/rtic/examples/idle.rs +++ b/rtic/examples/idle.rs @@ -1,10 +1,10 @@ //! examples/idle.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] use panic_semihosting as _; diff --git a/rtic/examples/init.rs b/rtic/examples/init.rs index c3081bf8ed..634d309d6d 100644 --- a/rtic/examples/init.rs +++ b/rtic/examples/init.rs @@ -1,10 +1,10 @@ //! examples/init.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] use panic_semihosting as _; diff --git a/rtic/examples/locals.rs b/rtic/examples/locals.rs index ec3d59d8db..2408f90ca2 100644 --- a/rtic/examples/locals.rs +++ b/rtic/examples/locals.rs @@ -1,11 +1,11 @@ //! examples/locals.rs -#![feature(type_alias_impl_trait)] -#![deny(unsafe_code)] -#![deny(missing_docs)] -#![deny(warnings)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] +#![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/lock-free.no_rs b/rtic/examples/lock-free.no_rs deleted file mode 100644 index 053307c16d..0000000000 --- a/rtic/examples/lock-free.no_rs +++ /dev/null @@ -1,50 +0,0 @@ -//! examples/lock-free.rs - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] -#![feature(type_alias_impl_trait)] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [GPIOA])] -mod app { - use cortex_m_semihosting::{debug, hprintln}; - - #[shared] - struct Shared { - #[lock_free] // <- lock-free shared resource - counter: u64, - } - - #[local] - struct Local {} - - #[init] - fn init(_: init::Context) -> (Shared, Local) { - foo::spawn().unwrap(); - - (Shared { counter: 0 }, Local {}) - } - - #[task(shared = [counter])] // <- same priority - async fn foo(c: foo::Context) { - bar::spawn().unwrap(); - - *c.shared.counter += 1; // <- no lock API required - let counter = *c.shared.counter; - hprintln!(" foo = {}", counter).unwrap(); - } - - #[task(shared = [counter])] // <- same priority - async fn bar(c: bar::Context) { - foo::spawn().unwrap(); - - *c.shared.counter += 1; // <- no lock API required - let counter = *c.shared.counter; - hprintln!(" bar = {}", counter).unwrap(); - - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - } -} diff --git a/rtic/examples/lock-free.rs b/rtic/examples/lock-free.rs index 3e0960408e..c17d70d36b 100644 --- a/rtic/examples/lock-free.rs +++ b/rtic/examples/lock-free.rs @@ -1,9 +1,10 @@ //! examples/lock-free.rs -#![deny(unsafe_code)] -#![deny(warnings)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/lock.rs b/rtic/examples/lock.rs index 203ae6f47d..c09d99db12 100644 --- a/rtic/examples/lock.rs +++ b/rtic/examples/lock.rs @@ -1,10 +1,10 @@ //! examples/lock.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/message.no_rs b/rtic/examples/message.no_rs deleted file mode 100644 index 76c5675aaa..0000000000 --- a/rtic/examples/message.no_rs +++ /dev/null @@ -1,52 +0,0 @@ -//! examples/message.rs - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] -mod app { - use cortex_m_semihosting::{debug, hprintln}; - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { - foo::spawn(/* no message */).unwrap(); - - (Shared {}, Local {}, init::Monotonics()) - } - - #[task(local = [count: u32 = 0])] - fn foo(cx: foo::Context) { - hprintln!("foo").unwrap(); - - bar::spawn(*cx.local.count).unwrap(); - *cx.local.count += 1; - } - - #[task] - fn bar(_: bar::Context, x: u32) { - hprintln!("bar({})", x).unwrap(); - - baz::spawn(x + 1, x + 2).unwrap(); - } - - #[task] - fn baz(_: baz::Context, x: u32, y: u32) { - hprintln!("baz({}, {})", x, y).unwrap(); - - if x + y > 4 { - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - } - - foo::spawn().unwrap(); - } -} diff --git a/rtic/examples/multilock.rs b/rtic/examples/multilock.rs index 6208caccd4..ba9588bfdb 100644 --- a/rtic/examples/multilock.rs +++ b/rtic/examples/multilock.rs @@ -1,10 +1,10 @@ //! examples/mutlilock.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/not-sync.rs b/rtic/examples/not-sync.rs index 6d1ddaea58..cd6b0bf5c9 100644 --- a/rtic/examples/not-sync.rs +++ b/rtic/examples/not-sync.rs @@ -1,10 +1,9 @@ //! `examples/not-sync.rs` -// #![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use core::marker::PhantomData; diff --git a/rtic/examples/only-shared-access.rs b/rtic/examples/only-shared-access.rs index 1d006e636b..23ae67ef63 100644 --- a/rtic/examples/only-shared-access.rs +++ b/rtic/examples/only-shared-access.rs @@ -1,10 +1,10 @@ //! examples/only-shared-access.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/periodic-at.no_rs b/rtic/examples/periodic-at.no_rs deleted file mode 100644 index ca68ed5eb9..0000000000 --- a/rtic/examples/periodic-at.no_rs +++ /dev/null @@ -1,49 +0,0 @@ -//! examples/periodic-at.rs - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] -mod app { - use cortex_m_semihosting::{debug, hprintln}; - use systick_monotonic::*; - - #[monotonic(binds = SysTick, default = true)] - type MyMono = Systick<100>; // 100 Hz / 10 ms granularity - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { - let systick = cx.core.SYST; - - // Initialize the monotonic (SysTick rate in QEMU is 12 MHz) - let mut mono = Systick::new(systick, 12_000_000); - - foo::spawn_after(1.secs(), mono.now()).unwrap(); - - (Shared {}, Local {}, init::Monotonics(mono)) - } - - #[task(local = [cnt: u32 = 0])] - fn foo(cx: foo::Context, instant: fugit::TimerInstantU64<100>) { - hprintln!("foo {:?}", instant).ok(); - *cx.local.cnt += 1; - - if *cx.local.cnt == 4 { - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - } - - // Periodic every 100 milliseconds - let next_instant = instant + 100.millis(); - foo::spawn_at(next_instant, next_instant).unwrap(); - } -} diff --git a/rtic/examples/periodic-at2.no_rs b/rtic/examples/periodic-at2.no_rs deleted file mode 100644 index ec9adcc50c..0000000000 --- a/rtic/examples/periodic-at2.no_rs +++ /dev/null @@ -1,61 +0,0 @@ -//! examples/periodic-at2.rs - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] -mod app { - use cortex_m_semihosting::{debug, hprintln}; - use systick_monotonic::*; - - #[monotonic(binds = SysTick, default = true)] - type MyMono = Systick<100>; // 100 Hz / 10 ms granularity - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { - let systick = cx.core.SYST; - - // Initialize the monotonic (SysTick rate in QEMU is 12 MHz) - let mut mono = Systick::new(systick, 12_000_000); - - foo::spawn_after(200.millis(), mono.now()).unwrap(); - - (Shared {}, Local {}, init::Monotonics(mono)) - } - - // Using the explicit type of the timer implementation - #[task(local = [cnt: u32 = 0])] - fn foo(cx: foo::Context, instant: fugit::TimerInstantU64<100>) { - hprintln!("foo {:?}", instant).ok(); - *cx.local.cnt += 1; - - if *cx.local.cnt == 4 { - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - } - - // Spawn a new message with 100 ms offset to spawned time - let next_instant = instant + 100.millis(); - bar::spawn_at(next_instant, next_instant).unwrap(); - } - - // Using the Instant from the Monotonic trait - // This remains agnostic to the timer implementation - #[task(local = [cnt: u32 = 0])] - fn bar(_cx: bar::Context, instant: ::Instant) { - hprintln!("bar {:?}", instant).ok(); - - // Spawn a new message with 200ms offset to spawned time - let next_instant = instant + 200.millis(); - foo::spawn_at(next_instant, next_instant).unwrap(); - } -} diff --git a/rtic/examples/periodic.no_rs b/rtic/examples/periodic.no_rs deleted file mode 100644 index 2f9e8e6a64..0000000000 --- a/rtic/examples/periodic.no_rs +++ /dev/null @@ -1,48 +0,0 @@ -//! examples/periodic.rs - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] -mod app { - use cortex_m_semihosting::{debug, hprintln}; - use systick_monotonic::*; - - #[monotonic(binds = SysTick, default = true)] - type MyMono = Systick<100>; // 100 Hz / 10 ms granularity - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { - let systick = cx.core.SYST; - - // Initialize the monotonic (SysTick rate in QEMU is 12 MHz) - let mono = Systick::new(systick, 12_000_000); - - foo::spawn_after(100.millis()).unwrap(); - - (Shared {}, Local {}, init::Monotonics(mono)) - } - - #[task(local = [cnt: u32 = 0])] - fn foo(cx: foo::Context) { - hprintln!("foo").ok(); - *cx.local.cnt += 1; - - if *cx.local.cnt == 4 { - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - } - - // Periodic every 100ms - foo::spawn_after(100.millis()).unwrap(); - } -} diff --git a/rtic/examples/peripherals-taken.rs b/rtic/examples/peripherals-taken.rs index 2f710e90c3..2f63001321 100644 --- a/rtic/examples/peripherals-taken.rs +++ b/rtic/examples/peripherals-taken.rs @@ -1,10 +1,10 @@ //! examples/peripherals-taken.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] use panic_semihosting as _; diff --git a/rtic/examples/pool.rs b/rtic/examples/pool.rs index e597ec69f5..92c10c4339 100644 --- a/rtic/examples/pool.rs +++ b/rtic/examples/pool.rs @@ -1,9 +1,8 @@ //! examples/pool.rs -#![deny(unsafe_code)] -#![deny(warnings)] #![no_main] #![no_std] +#![deny(warnings)] #![feature(type_alias_impl_trait)] use heapless::{ diff --git a/rtic/examples/preempt.rs b/rtic/examples/preempt.rs index 4b11907c87..f1a92b0231 100644 --- a/rtic/examples/preempt.rs +++ b/rtic/examples/preempt.rs @@ -2,8 +2,10 @@ #![no_main] #![no_std] -#![feature(type_alias_impl_trait)] +#![deny(warnings)] +#![deny(unsafe_code)] #![deny(missing_docs)] +#![feature(type_alias_impl_trait)] use panic_semihosting as _; use rtic::app; diff --git a/rtic/examples/ramfunc.rs b/rtic/examples/ramfunc.rs index e2e7f67bb0..11349268be 100644 --- a/rtic/examples/ramfunc.rs +++ b/rtic/examples/ramfunc.rs @@ -1,9 +1,9 @@ //! examples/ramfunc.rs +//! TODO: verify that ram-sections are properly used -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/resource-user-struct.rs b/rtic/examples/resource-user-struct.rs index fcbacaea8c..cad42d7a86 100644 --- a/rtic/examples/resource-user-struct.rs +++ b/rtic/examples/resource-user-struct.rs @@ -1,10 +1,10 @@ //! examples/resource.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] use panic_semihosting as _; diff --git a/rtic/examples/schedule.no_rs b/rtic/examples/schedule.no_rs deleted file mode 100644 index 5bad5a30ad..0000000000 --- a/rtic/examples/schedule.no_rs +++ /dev/null @@ -1,64 +0,0 @@ -//! examples/schedule.rs - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] -mod app { - use cortex_m_semihosting::{debug, hprintln}; - use systick_monotonic::*; - - #[monotonic(binds = SysTick, default = true)] - type MyMono = Systick<100>; // 100 Hz / 10 ms granularity - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { - let systick = cx.core.SYST; - - // Initialize the monotonic (SysTick rate in QEMU is 12 MHz) - let mono = Systick::new(systick, 12_000_000); - - hprintln!("init").ok(); - - // Schedule `foo` to run 1 second in the future - foo::spawn_after(1.secs()).unwrap(); - - ( - Shared {}, - Local {}, - init::Monotonics(mono), // Give the monotonic to RTIC - ) - } - - #[task] - fn foo(_: foo::Context) { - hprintln!("foo").ok(); - - // Schedule `bar` to run 2 seconds in the future (1 second after foo runs) - bar::spawn_after(1.secs()).unwrap(); - } - - #[task] - fn bar(_: bar::Context) { - hprintln!("bar").ok(); - - // Schedule `baz` to run 1 seconds from now, but with a specific time instant. - baz::spawn_at(monotonics::now() + 1.secs()).unwrap(); - } - - #[task] - fn baz(_: baz::Context) { - hprintln!("baz").ok(); - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - } -} diff --git a/rtic/examples/shared.rs b/rtic/examples/shared.rs index d0633fbd0e..79ebab8699 100644 --- a/rtic/examples/shared.rs +++ b/rtic/examples/shared.rs @@ -1,10 +1,10 @@ //! examples/late.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] use panic_semihosting as _; diff --git a/rtic/examples/smallest.rs b/rtic/examples/smallest.rs index e54ae44813..fee3f05d97 100644 --- a/rtic/examples/smallest.rs +++ b/rtic/examples/smallest.rs @@ -2,6 +2,8 @@ #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] #![deny(missing_docs)] use panic_semihosting as _; // panic handler diff --git a/rtic/examples/spawn.rs b/rtic/examples/spawn.rs index d30ecf1bb6..58f9bc00c0 100644 --- a/rtic/examples/spawn.rs +++ b/rtic/examples/spawn.rs @@ -1,10 +1,10 @@ //! examples/spawn.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/spawn_arguments.rs b/rtic/examples/spawn_arguments.rs index 01f1a65499..5ca700fba1 100644 --- a/rtic/examples/spawn_arguments.rs +++ b/rtic/examples/spawn_arguments.rs @@ -1,9 +1,10 @@ -//! examples/message_passing.rs +//! examples/spawn_arguments.rs -#![deny(unsafe_code)] -#![deny(warnings)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/spawn_err.rs b/rtic/examples/spawn_err.rs index ee9904ae19..abe62953bd 100644 --- a/rtic/examples/spawn_err.rs +++ b/rtic/examples/spawn_err.rs @@ -1,10 +1,10 @@ -//! examples/spawn.rs +//! examples/spawn_err.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/spawn_loop.rs b/rtic/examples/spawn_loop.rs index c1ad04e36c..9328a94250 100644 --- a/rtic/examples/spawn_loop.rs +++ b/rtic/examples/spawn_loop.rs @@ -1,10 +1,10 @@ -//! examples/spawn.rs +//! examples/spawn_loop.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/static.rs b/rtic/examples/static.rs index 7f656f4529..a98e2e5ef2 100644 --- a/rtic/examples/static.rs +++ b/rtic/examples/static.rs @@ -1,10 +1,10 @@ //! examples/static.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/t-binds.rs b/rtic/examples/t-binds.rs index bdeb3917dd..01c262cf7c 100644 --- a/rtic/examples/t-binds.rs +++ b/rtic/examples/t-binds.rs @@ -1,10 +1,10 @@ //! [compile-pass] Check that `binds` works as advertised -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] use panic_semihosting as _; diff --git a/rtic/examples/t-cfg-resources.rs b/rtic/examples/t-cfg-resources.rs index 0328700957..2ddfae738f 100644 --- a/rtic/examples/t-cfg-resources.rs +++ b/rtic/examples/t-cfg-resources.rs @@ -2,6 +2,8 @@ #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] #![deny(missing_docs)] use panic_semihosting as _; diff --git a/rtic/examples/t-htask-main.rs b/rtic/examples/t-htask-main.rs index 8f885bc173..61280f80d3 100644 --- a/rtic/examples/t-htask-main.rs +++ b/rtic/examples/t-htask-main.rs @@ -1,10 +1,10 @@ -//! examples/h-task-main.rs +//! examples/t-task-main.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] use panic_semihosting as _; diff --git a/rtic/examples/t-idle-main.rs b/rtic/examples/t-idle-main.rs index 43215cf7c5..88566a98d0 100644 --- a/rtic/examples/t-idle-main.rs +++ b/rtic/examples/t-idle-main.rs @@ -1,10 +1,10 @@ //! examples/t-idle-main.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] use panic_semihosting as _; diff --git a/rtic/examples/t-late-not-send.rs b/rtic/examples/t-late-not-send.rs index 44d1d855b4..be5cc66b71 100644 --- a/rtic/examples/t-late-not-send.rs +++ b/rtic/examples/t-late-not-send.rs @@ -2,6 +2,8 @@ #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] #![deny(missing_docs)] use core::marker::PhantomData; diff --git a/rtic/examples/t-schedule.no_rs b/rtic/examples/t-schedule.no_rs deleted file mode 100644 index 5ec420873d..0000000000 --- a/rtic/examples/t-schedule.no_rs +++ /dev/null @@ -1,136 +0,0 @@ -//! [compile-pass] Check `schedule` code generation - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] -mod app { - use cortex_m_semihosting::debug; - use systick_monotonic::*; - - #[monotonic(binds = SysTick, default = true)] - type MyMono = Systick<100>; // 100 Hz / 10 ms granularity - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { - let systick = cx.core.SYST; - - // Initialize the monotonic (SysTick rate in QEMU is 12 MHz) - let mono = Systick::new(systick, 12_000_000); - - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - - (Shared {}, Local {}, init::Monotonics(mono)) - } - - #[idle] - fn idle(_: idle::Context) -> ! { - // Task without message passing - - // Not default - let _: Result = - foo::MyMono::spawn_at(monotonics::MyMono::now()); - let handle: Result = foo::MyMono::spawn_after(1.secs()); - let _: Result = handle.unwrap().reschedule_after(1.secs()); - - let handle: Result = foo::MyMono::spawn_after(1.secs()); - let _: Result = - handle.unwrap().reschedule_at(monotonics::MyMono::now()); - - let handle: Result = foo::MyMono::spawn_after(1.secs()); - let _: Result<(), ()> = handle.unwrap().cancel(); - - // Using default - let _: Result = foo::spawn_at(monotonics::now()); - let handle: Result = foo::spawn_after(1.secs()); - let _: Result = handle.unwrap().reschedule_after(1.secs()); - - let handle: Result = foo::spawn_after(1.secs()); - let _: Result = - handle.unwrap().reschedule_at(monotonics::MyMono::now()); - - let handle: Result = foo::spawn_after(1.secs()); - let _: Result<(), ()> = handle.unwrap().cancel(); - - // Task with single message passing - - // Not default - let _: Result = - bar::MyMono::spawn_at(monotonics::MyMono::now(), 0); - let handle: Result = bar::MyMono::spawn_after(1.secs(), 1); - let _: Result = handle.unwrap().reschedule_after(1.secs()); - - let handle: Result = bar::MyMono::spawn_after(1.secs(), 1); - let _: Result = - handle.unwrap().reschedule_at(monotonics::MyMono::now()); - - let handle: Result = bar::MyMono::spawn_after(1.secs(), 1); - let _: Result = handle.unwrap().cancel(); - - // Using default - let _: Result = bar::spawn_at(monotonics::MyMono::now(), 0); - let handle: Result = bar::spawn_after(1.secs(), 1); - let _: Result = handle.unwrap().reschedule_after(1.secs()); - - let handle: Result = bar::spawn_after(1.secs(), 1); - let _: Result = - handle.unwrap().reschedule_at(monotonics::MyMono::now()); - - let handle: Result = bar::spawn_after(1.secs(), 1); - let _: Result = handle.unwrap().cancel(); - - // Task with multiple message passing - - // Not default - let _: Result = - baz::MyMono::spawn_at(monotonics::MyMono::now(), 0, 1); - let handle: Result = - baz::MyMono::spawn_after(1.secs(), 1, 2); - let _: Result = handle.unwrap().reschedule_after(1.secs()); - - let handle: Result = - baz::MyMono::spawn_after(1.secs(), 1, 2); - let _: Result = - handle.unwrap().reschedule_at(monotonics::MyMono::now()); - - let handle: Result = - baz::MyMono::spawn_after(1.secs(), 1, 2); - let _: Result<(u32, u32), ()> = handle.unwrap().cancel(); - - // Using default - let _: Result = - baz::spawn_at(monotonics::MyMono::now(), 0, 1); - let handle: Result = baz::spawn_after(1.secs(), 1, 2); - let _: Result = handle.unwrap().reschedule_after(1.secs()); - - let handle: Result = baz::spawn_after(1.secs(), 1, 2); - let _: Result = - handle.unwrap().reschedule_at(monotonics::MyMono::now()); - - let handle: Result = baz::spawn_after(1.secs(), 1, 2); - let _: Result<(u32, u32), ()> = handle.unwrap().cancel(); - - loop { - cortex_m::asm::nop(); - } - } - - #[task] - fn foo(_: foo::Context) {} - - #[task] - fn bar(_: bar::Context, _x: u32) {} - - #[task] - fn baz(_: baz::Context, _x: u32, _y: u32) {} -} diff --git a/rtic/examples/t-spawn.no_rs b/rtic/examples/t-spawn.no_rs deleted file mode 100644 index dad0c83ac2..0000000000 --- a/rtic/examples/t-spawn.no_rs +++ /dev/null @@ -1,69 +0,0 @@ -//! [compile-pass] Check code generation of `spawn` - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] -#![feature(type_alias_impl_trait)] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] -mod app { - use cortex_m_semihosting::debug; - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(_: init::Context) -> (Shared, Local) { - let _: Result<(), ()> = foo::spawn(); - let _: Result<(), u32> = bar::spawn(0); - let _: Result<(), (u32, u32)> = baz::spawn(0, 1); - - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - - (Shared {}, Local {}) - } - - #[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)] - 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)] - fn uart0(_: uart0::Context) { - let _: Result<(), ()> = foo::spawn(); - let _: Result<(), u32> = bar::spawn(0); - let _: Result<(), (u32, u32)> = baz::spawn(0, 1); - } - - #[task] - async fn foo(_: foo::Context) { - let _: Result<(), ()> = foo::spawn(); - let _: Result<(), u32> = bar::spawn(0); - let _: Result<(), (u32, u32)> = baz::spawn(0, 1); - } - - #[task] - async fn bar(_: bar::Context, _x: u32) {} - - #[task] - async fn baz(_: baz::Context, _x: u32, _y: u32) {} -} diff --git a/rtic/examples/task.rs b/rtic/examples/task.rs index ab6a1e0e51..9b06bb49c8 100644 --- a/rtic/examples/task.rs +++ b/rtic/examples/task.rs @@ -1,10 +1,10 @@ //! examples/task.rs -#![deny(unsafe_code)] -#![deny(warnings)] -#![deny(missing_docs)] #![no_main] #![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] #![feature(type_alias_impl_trait)] use panic_semihosting as _; diff --git a/rtic/examples/zero-prio-task.rs b/rtic/examples/zero-prio-task.rs index c810e8fa87..dbe1959e67 100644 --- a/rtic/examples/zero-prio-task.rs +++ b/rtic/examples/zero-prio-task.rs @@ -2,8 +2,10 @@ #![no_main] #![no_std] -#![feature(type_alias_impl_trait)] +#![deny(warnings)] +#![deny(unsafe_code)] #![deny(missing_docs)] +#![feature(type_alias_impl_trait)] use core::marker::PhantomData; use panic_semihosting as _; diff --git a/rtic/examples/zero-prio-task_err.no_rs b/rtic/examples/zero-prio-task_err.no_rs deleted file mode 100644 index ab67d82e3f..0000000000 --- a/rtic/examples/zero-prio-task_err.no_rs +++ /dev/null @@ -1,66 +0,0 @@ -//! examples/zero-prio-task.rs - -#![no_main] -#![no_std] -#![feature(type_alias_impl_trait)] -#![deny(missing_docs)] - -use core::marker::PhantomData; -use panic_semihosting as _; - -/// Does not impl send -pub struct NotSend { - _0: PhantomData<*const ()>, -} - -#[rtic::app(device = lm3s6965, peripherals = true)] -mod app { - use super::NotSend; - use core::marker::PhantomData; - use cortex_m_semihosting::{debug, hprintln}; - - #[shared] - struct Shared { - x: NotSend, - } - - #[local] - struct Local { - y: NotSend, - } - - #[init] - fn init(_cx: init::Context) -> (Shared, Local) { - hprintln!("init"); - - async_task::spawn().unwrap(); - async_task2::spawn().unwrap(); - - ( - Shared { - x: NotSend { _0: PhantomData }, - }, - Local { - y: NotSend { _0: PhantomData }, - }, - ) - } - - #[task(priority = 0, shared = [x], local = [y])] - async fn async_task(_: async_task::Context) { - hprintln!("hello from async"); - } - - #[task(priority = 0, shared = [x])] - async fn async_task2(_: async_task2::Context) { - hprintln!("hello from async2"); - } - - #[idle(shared = [x])] - fn idle(_: idle::Context) -> ! { - hprintln!("hello from idle"); - - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - loop {} - } -}