diff --git a/Cargo.toml b/Cargo.toml index b02df9f7c8..0d762df0ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,6 @@ license = "MIT OR Apache-2.0" name = "cortex-m-rtic" readme = "README.md" repository = "https://github.com/rtic-rs/cortex-m-rtic" - version = "0.6.0-alpha.1" [lib] @@ -58,7 +57,7 @@ rtic-monotonic = "0.1.0-alpha.0" rtic-core = "0.3.1" heapless = "0.6.1" bare-metal = "1.0.0" -generic-array = "*" +generic-array = "0.14" [dependencies.dwt-systick-monotonic] version = "0.1.0-alpha.0" diff --git a/examples/t-schedule.rs b/examples/t-schedule.rs index 6b6245eb50..890b3163b2 100644 --- a/examples/t-schedule.rs +++ b/examples/t-schedule.rs @@ -26,30 +26,93 @@ mod app { let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000); - let a: Result = foo::spawn_after(Seconds(1_u32)); - if let Ok(handle) = a { - let _: Result = handle.reschedule_after(Seconds(1_u32)); - } + // Task without message passing - let b: Result = bar::spawn_after(Seconds(2_u32), 0); - if let Ok(handle) = b { - let _: Result = handle.cancel(); - } + // Not default + let _: Result = foo::MyMono::spawn_at(MyMono::now()); + let handle: Result = foo::MyMono::spawn_after(Seconds(1_u32)); + let _: Result = + handle.unwrap().reschedule_after(Seconds(1_u32)); + let handle: Result = foo::MyMono::spawn_after(Seconds(1_u32)); + let _: Result = handle.unwrap().reschedule_at(MyMono::now()); + + let handle: Result = foo::MyMono::spawn_after(Seconds(1_u32)); + let _: Result<(), ()> = handle.unwrap().cancel(); + + // Using default + let _: Result = foo::spawn_at(MyMono::now()); + let handle: Result = foo::spawn_after(Seconds(1_u32)); + let _: Result = handle.unwrap().reschedule_after(Seconds(1_u32)); + + let handle: Result = foo::spawn_after(Seconds(1_u32)); + let _: Result = handle.unwrap().reschedule_at(MyMono::now()); + + let handle: Result = foo::spawn_after(Seconds(1_u32)); + let _: Result<(), ()> = handle.unwrap().cancel(); + + // Task with single message passing + + // Not default + let _: Result = bar::MyMono::spawn_at(MyMono::now(), 0); + let handle: Result = + bar::MyMono::spawn_after(Seconds(1_u32), 0); + let _: Result = + handle.unwrap().reschedule_after(Seconds(1_u32)); + + let handle: Result = + bar::MyMono::spawn_after(Seconds(1_u32), 0); + let _: Result = handle.unwrap().reschedule_at(MyMono::now()); + + let handle: Result = + bar::MyMono::spawn_after(Seconds(1_u32), 0); + let _: Result = handle.unwrap().cancel(); + + // Using default + let _: Result = bar::spawn_at(MyMono::now(), 0); + let handle: Result = bar::spawn_after(Seconds(1_u32), 0); + let _: Result = handle.unwrap().reschedule_after(Seconds(1_u32)); + + let handle: Result = bar::spawn_after(Seconds(1_u32), 0); + let _: Result = handle.unwrap().reschedule_at(MyMono::now()); + + let handle: Result = bar::spawn_after(Seconds(1_u32), 0); + let _: Result = handle.unwrap().cancel(); + + // Task with multiple message passing + + // Not default let _: Result = - baz::spawn_after(Seconds(3_u32), 0, 1); + baz::MyMono::spawn_at(MyMono::now(), 0, 1); + let handle: Result = + baz::MyMono::spawn_after(Seconds(1_u32), 0, 1); + let _: Result = + handle.unwrap().reschedule_after(Seconds(1_u32)); + + let handle: Result = + baz::MyMono::spawn_after(Seconds(1_u32), 0, 1); + let _: Result = handle.unwrap().reschedule_at(MyMono::now()); + + let handle: Result = + baz::MyMono::spawn_after(Seconds(1_u32), 0, 1); + let _: Result<(u32, u32), ()> = handle.unwrap().cancel(); + + // Using default + let _: Result = baz::spawn_at(MyMono::now(), 0, 1); + let handle: Result = baz::spawn_after(Seconds(1_u32), 0, 1); + let _: Result = handle.unwrap().reschedule_after(Seconds(1_u32)); + + let handle: Result = baz::spawn_after(Seconds(1_u32), 0, 1); + let _: Result = handle.unwrap().reschedule_at(MyMono::now()); + + let handle: Result = baz::spawn_after(Seconds(1_u32), 0, 1); + let _: Result<(u32, u32), ()> = handle.unwrap().cancel(); (init::LateResources {}, init::Monotonics(mono)) } #[idle] fn idle(_: idle::Context) -> ! { - let _: Result = foo::spawn_at(MyMono::now() + Seconds(3_u32)); - let _: Result = - bar::spawn_at(MyMono::now() + Seconds(4_u32), 0); - let _: Result = - baz::spawn_at(MyMono::now() + Seconds(5_u32), 0, 1); - loop { cortex_m::asm::nop(); } diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index 5a594c66b3..e15aab1c83 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -319,18 +319,6 @@ pub fn codegen( marker: u32, } - // TODO: remove - impl core::fmt::Debug for SpawnHandle - { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let handle = unsafe { &#app_path::#tq as *const _ as u32 }; - f.debug_struct("SpawnHandle") - .field("marker", &self.marker) - .field("handle", &handle) - .finish() - } - } - impl SpawnHandle { pub fn cancel(self) -> Result<#ty, ()> { rtic::export::interrupt::free(|_| unsafe { diff --git a/src/lib.rs b/src/lib.rs index a88ea81eb4..a4abc4c87b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,7 +32,7 @@ #![deny(missing_docs)] #![deny(rust_2018_compatibility)] #![deny(rust_2018_idioms)] -// #![deny(warnings)] +#![deny(warnings)] #![no_std] use cortex_m::{interrupt::InterruptNumber, peripheral::NVIC};