From 21db4d1df4b3a3b7a2a6bf61d96d630abfe4d424 Mon Sep 17 00:00:00 2001 From: Eric Trombly Date: Fri, 19 Apr 2019 10:50:43 -0500 Subject: [PATCH 01/20] add sandbox example --- book/en/src/by-example.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/book/en/src/by-example.md b/book/en/src/by-example.md index 0e09b03fb1..cafbc86cca 100644 --- a/book/en/src/by-example.md +++ b/book/en/src/by-example.md @@ -14,3 +14,9 @@ program. Check [the embedded Rust book] for instructions on how to set up an embedded development environment that includes QEMU. [the embedded Rust book]: https://rust-embedded.github.io/book/intro/install.html + +## Real World Examples + +The following are examples of RTFM being used in real world projects. + +- [etrombly/sandbox](https://github.com/etrombly/sandbox/tree/4f5a230920ad815c0cfbc0e0ae5e39718d3f58fa). A hardware zen garden that draws patterns in sand. Patterns are sent over serial using G-code. From 19212a9f706b7d66afae7d1e7efa669e24964351 Mon Sep 17 00:00:00 2001 From: Eric Trombly Date: Sun, 21 Apr 2019 09:21:33 -0500 Subject: [PATCH 02/20] update commit for example link and specify RTFM version --- book/en/src/by-example.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/book/en/src/by-example.md b/book/en/src/by-example.md index cafbc86cca..e19f07491c 100644 --- a/book/en/src/by-example.md +++ b/book/en/src/by-example.md @@ -19,4 +19,6 @@ embedded development environment that includes QEMU. The following are examples of RTFM being used in real world projects. -- [etrombly/sandbox](https://github.com/etrombly/sandbox/tree/4f5a230920ad815c0cfbc0e0ae5e39718d3f58fa). A hardware zen garden that draws patterns in sand. Patterns are sent over serial using G-code. +### RTFM V0.4.2 + +- [etrombly/sandbox](https://github.com/etrombly/sandbox/tree/41d423bcdd0d8e42fd46b79771400a8ca349af55). A hardware zen garden that draws patterns in sand. Patterns are sent over serial using G-code. From d127b377a5587d14b8f449f9b1de21b8319b17f1 Mon Sep 17 00:00:00 2001 From: Nathan Fox Date: Mon, 27 Jul 2020 21:11:27 -0400 Subject: [PATCH 03/20] fix badges / clean up README --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 45bb9de840..3b3a471661 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ A concurrency framework for building real-time systems. Formerly known as Real-Time For the Masses. -![crates.io](https://img.shields.io/crates/v/cortex-m-rtic) -![docs.rs](https://docs.rs/cortex-m-rtic/badge.svg) -![book](https://img.shields.io/badge/web-rtic.rs-red.svg?style=flat&label=book&colorB=d33847) +[![crates.io](https://img.shields.io/crates/v/cortex-m-rtic)](https://crates.io/crates/cortex-m-rtic) +[![docs.rs](https://docs.rs/cortex-m-rtic/badge.svg)](https://docs.rs/cortex-m-rtic) +[![book](https://img.shields.io/badge/web-rtic.rs-red.svg?style=flat&label=book&colorB=d33847)](https://rtic.rs/) ![rustc](https://img.shields.io/badge/rustc-1.36+-lightgray.svg) ## Features @@ -50,10 +50,6 @@ Formerly known as Real-Time For the Masses. - Applications must be written using the 2018 edition. -## [User documentation](https://rtic.rs) - -## [API reference](https://rtic.rs/0.5/api/) - ## Chat Join us and talk about RTIC in the [Matrix room][matrix-room]. From 05d08c3be577b7359b9e92873e02300d7dbbe6a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Thu, 1 Oct 2020 16:29:55 +0000 Subject: [PATCH 04/20] Use latest mdBook --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c687115389..0f88c80d08 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -529,7 +529,7 @@ jobs: - name: mdBook Action uses: peaceiris/actions-mdbook@v1.1.11 with: - mdbook-version: '0.3.1' + mdbook-version: 'latest' - name: Build book in English run: cd book/en && mdbook build From e7f0d9c3e3fad77dace2ce63af02559fda46cb73 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Thu, 1 Oct 2020 19:38:49 +0200 Subject: [PATCH 05/20] Now late resources are always used --- examples/baseline.rs | 4 ++- examples/binds.rs | 4 ++- examples/capacity.rs | 4 ++- examples/cfg.rs | 4 ++- examples/destructure.rs | 4 ++- examples/generics.rs | 4 ++- examples/hardware.rs | 4 ++- examples/idle.rs | 4 ++- examples/init.rs | 4 ++- examples/lock.rs | 4 ++- examples/message.rs | 4 ++- examples/not-send.rs | 4 ++- examples/not-sync.rs | 4 ++- examples/periodic.rs | 4 ++- examples/peripherals-taken.rs | 4 ++- examples/pool.rs | 4 ++- examples/preempt.rs | 4 ++- examples/ramfunc.rs | 4 ++- examples/resource.rs | 4 ++- examples/schedule.rs | 4 ++- examples/shared-with-init.rs | 4 ++- examples/t-binds.rs | 4 ++- examples/t-cfg.rs | 4 ++- examples/t-htask-main.rs | 6 +++-- examples/t-idle-main.rs | 4 ++- examples/t-init-main.rs | 4 ++- examples/t-resource.rs | 4 ++- examples/t-schedule.rs | 4 ++- examples/t-spawn.rs | 4 ++- examples/t-stask-main.rs | 4 ++- examples/task.rs | 4 ++- examples/types.rs | 4 ++- macros/Cargo.toml | 2 +- macros/src/codegen/init.rs | 50 +++++++++++++++-------------------- macros/src/codegen/module.rs | 12 ++++----- 35 files changed, 124 insertions(+), 70 deletions(-) diff --git a/examples/baseline.rs b/examples/baseline.rs index f46b273d4b..5a6dbd4c17 100644 --- a/examples/baseline.rs +++ b/examples/baseline.rs @@ -13,13 +13,15 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)] const APP: () = { #[init(spawn = [foo])] - fn init(cx: init::Context) { + 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(); + + init::LateResources {} } #[task(schedule = [foo])] diff --git a/examples/binds.rs b/examples/binds.rs index 82bf89640f..f3ce51ec1c 100644 --- a/examples/binds.rs +++ b/examples/binds.rs @@ -13,10 +13,12 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965)] const APP: () = { #[init] - fn init(_: init::Context) { + fn init(_: init::Context) -> init::LateResources { rtic::pend(Interrupt::UART0); hprintln!("init").unwrap(); + + init::LateResources {} } #[idle] diff --git a/examples/capacity.rs b/examples/capacity.rs index 00cec34459..cac0029cc1 100644 --- a/examples/capacity.rs +++ b/examples/capacity.rs @@ -12,8 +12,10 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965)] const APP: () = { #[init] - fn init(_: init::Context) { + fn init(_: init::Context) -> init::LateResources { rtic::pend(Interrupt::UART0); + + init::LateResources {} } #[task(binds = UART0, spawn = [foo, bar])] diff --git a/examples/cfg.rs b/examples/cfg.rs index 8eeeb2a93a..4f46724761 100644 --- a/examples/cfg.rs +++ b/examples/cfg.rs @@ -19,9 +19,11 @@ const APP: () = { } #[init(spawn = [foo])] - fn init(cx: init::Context) { + fn init(cx: init::Context) -> init::LateResources { cx.spawn.foo().unwrap(); cx.spawn.foo().unwrap(); + + init::LateResources {} } #[idle] diff --git a/examples/destructure.rs b/examples/destructure.rs index 1756bd9e75..ad1d859405 100644 --- a/examples/destructure.rs +++ b/examples/destructure.rs @@ -22,9 +22,11 @@ const APP: () = { } #[init] - fn init(_: init::Context) { + fn init(_: init::Context) -> init::LateResources { rtic::pend(Interrupt::UART0); rtic::pend(Interrupt::UART1); + + init::LateResources {} } // Direct destructure diff --git a/examples/generics.rs b/examples/generics.rs index 40ab81ac75..65c5db02a0 100644 --- a/examples/generics.rs +++ b/examples/generics.rs @@ -18,9 +18,11 @@ const APP: () = { } #[init] - fn init(_: init::Context) { + fn init(_: init::Context) -> init::LateResources { rtic::pend(Interrupt::UART0); rtic::pend(Interrupt::UART1); + + init::LateResources {} } #[task(binds = UART0, resources = [shared])] diff --git a/examples/hardware.rs b/examples/hardware.rs index 8105a7420d..30de77ab66 100644 --- a/examples/hardware.rs +++ b/examples/hardware.rs @@ -12,12 +12,14 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965)] const APP: () = { #[init] - fn init(_: init::Context) { + fn init(_: init::Context) -> init::LateResources { // Pends the UART0 interrupt but its handler won't run until *after* // `init` returns because interrupts are disabled rtic::pend(Interrupt::UART0); // equivalent to NVIC::pend hprintln!("init").unwrap(); + + init::LateResources {} } #[idle] diff --git a/examples/idle.rs b/examples/idle.rs index 3d28dac8a7..b029fcae27 100644 --- a/examples/idle.rs +++ b/examples/idle.rs @@ -11,8 +11,10 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965)] const APP: () = { #[init] - fn init(_: init::Context) { + fn init(_: init::Context) -> init::LateResources { hprintln!("init").unwrap(); + + init::LateResources {} } #[idle] diff --git a/examples/init.rs b/examples/init.rs index 315969f045..d5cebbaaa1 100644 --- a/examples/init.rs +++ b/examples/init.rs @@ -11,7 +11,7 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965, peripherals = true)] const APP: () = { #[init] - fn init(cx: init::Context) { + fn init(cx: init::Context) -> init::LateResources { static mut X: u32 = 0; // Cortex-M peripherals @@ -26,5 +26,7 @@ const APP: () = { hprintln!("init").unwrap(); debug::exit(debug::EXIT_SUCCESS); + + init::LateResources {} } }; diff --git a/examples/lock.rs b/examples/lock.rs index 5e3bce2500..ff947c5360 100644 --- a/examples/lock.rs +++ b/examples/lock.rs @@ -17,8 +17,10 @@ const APP: () = { } #[init] - fn init(_: init::Context) { + fn init(_: init::Context) -> init::LateResources { rtic::pend(Interrupt::GPIOA); + + init::LateResources {} } // when omitted priority is assumed to be `1` diff --git a/examples/message.rs b/examples/message.rs index 596f244904..a1352c0e8a 100644 --- a/examples/message.rs +++ b/examples/message.rs @@ -11,8 +11,10 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965)] const APP: () = { #[init(spawn = [foo])] - fn init(c: init::Context) { + fn init(c: init::Context) -> init::LateResources { c.spawn.foo(/* no message */).unwrap(); + + init::LateResources {} } #[task(spawn = [bar])] diff --git a/examples/not-send.rs b/examples/not-send.rs index 16a874dc0f..999abfaff4 100644 --- a/examples/not-send.rs +++ b/examples/not-send.rs @@ -23,9 +23,11 @@ const APP: () = { } #[init(spawn = [baz, quux])] - fn init(c: init::Context) { + fn init(c: init::Context) -> init::LateResources { c.spawn.baz().unwrap(); c.spawn.quux().unwrap(); + + init::LateResources {} } #[task(spawn = [bar])] diff --git a/examples/not-sync.rs b/examples/not-sync.rs index a7eaac8e7f..5a67489fa4 100644 --- a/examples/not-sync.rs +++ b/examples/not-sync.rs @@ -22,8 +22,10 @@ const APP: () = { } #[init] - fn init(_: init::Context) { + fn init(_: init::Context) -> init::LateResources { debug::exit(debug::EXIT_SUCCESS); + + init::LateResources {} } #[task(resources = [&shared])] diff --git a/examples/periodic.rs b/examples/periodic.rs index 405346e390..da56d468a8 100644 --- a/examples/periodic.rs +++ b/examples/periodic.rs @@ -15,10 +15,12 @@ const PERIOD: u32 = 8_000_000; #[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)] const APP: () = { #[init(schedule = [foo])] - fn init(cx: init::Context) { + fn init(cx: init::Context) -> init::LateResources { // omitted: initialization of `CYCCNT` cx.schedule.foo(cx.start + PERIOD.cycles()).unwrap(); + + init::LateResources {} } #[task(schedule = [foo])] diff --git a/examples/peripherals-taken.rs b/examples/peripherals-taken.rs index cd4ba0f0ed..42ad8c0fcb 100644 --- a/examples/peripherals-taken.rs +++ b/examples/peripherals-taken.rs @@ -9,8 +9,10 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965)] const APP: () = { #[init] - fn main(_: main::Context) { + fn main(_: main::Context) -> main::LateResources { assert!(cortex_m::Peripherals::take().is_none()); debug::exit(debug::EXIT_SUCCESS); + + main::LateResources {} } }; diff --git a/examples/pool.rs b/examples/pool.rs index 824d5bd86b..9fccdf8449 100644 --- a/examples/pool.rs +++ b/examples/pool.rs @@ -20,13 +20,15 @@ pool!(P: [u8; 128]); #[app(device = lm3s6965)] const APP: () = { #[init] - fn init(_: init::Context) { + fn init(_: init::Context) -> init::LateResources { static mut MEMORY: [u8; 512] = [0; 512]; // Increase the capacity of the memory pool by ~4 P::grow(MEMORY); rtic::pend(Interrupt::I2C0); + + init::LateResources {} } #[task(binds = I2C0, priority = 2, spawn = [foo, bar])] diff --git a/examples/preempt.rs b/examples/preempt.rs index 3cb11029b4..7103b17be2 100644 --- a/examples/preempt.rs +++ b/examples/preempt.rs @@ -11,8 +11,10 @@ use rtic::app; #[app(device = lm3s6965)] const APP: () = { #[init] - fn init(_: init::Context) { + fn init(_: init::Context) -> init::LateResources { rtic::pend(Interrupt::GPIOA); + + init::LateResources {} } #[task(binds = GPIOA, priority = 1)] diff --git a/examples/ramfunc.rs b/examples/ramfunc.rs index 1f95d496ef..214b7e6772 100644 --- a/examples/ramfunc.rs +++ b/examples/ramfunc.rs @@ -11,8 +11,10 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965)] const APP: () = { #[init(spawn = [bar])] - fn init(c: init::Context) { + fn init(c: init::Context) -> init::LateResources { c.spawn.bar().unwrap(); + + init::LateResources {} } #[inline(never)] diff --git a/examples/resource.rs b/examples/resource.rs index 2361fd0033..06aa975677 100644 --- a/examples/resource.rs +++ b/examples/resource.rs @@ -18,9 +18,11 @@ const APP: () = { } #[init] - fn init(_: init::Context) { + fn init(_: init::Context) -> init::LateResources { rtic::pend(Interrupt::UART0); rtic::pend(Interrupt::UART1); + + init::LateResources {} } // `shared` cannot be accessed from this context diff --git a/examples/schedule.rs b/examples/schedule.rs index 70a7a5e328..b76d9e7f81 100644 --- a/examples/schedule.rs +++ b/examples/schedule.rs @@ -14,7 +14,7 @@ use rtic::cyccnt::{Instant, U32Ext as _}; #[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)] const APP: () = { #[init(schedule = [foo, bar])] - fn init(mut cx: init::Context) { + fn init(mut cx: init::Context) -> init::LateResources { // Initialize (enable) the monotonic timer (CYCCNT) cx.core.DCB.enable_trace(); // required on Cortex-M7 devices that software lock the DWT (e.g. STM32F7) @@ -32,6 +32,8 @@ const APP: () = { // Schedule `bar` to run 4e6 cycles in the future cx.schedule.bar(now + 4_000_000.cycles()).unwrap(); + + init::LateResources {} } #[task] diff --git a/examples/shared-with-init.rs b/examples/shared-with-init.rs index bd55f7efd5..fa900a262d 100644 --- a/examples/shared-with-init.rs +++ b/examples/shared-with-init.rs @@ -20,12 +20,14 @@ const APP: () = { } #[init(resources = [shared])] - fn init(c: init::Context) { + fn init(c: init::Context) -> init::LateResources { // this `message` will be sent to task `UART0` let message = MustBeSend; *c.resources.shared = Some(message); rtic::pend(Interrupt::UART0); + + init::LateResources {} } #[task(binds = UART0, resources = [shared])] diff --git a/examples/t-binds.rs b/examples/t-binds.rs index 588ac46fa6..edf0fc6991 100644 --- a/examples/t-binds.rs +++ b/examples/t-binds.rs @@ -10,7 +10,9 @@ use panic_halt as _; #[rtic::app(device = lm3s6965)] const APP: () = { #[init] - fn init(_: init::Context) {} + fn init(_: init::Context) -> init::LateResources { + init::LateResources {} + } // Cortex-M exception #[task(binds = SVCall)] diff --git a/examples/t-cfg.rs b/examples/t-cfg.rs index b6c9e47207..254cb8e026 100644 --- a/examples/t-cfg.rs +++ b/examples/t-cfg.rs @@ -14,9 +14,11 @@ const APP: () = { } #[init] - fn init(_: init::Context) { + fn init(_: init::Context) -> init::LateResources { #[cfg(never)] static mut BAR: u32 = 0; + + init::LateResources {} } #[idle] diff --git a/examples/t-htask-main.rs b/examples/t-htask-main.rs index c4bebf94dc..885019a179 100644 --- a/examples/t-htask-main.rs +++ b/examples/t-htask-main.rs @@ -9,8 +9,10 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965)] const APP: () = { #[init] - fn init(_: init::Context) { - rtic::pend(lm3s6965::Interrupt::UART0) + fn init(_: init::Context) -> init::LateResources { + rtic::pend(lm3s6965::Interrupt::UART0); + + init::LateResources {} } #[task(binds = UART0)] diff --git a/examples/t-idle-main.rs b/examples/t-idle-main.rs index 051a9ee812..3e06cac65b 100644 --- a/examples/t-idle-main.rs +++ b/examples/t-idle-main.rs @@ -9,7 +9,9 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965)] const APP: () = { #[init] - fn init(_: init::Context) {} + fn init(_: init::Context) -> init::LateResources { + init::LateResources {} + } #[idle] fn main(_: main::Context) -> ! { diff --git a/examples/t-init-main.rs b/examples/t-init-main.rs index 6a6cd99164..f6c1d9cac3 100644 --- a/examples/t-init-main.rs +++ b/examples/t-init-main.rs @@ -9,7 +9,9 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965)] const APP: () = { #[init] - fn main(_: main::Context) { + fn main(_: main::Context) -> main::LateResources { debug::exit(debug::EXIT_SUCCESS); + + main::LateResources {} } }; diff --git a/examples/t-resource.rs b/examples/t-resource.rs index 81ba18563f..78e518c106 100644 --- a/examples/t-resource.rs +++ b/examples/t-resource.rs @@ -31,7 +31,7 @@ const APP: () = { } #[init(resources = [o1, o4, o5, o6, s3])] - fn init(c: init::Context) { + fn init(c: init::Context) -> init::LateResources { // owned by `init` == `&'static mut` let _: &'static mut u32 = c.resources.o1; @@ -42,6 +42,8 @@ const APP: () = { let _: &mut u32 = c.resources.o4; let _: &mut u32 = c.resources.o5; let _: &mut u32 = c.resources.s3; + + init::LateResources {} } #[idle(resources = [o2, &o4, s1, &s3])] diff --git a/examples/t-schedule.rs b/examples/t-schedule.rs index 3854aad36b..8af01abaa2 100644 --- a/examples/t-schedule.rs +++ b/examples/t-schedule.rs @@ -11,10 +11,12 @@ use rtic::cyccnt::{Instant, U32Ext as _}; #[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)] const APP: () = { #[init(schedule = [foo, bar, baz])] - fn init(c: init::Context) { + 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); + + init::LateResources {} } #[idle(schedule = [foo, bar, baz])] diff --git a/examples/t-spawn.rs b/examples/t-spawn.rs index 35831ccf9d..af2a79ea77 100644 --- a/examples/t-spawn.rs +++ b/examples/t-spawn.rs @@ -10,10 +10,12 @@ use panic_halt as _; #[rtic::app(device = lm3s6965)] const APP: () = { #[init(spawn = [foo, bar, baz])] - fn init(c: init::Context) { + 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::LateResources {} } #[idle(spawn = [foo, bar, baz])] diff --git a/examples/t-stask-main.rs b/examples/t-stask-main.rs index f270940454..aefd482164 100644 --- a/examples/t-stask-main.rs +++ b/examples/t-stask-main.rs @@ -9,8 +9,10 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965)] const APP: () = { #[init(spawn = [main])] - fn init(cx: init::Context) { + fn init(cx: init::Context) -> init::LateResources { cx.spawn.main().ok(); + + init::LateResources {} } #[task] diff --git a/examples/task.rs b/examples/task.rs index 12c4ac8355..e148b3560b 100644 --- a/examples/task.rs +++ b/examples/task.rs @@ -11,8 +11,10 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965)] const APP: () = { #[init(spawn = [foo])] - fn init(c: init::Context) { + fn init(c: init::Context) -> init::LateResources { c.spawn.foo().unwrap(); + + init::LateResources {} } #[task(spawn = [bar, baz])] diff --git a/examples/types.rs b/examples/types.rs index 5233f868b1..46d08b8395 100644 --- a/examples/types.rs +++ b/examples/types.rs @@ -17,7 +17,7 @@ const APP: () = { } #[init(schedule = [foo], spawn = [foo])] - fn init(cx: init::Context) { + fn init(cx: init::Context) -> init::LateResources { let _: cyccnt::Instant = cx.start; let _: rtic::Peripherals = cx.core; let _: lm3s6965::Peripherals = cx.device; @@ -25,6 +25,8 @@ const APP: () = { let _: init::Spawn = cx.spawn; debug::exit(debug::EXIT_SUCCESS); + + init::LateResources {} } #[idle(schedule = [foo], spawn = [foo])] diff --git a/macros/Cargo.toml b/macros/Cargo.toml index 610890bbfb..ec5c130c95 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 = { git = "https://github.com/rtic-rs/rtic-syntax", branch = "master", version = "0.4.0" } +rtic-syntax = { git = "https://github.com/rtic-rs/rtic-syntax", branch = "always_late_resources" } diff --git a/macros/src/codegen/init.rs b/macros/src/codegen/init.rs index e0b7d69972..b41c389489 100644 --- a/macros/src/codegen/init.rs +++ b/macros/src/codegen/init.rs @@ -34,39 +34,31 @@ pub fn codegen( let mut root_init = vec![]; - let ret = { - let late_fields = analysis - .late_resources - .iter() - .flat_map(|resources| { - resources.iter().map(|name| { - let ty = &app.late_resources[name].ty; - let cfgs = &app.late_resources[name].cfgs; + let late_fields = analysis + .late_resources + .iter() + .flat_map(|resources| { + resources.iter().map(|name| { + let ty = &app.late_resources[name].ty; + let cfgs = &app.late_resources[name].cfgs; - quote!( - #(#cfgs)* - pub #name: #ty - ) - }) + quote!( + #(#cfgs)* + pub #name: #ty + ) }) - .collect::>(); + }) + .collect::>(); - if !late_fields.is_empty() { - let late_resources = util::late_resources_ident(&name); + let late_resources = util::late_resources_ident(&name); - root_init.push(quote!( - /// Resources initialized at runtime - #[allow(non_snake_case)] - pub struct #late_resources { - #(#late_fields),* - } - )); - - Some(quote!(-> #name::LateResources)) - } else { - None + root_init.push(quote!( + /// Resources initialized at runtime + #[allow(non_snake_case)] + pub struct #late_resources { + #(#late_fields),* } - }; + )); let mut locals_pat = None; let mut locals_new = None; @@ -85,7 +77,7 @@ pub fn codegen( let user_init = Some(quote!( #(#attrs)* #[allow(non_snake_case)] - fn #name(#(#locals_pat,)* #context: #name::Context) #ret { + fn #name(#(#locals_pat,)* #context: #name::Context) -> #name::LateResources { #(#stmts)* } )); diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index 863f6c5b73..85bab3ab68 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -253,14 +253,12 @@ pub fn codegen(ctxt: Context, resources_tick: bool, app: &App, extra: &Extra) -> if let Context::Init = ctxt { let init = &app.inits.first().unwrap(); - if init.returns_late_resources { - let late_resources = util::late_resources_ident(&init.name); + let late_resources = util::late_resources_ident(&init.name); - items.push(quote!( - #[doc(inline)] - pub use super::#late_resources as LateResources; - )); - } + items.push(quote!( + #[doc(inline)] + pub use super::#late_resources as LateResources; + )); } let doc = match ctxt { From 9d2598dc071882a94b813ab1d9ddf49092546257 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Thu, 1 Oct 2020 20:14:07 +0200 Subject: [PATCH 06/20] Fixing test errors --- ui/single/locals-cfg.rs | 4 ++- ui/single/locals-cfg.stderr | 16 ++++++------ ui/single/resources-cfg.rs | 4 ++- ui/single/resources-cfg.stderr | 40 ++++++++++++++--------------- ui/single/task-priority-too-high.rs | 4 ++- 5 files changed, 37 insertions(+), 31 deletions(-) diff --git a/ui/single/locals-cfg.rs b/ui/single/locals-cfg.rs index 54bba8aefd..cd8677a94c 100644 --- a/ui/single/locals-cfg.rs +++ b/ui/single/locals-cfg.rs @@ -3,11 +3,13 @@ #[rtic::app(device = lm3s6965)] const APP: () = { #[init] - fn init(_: init::Context) { + fn init(_: init::Context) -> init::LateResources { #[cfg(never)] static mut FOO: u32 = 0; FOO; + + init::LateResources {} } #[idle] diff --git a/ui/single/locals-cfg.stderr b/ui/single/locals-cfg.stderr index bb558fa60e..dc104a698b 100644 --- a/ui/single/locals-cfg.stderr +++ b/ui/single/locals-cfg.stderr @@ -5,27 +5,27 @@ error[E0425]: cannot find value `FOO` in this scope | ^^^ not found in this scope error[E0425]: cannot find value `FOO` in this scope - --> $DIR/locals-cfg.rs:18:9 + --> $DIR/locals-cfg.rs:20:9 | -18 | FOO; +20 | FOO; | ^^^ not found in this scope error[E0425]: cannot find value `FOO` in this scope - --> $DIR/locals-cfg.rs:28:9 + --> $DIR/locals-cfg.rs:30:9 | -28 | FOO; +30 | FOO; | ^^^ not found in this scope error[E0425]: cannot find value `FOO` in this scope - --> $DIR/locals-cfg.rs:36:9 + --> $DIR/locals-cfg.rs:38:9 | -36 | FOO; +38 | FOO; | ^^^ not found in this scope error[E0425]: cannot find value `FOO` in this scope - --> $DIR/locals-cfg.rs:44:9 + --> $DIR/locals-cfg.rs:46:9 | -44 | FOO; +46 | FOO; | ^^^ not found in this scope error: duplicate lang item in crate `panic_halt`: `panic_impl`. diff --git a/ui/single/resources-cfg.rs b/ui/single/resources-cfg.rs index df7ac80605..bcb712082d 100644 --- a/ui/single/resources-cfg.rs +++ b/ui/single/resources-cfg.rs @@ -41,12 +41,14 @@ const APP: () = { } #[init(resources = [o1, o4, o5, o6, s3])] - fn init(c: init::Context) { + fn init(c: init::Context) -> init::LateResources { c.resources.o1; c.resources.o4; c.resources.o5; c.resources.o6; c.resources.s3; + + init::LateResources {} } #[idle(resources = [o2, &o4, s1, &s3])] diff --git a/ui/single/resources-cfg.stderr b/ui/single/resources-cfg.stderr index c47b95d4b9..68063693ab 100644 --- a/ui/single/resources-cfg.stderr +++ b/ui/single/resources-cfg.stderr @@ -39,81 +39,81 @@ error[E0609]: no field `s3` on type `initResources<'_>` = note: available fields are: `__marker__` error[E0609]: no field `o2` on type `idleResources<'_>` - --> $DIR/resources-cfg.rs:54:21 + --> $DIR/resources-cfg.rs:56:21 | -54 | c.resources.o2; +56 | c.resources.o2; | ^^ unknown field | = note: available fields are: `__marker__` error[E0609]: no field `o4` on type `idleResources<'_>` - --> $DIR/resources-cfg.rs:55:21 + --> $DIR/resources-cfg.rs:57:21 | -55 | c.resources.o4; +57 | c.resources.o4; | ^^ unknown field | = note: available fields are: `__marker__` error[E0609]: no field `s1` on type `idleResources<'_>` - --> $DIR/resources-cfg.rs:56:21 + --> $DIR/resources-cfg.rs:58:21 | -56 | c.resources.s1; +58 | c.resources.s1; | ^^ unknown field | = note: available fields are: `__marker__` error[E0609]: no field `s3` on type `idleResources<'_>` - --> $DIR/resources-cfg.rs:57:21 + --> $DIR/resources-cfg.rs:59:21 | -57 | c.resources.s3; +59 | c.resources.s3; | ^^ unknown field | = note: available fields are: `__marker__` error[E0609]: no field `o3` on type `uart0Resources<'_>` - --> $DIR/resources-cfg.rs:64:21 + --> $DIR/resources-cfg.rs:66:21 | -64 | c.resources.o3; +66 | c.resources.o3; | ^^ unknown field | = note: available fields are: `__marker__` error[E0609]: no field `s1` on type `uart0Resources<'_>` - --> $DIR/resources-cfg.rs:65:21 + --> $DIR/resources-cfg.rs:67:21 | -65 | c.resources.s1; +67 | c.resources.s1; | ^^ unknown field | = note: available fields are: `__marker__` error[E0609]: no field `s2` on type `uart0Resources<'_>` - --> $DIR/resources-cfg.rs:66:21 + --> $DIR/resources-cfg.rs:68:21 | -66 | c.resources.s2; +68 | c.resources.s2; | ^^ unknown field | = note: available fields are: `__marker__` error[E0609]: no field `s3` on type `uart0Resources<'_>` - --> $DIR/resources-cfg.rs:67:21 + --> $DIR/resources-cfg.rs:69:21 | -67 | c.resources.s3; +69 | c.resources.s3; | ^^ unknown field | = note: available fields are: `__marker__` error[E0609]: no field `s2` on type `uart1Resources<'_>` - --> $DIR/resources-cfg.rs:72:21 + --> $DIR/resources-cfg.rs:74:21 | -72 | c.resources.s2; +74 | c.resources.s2; | ^^ unknown field | = note: available fields are: `__marker__` error[E0609]: no field `o5` on type `uart1Resources<'_>` - --> $DIR/resources-cfg.rs:73:21 + --> $DIR/resources-cfg.rs:75:21 | -73 | c.resources.o5; +75 | c.resources.o5; | ^^ unknown field | = note: available fields are: `__marker__` diff --git a/ui/single/task-priority-too-high.rs b/ui/single/task-priority-too-high.rs index 539c3f5d0e..62e531d81d 100644 --- a/ui/single/task-priority-too-high.rs +++ b/ui/single/task-priority-too-high.rs @@ -5,7 +5,9 @@ use rtic::app; #[rtic::app(device = lm3s6965)] const APP: () = { #[init] - fn init(_: init::Context) {} + fn init(_: init::Context) -> init::LateResources { + init::LateResources {} + } #[task(binds = GPIOA, priority = 1)] fn gpioa(_: gpioa::Context) {} From 91c2d4850e31da1bbd49fc668ae79533e7ac3ab4 Mon Sep 17 00:00:00 2001 From: Daniel Carosone Date: Fri, 2 Oct 2020 19:56:17 +1000 Subject: [PATCH 07/20] Shared access is useful with interior mutability --- book/en/src/by-example/resources.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/book/en/src/by-example/resources.md b/book/en/src/by-example/resources.md index d67a72ff48..9831e55b3b 100644 --- a/book/en/src/by-example/resources.md +++ b/book/en/src/by-example/resources.md @@ -114,7 +114,9 @@ are required to access the resource even if the resource is contended by several tasks running at different priorities. The downside is that the task only gets a shared reference (`&-`) to the resource, limiting the operations it can perform on it, but where a shared reference is enough this approach reduces the number -of required locks. +of required locks. In addition to simple immutable data, this shared access can +be useful where the resource type safely implements interior mutability, with +appropriate locking or atomic operations of its own. Note that in this release of RTIC it is not possible to request both exclusive access (`&mut-`) and shared access (`&-`) to the *same* resource from different From 3d6a0ea64fb2661ee1150a84425f50c18c2de9ad Mon Sep 17 00:00:00 2001 From: Daniel Carosone Date: Fri, 2 Oct 2020 20:43:52 +1000 Subject: [PATCH 08/20] minor markdownlints --- book/en/src/by-example/resources.md | 2 +- book/en/src/by-example/tips.md | 1 + book/en/src/migration.md | 3 +-- book/en/src/migration_rtic.md | 4 ---- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/book/en/src/by-example/resources.md b/book/en/src/by-example/resources.md index 9831e55b3b..9b6e5a809f 100644 --- a/book/en/src/by-example/resources.md +++ b/book/en/src/by-example/resources.md @@ -1,4 +1,4 @@ -## Resources +# Resources The framework provides an abstraction to share data between any of the contexts we saw in the previous section (task handlers, `init` and `idle`): resources. diff --git a/book/en/src/by-example/tips.md b/book/en/src/by-example/tips.md index 5a44708865..98c1abbf1e 100644 --- a/book/en/src/by-example/tips.md +++ b/book/en/src/by-example/tips.md @@ -116,6 +116,7 @@ Here's an example where `heapless::Pool` is used to "box" buffers of 128 bytes. ``` rust {{#include ../../../../examples/pool.rs}} ``` + ``` console $ cargo run --example pool {{#include ../../../../ci/expected/pool.run}} diff --git a/book/en/src/migration.md b/book/en/src/migration.md index 6cca64dba4..d382db1724 100644 --- a/book/en/src/migration.md +++ b/book/en/src/migration.md @@ -8,7 +8,6 @@ the version v0.5.0 of the framework. First, the version of the `cortex-m-rtic` dependency needs to be updated to `"0.5.0"`. The `timer-queue` feature needs to be removed. - ``` toml [dependencies.cortex-m-rtic] # change this @@ -194,7 +193,7 @@ Also, the `Duration` and `Instant` types and the `U32Ext` trait have been moved into the `rtic::cyccnt` module. This module is only available on ARMv7-M+ devices. The removal of the `timer-queue` also brings back the `DWT` peripheral inside the core peripherals struct, this will need to be enabled by the application -inside `init`. +inside `init`. Change this: diff --git a/book/en/src/migration_rtic.md b/book/en/src/migration_rtic.md index 555f1bb710..c027da35fd 100644 --- a/book/en/src/migration_rtic.md +++ b/book/en/src/migration_rtic.md @@ -8,14 +8,11 @@ change. [RFC #33]: https://github.com/rtic-rs/rfcs/pull/33 - - ## `Cargo.toml` First, the `cortex-m-rtfm` dependency needs to be updated to `cortex-m-rtic`. - ``` toml [dependencies] # change this @@ -51,4 +48,3 @@ const APP: () = { }; ``` - From 3fed6a944e73e1a077d218f77c0957cfdd508688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Mon, 5 Oct 2020 10:07:43 +0000 Subject: [PATCH 09/20] Use a full copy of the book instead of symlink --- .github/workflows/build.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56183c3ac9..b6aed4e7fd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -586,6 +586,8 @@ jobs: stable=$(git tag | grep "^v" | grep -v "-" | tail -n 1 | cut -c2-4) vers=( 0.5.x 0.4.x ) + echo "Stable version: $stable" + # Create directories td=$(mktemp -d) mkdir -p $td/$devver/book/ @@ -630,8 +632,8 @@ jobs: rm -rf $src done - # Create alias for the stable release - ln -s $stable $td/stable + # Copy the stable book to the stable alias + cp -r $td/$stable $td/stable # Forward CNAME file cp CNAME $td/ From a38952fbd4f972c2016093a852a35aadc479ac72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Mon, 5 Oct 2020 10:44:57 +0000 Subject: [PATCH 10/20] Unable to use git for tags --- .github/workflows/build.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b6aed4e7fd..1d5773e458 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -579,13 +579,14 @@ jobs: run: | langs=( en ru ) devver=( dev ) - # Query git for tagged releases, all releases start with "v" - # followed by MAJOR.MINOR.PATCH, see semver.org - # Then remove all pre-releases/tags with hyphens (-). - # The latest release is last, finally trim "v" and PATCH - stable=$(git tag | grep "^v" | grep -v "-" | tail -n 1 | cut -c2-4) + # The latest stable must be the first element in the array vers=( 0.5.x 0.4.x ) + # All releases start with "v" + # followed by MAJOR.MINOR.PATCH, see semver.org + # Retain MAJOR.MINOR as $stable + stable=${vers%.*} + echo "Stable version: $stable" # Create directories From da1b31d95af9557020889917ea8a014091a44418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Mon, 5 Oct 2020 10:48:20 +0000 Subject: [PATCH 11/20] Also update for the deploy stage --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0f88c80d08..e64381f74e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -582,8 +582,7 @@ jobs: - name: mdBook Action uses: peaceiris/actions-mdbook@v1.1.11 with: - mdbook-version: '0.3.1' - # mdbook-version: 'latest' + mdbook-version: 'latest' - name: Remove cargo-config run: rm -f .cargo/config From 7261685b7fa3d555c29a4cd9f8dd208d985c182c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Mon, 5 Oct 2020 09:35:07 +0000 Subject: [PATCH 12/20] Separate example check and run-pass tests --- .github/workflows/build.yml | 49 ++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1d5773e458..e53672bc46 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -85,7 +85,7 @@ jobs: command: check args: --target=${{ matrix.target }} - # Verify all examples + # Verify all examples, checks checkexamples: name: checkexamples runs-on: ubuntu-20.04 @@ -140,6 +140,51 @@ jobs: command: check args: --examples --target=${{ matrix.target }} --features __min_r1_43,${{ env.V7 }} + # Verify the example output with run-pass tests + testexamples: + name: testexamples + runs-on: ubuntu-20.04 + strategy: + matrix: + target: + - thumbv7m-none-eabi + - thumbv6m-none-eabi + toolchain: + - stable + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Cache cargo dependencies + uses: actions/cache@v2 + with: + path: | + - ~/.cargo/bin/ + - ~/.cargo/registry/index/ + - ~/.cargo/registry/cache/ + - ~/.cargo/git/db/ + key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} + ${{ runner.OS }}-cargo- + + - name: Cache build output dependencies + uses: actions/cache@v2 + with: + path: target + key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} + ${{ runner.OS }}-build- + + - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + target: ${{ matrix.target }} + override: true + components: llvm-tools-preview + # Use precompiled binutils - name: cargo install cargo-binutils uses: actions-rs/install@v0.1 @@ -657,6 +702,7 @@ jobs: - style - check - checkexamples + - testexamples - checkmacros - testv7 - testv6 @@ -673,6 +719,7 @@ jobs: - style - check - checkexamples + - testexamples - checkmacros - testv7 - testv6 From c21ccd04ce52c5d469a2bdfd4e0125540ad1cddb Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Mon, 5 Oct 2020 18:30:06 +0200 Subject: [PATCH 13/20] Overwrite steerr files --- ui/single/locals-cfg.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/single/locals-cfg.stderr b/ui/single/locals-cfg.stderr index 63953fc9bc..e58bd935e3 100644 --- a/ui/single/locals-cfg.stderr +++ b/ui/single/locals-cfg.stderr @@ -31,7 +31,7 @@ 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/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-cf0f33af3a901778.rlib + = 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 error: duplicate lang item in crate `panic_semihosting`: `panic_impl`. From 44f26fe90c2b49f3a30c507bf930b6bedc283a9c Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Mon, 5 Oct 2020 20:05:52 +0200 Subject: [PATCH 14/20] Move to master of rtic-syntax --- macros/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macros/Cargo.toml b/macros/Cargo.toml index ec5c130c95..610890bbfb 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 = { git = "https://github.com/rtic-rs/rtic-syntax", branch = "always_late_resources" } +rtic-syntax = { git = "https://github.com/rtic-rs/rtic-syntax", branch = "master", version = "0.4.0" } From 8ab7be98714d1ef6298e6feb19f16b84cd9bb4e6 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Mon, 5 Oct 2020 20:19:52 +0200 Subject: [PATCH 15/20] Added back accidentally removed block --- macros/src/codegen/init.rs | 6 ++++++ macros/src/lib.rs | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/macros/src/codegen/init.rs b/macros/src/codegen/init.rs index 1ced68bccc..8942439bd7 100644 --- a/macros/src/codegen/init.rs +++ b/macros/src/codegen/init.rs @@ -63,6 +63,12 @@ pub fn codegen( } )); + let name_late = format_ident!("{}LateResources", name); + user_init_imports.push(quote!( + #[allow(non_snake_case)] + use super::#name_late; + )); + let mut locals_pat = None; let mut locals_new = None; if !init.locals.is_empty() { diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 94e7eec60c..e659559e9b 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -35,8 +35,7 @@ mod tests; /// /// The items allowed in the module block are specified below: /// -/// # 1. `#[resources] -/// struct ` +/// # 1. `#[resources] struct ` /// /// This structure contains the declaration of all the resources used by the application. Each field /// in this structure corresponds to a different resource. Each resource may optionally be given an From e17a1fc903c18eb4fcc1d2dd3f86d4ded830f3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Mon, 5 Oct 2020 18:37:21 +0000 Subject: [PATCH 16/20] Run the macro tests --- .github/workflows/build.yml | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e53672bc46..5a47a757c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -386,6 +386,56 @@ jobs: command: check args: --manifest-path macros/Cargo.toml --target=${{ matrix.target }} + # Run the macros test-suite + testmacros: + name: testmacros + runs-on: ubuntu-20.04 + strategy: + matrix: + target: + - x86_64-unknown-linux-gnu + toolchain: + - stable + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Cache cargo dependencies + uses: actions/cache@v2 + with: + path: | + - ~/.cargo/bin/ + - ~/.cargo/registry/index/ + - ~/.cargo/registry/cache/ + - ~/.cargo/git/db/ + key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} + ${{ runner.OS }}-cargo- + + - name: Cache build output dependencies + uses: actions/cache@v2 + with: + path: target + key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} + ${{ runner.OS }}-build- + + - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + target: ${{ matrix.target }} + override: true + + - name: cargo check + uses: actions-rs/cargo@v1 + with: + use-cross: false + command: test + args: --manifest-path macros/Cargo.toml --target=${{ matrix.target }} + # Run test suite for thumbv7m testv7: name: testv7 @@ -586,7 +636,9 @@ jobs: - style - check - checkexamples + - testexamples - checkmacros + - testmacros - testv7 - testv6 - docs @@ -704,6 +756,7 @@ jobs: - checkexamples - testexamples - checkmacros + - testmacros - testv7 - testv6 - docs @@ -721,6 +774,7 @@ jobs: - checkexamples - testexamples - checkmacros + - testmacros - testv7 - testv6 - docs From 71a279f6d0a2fa4f0e51d09eda47bd422a1b0240 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Mon, 5 Oct 2020 20:38:52 +0200 Subject: [PATCH 17/20] Split up migration guides into its own sections --- book/en/src/SUMMARY.md | 6 +- book/en/src/migration.md | 333 +----------------- book/en/src/{ => migration}/migration_rtic.md | 0 book/en/src/migration/migration_v4.md | 232 ++++++++++++ book/en/src/migration/migration_v5.md | 96 +++++ 5 files changed, 335 insertions(+), 332 deletions(-) rename book/en/src/{ => migration}/migration_rtic.md (100%) create mode 100644 book/en/src/migration/migration_v4.md create mode 100644 book/en/src/migration/migration_v5.md diff --git a/book/en/src/SUMMARY.md b/book/en/src/SUMMARY.md index a573cbb55a..e1a4a330c7 100644 --- a/book/en/src/SUMMARY.md +++ b/book/en/src/SUMMARY.md @@ -10,8 +10,10 @@ - [Types, Send and Sync](./by-example/types-send-sync.md) - [Starting a new project](./by-example/new.md) - [Tips & tricks](./by-example/tips.md) -- [Migrating from v0.4.x to v0.5.0](./migration.md) -- [Migrating from RTFM to RTIC](./migration_rtic.md) +- [Migration Guides](./migration.md) + - [v0.5.x to v0.6.x](./migration/migration_v5.md) + - [v0.4.x to v0.5.x](./migration/migration_v4.md) + - [RTFM to RTIC](./migration/migration_rtic.md) - [Under the hood](./internals.md) - [Interrupt configuration](./internals/interrupt-configuration.md) - [Non-reentrancy](./internals/non-reentrancy.md) diff --git a/book/en/src/migration.md b/book/en/src/migration.md index 7be30943c8..08feb81e1e 100644 --- a/book/en/src/migration.md +++ b/book/en/src/migration.md @@ -1,331 +1,4 @@ -# Migration of RTIC +# Migration Guides -## Migrating from v0.5.x to v0.6.0 - -This section describes how to upgrade from v0.5.x to v0.6.0 of the RTIC framework. - -### `Cargo.toml` - version bump - -Change the version of `cortex-m-rtic` to `"0.6.0"`. - -### Module instead of Const - -With the support of attributes on modules the `const APP` workaround is not needed. - -Change - -``` rust -#[rtic::app(/* .. */)] -const APP: () = { - [code here] -}; -``` - -into - -``` rust -#[rtic::app(/* .. */)] -mod app { - [code here] -} -``` - -Now that a regular Rust module is used it means it is possible to have custom -user code within that module. -Additionally, it means that `use`-statements for resources etc may be required. - -### Init always returns late resources - -In order to make the API more symmetric the #[init]-task always returns a late resource. - -From this: - -``` rust -#[rtic::app(device = lm3s6965)] -mod app { - #[init] - fn init(_: init::Context) { - rtic::pend(Interrupt::UART0); - } - [more code] -} -``` - -to this: - -``` rust -#[rtic::app(device = lm3s6965)] -mod app { - #[init] - fn init(_: init::Context) -> init::LateResources { - rtic::pend(Interrupt::UART0); - - init::LateResources {} - } - [more code] -} -``` - -### Resources struct - #[resources] - -Previously the RTIC resources had to be in in a struct named exactly "Resources": - -``` rust -struct Resources { - // Resources defined in here -} -``` - -With RTIC v0.6.0 the resources struct is annotated similarly like -`#[task]`, `#[init]`, `#[idle]`: with an attribute `#[resources]` - -``` rust -#[resources] -struct Resources { - // Resources defined in here -} -``` - -In fact, the name of the struct is now up to the developer: - -``` rust -#[resources] -struct whateveryouwant { - // Resources defined in here -} -``` - -would work equally well. - -## Migrating from v0.4.x to v0.5.0 - -This section covers how to upgrade an application written against RTIC v0.4.x to -the version v0.5.0 of the framework. - -### `Cargo.toml` - -First, the version of the `cortex-m-rtic` dependency needs to be updated to -`"0.5.0"`. The `timer-queue` feature needs to be removed. - -``` toml -[dependencies.cortex-m-rtic] -# change this -version = "0.4.3" - -# into this -version = "0.5.0" - -# and remove this Cargo feature -features = ["timer-queue"] -# ^^^^^^^^^^^^^ -``` - -### `Context` argument - -All functions inside the `#[rtic::app]` item need to take as first argument a -`Context` structure. This `Context` type will contain the variables that were -magically injected into the scope of the function by version v0.4.x of the -framework: `resources`, `spawn`, `schedule` -- these variables will become -fields of the `Context` structure. Each function within the `#[rtic::app]` item -gets a different `Context` type. - -``` rust -#[rtic::app(/* .. */)] -const APP: () = { - // change this - #[task(resources = [x], spawn = [a], schedule = [b])] - fn foo() { - resources.x.lock(|x| /* .. */); - spawn.a(message); - schedule.b(baseline); - } - - // into this - #[task(resources = [x], spawn = [a], schedule = [b])] - fn foo(mut cx: foo::Context) { - // ^^^^^^^^^^^^^^^^^^^^ - - cx.resources.x.lock(|x| /* .. */); - // ^^^ - - cx.spawn.a(message); - // ^^^ - - cx.schedule.b(message, baseline); - // ^^^ - } - - // change this - #[init] - fn init() { - // .. - } - - // into this - #[init] - fn init(cx: init::Context) { - // ^^^^^^^^^^^^^^^^^ - // .. - } - - // .. -}; -``` - -### Resources - -The syntax used to declare resources has been changed from `static mut` -variables to a `struct Resources`. - -``` rust -#[rtic::app(/* .. */)] -const APP: () = { - // change this - static mut X: u32 = 0; - static mut Y: u32 = (); // late resource - - // into this - struct Resources { - #[init(0)] // <- initial value - X: u32, // NOTE: we suggest changing the naming style to `snake_case` - - Y: u32, // late resource - } - - // .. -}; -``` - -### Device peripherals - -If your application was accessing the device peripherals in `#[init]` through -the `device` variable then you'll need to add `peripherals = true` to the -`#[rtic::app]` attribute to continue to access the device peripherals through -the `device` field of the `init::Context` structure. - -Change this: - -``` rust -#[rtic::app(/* .. */)] -const APP: () = { - #[init] - fn init() { - device.SOME_PERIPHERAL.write(something); - } - - // .. -}; -``` - -Into this: - -``` rust -#[rtic::app(/* .. */, peripherals = true)] -// ^^^^^^^^^^^^^^^^^^ -const APP: () = { - #[init] - fn init(cx: init::Context) { - // ^^^^^^^^^^^^^^^^^ - cx.device.SOME_PERIPHERAL.write(something); - // ^^^ - } - - // .. -}; -``` - -### `#[interrupt]` and `#[exception]` - -The `#[interrupt]` and `#[exception]` attributes have been removed. To declare -hardware tasks in v0.5.x use the `#[task]` attribute with the `binds` argument. - -Change this: - -``` rust -#[rtic::app(/* .. */)] -const APP: () = { - // hardware tasks - #[exception] - fn SVCall() { /* .. */ } - - #[interrupt] - fn UART0() { /* .. */ } - - // software task - #[task] - fn foo() { /* .. */ } - - // .. -}; -``` - -Into this: - -``` rust -#[rtic::app(/* .. */)] -const APP: () = { - #[task(binds = SVCall)] - // ^^^^^^^^^^^^^^ - fn svcall(cx: svcall::Context) { /* .. */ } - // ^^^^^^ we suggest you use a `snake_case` name here - - #[task(binds = UART0)] - // ^^^^^^^^^^^^^ - fn uart0(cx: uart0::Context) { /* .. */ } - - #[task] - fn foo(cx: foo::Context) { /* .. */ } - - // .. -}; -``` - -### `schedule` - -The `timer-queue` feature has been removed. To use the `schedule` API one must -first define the monotonic timer the runtime will use using the `monotonic` -argument of the `#[rtic::app]` attribute. To continue using the cycle counter -(CYCCNT) as the monotonic timer, and match the behavior of version v0.4.x, add -the `monotonic = rtic::cyccnt::CYCCNT` argument to the `#[rtic::app]` attribute. - -Also, the `Duration` and `Instant` types and the `U32Ext` trait have been moved -into the `rtic::cyccnt` module. This module is only available on ARMv7-M+ -devices. The removal of the `timer-queue` also brings back the `DWT` peripheral -inside the core peripherals struct, this will need to be enabled by the application -inside `init`. - -Change this: - -``` rust -use rtic::{Duration, Instant, U32Ext}; - -#[rtic::app(/* .. */)] -const APP: () = { - #[task(schedule = [b])] - fn a() { - // .. - } -}; -``` - -Into this: - -``` rust -use rtic::cyccnt::{Duration, Instant, U32Ext}; -// ^^^^^^^^ - -#[rtic::app(/* .. */, monotonic = rtic::cyccnt::CYCCNT)] -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -const APP: () = { - #[init] - fn init(cx: init::Context) { - cx.core.DWT.enable_cycle_counter(); - // optional, configure the DWT run without a debugger connected - cx.core.DCB.enable_trace(); - } - #[task(schedule = [b])] - fn a(cx: a::Context) { - // .. - } -}; -``` +This section describes how to migrate between different version of RTIC. +It also acts as a comparing reference between versions. diff --git a/book/en/src/migration_rtic.md b/book/en/src/migration/migration_rtic.md similarity index 100% rename from book/en/src/migration_rtic.md rename to book/en/src/migration/migration_rtic.md diff --git a/book/en/src/migration/migration_v4.md b/book/en/src/migration/migration_v4.md new file mode 100644 index 0000000000..2c4e3ade6f --- /dev/null +++ b/book/en/src/migration/migration_v4.md @@ -0,0 +1,232 @@ +# Migrating from v0.4.x to v0.5.0 + +This section covers how to upgrade an application written against RTIC v0.4.x to +the version v0.5.0 of the framework. + +### `Cargo.toml` + +First, the version of the `cortex-m-rtic` dependency needs to be updated to +`"0.5.0"`. The `timer-queue` feature needs to be removed. + +``` toml +[dependencies.cortex-m-rtic] +# change this +version = "0.4.3" + +# into this +version = "0.5.0" + +# and remove this Cargo feature +features = ["timer-queue"] +# ^^^^^^^^^^^^^ +``` + +### `Context` argument + +All functions inside the `#[rtic::app]` item need to take as first argument a +`Context` structure. This `Context` type will contain the variables that were +magically injected into the scope of the function by version v0.4.x of the +framework: `resources`, `spawn`, `schedule` -- these variables will become +fields of the `Context` structure. Each function within the `#[rtic::app]` item +gets a different `Context` type. + +``` rust +#[rtic::app(/* .. */)] +const APP: () = { + // change this + #[task(resources = [x], spawn = [a], schedule = [b])] + fn foo() { + resources.x.lock(|x| /* .. */); + spawn.a(message); + schedule.b(baseline); + } + + // into this + #[task(resources = [x], spawn = [a], schedule = [b])] + fn foo(mut cx: foo::Context) { + // ^^^^^^^^^^^^^^^^^^^^ + + cx.resources.x.lock(|x| /* .. */); + // ^^^ + + cx.spawn.a(message); + // ^^^ + + cx.schedule.b(message, baseline); + // ^^^ + } + + // change this + #[init] + fn init() { + // .. + } + + // into this + #[init] + fn init(cx: init::Context) { + // ^^^^^^^^^^^^^^^^^ + // .. + } + + // .. +}; +``` + +### Resources + +The syntax used to declare resources has been changed from `static mut` +variables to a `struct Resources`. + +``` rust +#[rtic::app(/* .. */)] +const APP: () = { + // change this + static mut X: u32 = 0; + static mut Y: u32 = (); // late resource + + // into this + struct Resources { + #[init(0)] // <- initial value + X: u32, // NOTE: we suggest changing the naming style to `snake_case` + + Y: u32, // late resource + } + + // .. +}; +``` + +### Device peripherals + +If your application was accessing the device peripherals in `#[init]` through +the `device` variable then you'll need to add `peripherals = true` to the +`#[rtic::app]` attribute to continue to access the device peripherals through +the `device` field of the `init::Context` structure. + +Change this: + +``` rust +#[rtic::app(/* .. */)] +const APP: () = { + #[init] + fn init() { + device.SOME_PERIPHERAL.write(something); + } + + // .. +}; +``` + +Into this: + +``` rust +#[rtic::app(/* .. */, peripherals = true)] +// ^^^^^^^^^^^^^^^^^^ +const APP: () = { + #[init] + fn init(cx: init::Context) { + // ^^^^^^^^^^^^^^^^^ + cx.device.SOME_PERIPHERAL.write(something); + // ^^^ + } + + // .. +}; +``` + +### `#[interrupt]` and `#[exception]` + +The `#[interrupt]` and `#[exception]` attributes have been removed. To declare +hardware tasks in v0.5.x use the `#[task]` attribute with the `binds` argument. + +Change this: + +``` rust +#[rtic::app(/* .. */)] +const APP: () = { + // hardware tasks + #[exception] + fn SVCall() { /* .. */ } + + #[interrupt] + fn UART0() { /* .. */ } + + // software task + #[task] + fn foo() { /* .. */ } + + // .. +}; +``` + +Into this: + +``` rust +#[rtic::app(/* .. */)] +const APP: () = { + #[task(binds = SVCall)] + // ^^^^^^^^^^^^^^ + fn svcall(cx: svcall::Context) { /* .. */ } + // ^^^^^^ we suggest you use a `snake_case` name here + + #[task(binds = UART0)] + // ^^^^^^^^^^^^^ + fn uart0(cx: uart0::Context) { /* .. */ } + + #[task] + fn foo(cx: foo::Context) { /* .. */ } + + // .. +}; +``` + +### `schedule` + +The `timer-queue` feature has been removed. To use the `schedule` API one must +first define the monotonic timer the runtime will use using the `monotonic` +argument of the `#[rtic::app]` attribute. To continue using the cycle counter +(CYCCNT) as the monotonic timer, and match the behavior of version v0.4.x, add +the `monotonic = rtic::cyccnt::CYCCNT` argument to the `#[rtic::app]` attribute. + +Also, the `Duration` and `Instant` types and the `U32Ext` trait have been moved +into the `rtic::cyccnt` module. This module is only available on ARMv7-M+ +devices. The removal of the `timer-queue` also brings back the `DWT` peripheral +inside the core peripherals struct, this will need to be enabled by the application +inside `init`. + +Change this: + +``` rust +use rtic::{Duration, Instant, U32Ext}; + +#[rtic::app(/* .. */)] +const APP: () = { + #[task(schedule = [b])] + fn a() { + // .. + } +}; +``` + +Into this: + +``` rust +use rtic::cyccnt::{Duration, Instant, U32Ext}; +// ^^^^^^^^ + +#[rtic::app(/* .. */, monotonic = rtic::cyccnt::CYCCNT)] +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +const APP: () = { + #[init] + fn init(cx: init::Context) { + cx.core.DWT.enable_cycle_counter(); + // optional, configure the DWT run without a debugger connected + cx.core.DCB.enable_trace(); + } + #[task(schedule = [b])] + fn a(cx: a::Context) { + // .. + } +}; +``` diff --git a/book/en/src/migration/migration_v5.md b/book/en/src/migration/migration_v5.md new file mode 100644 index 0000000000..749ddecdba --- /dev/null +++ b/book/en/src/migration/migration_v5.md @@ -0,0 +1,96 @@ +# Migrating from v0.5.x to v0.6.0 + +This section describes how to upgrade from v0.5.x to v0.6.0 of the RTIC framework. + +### `Cargo.toml` - version bump + +Change the version of `cortex-m-rtic` to `"0.6.0"`. + +### Module instead of Const + +With the support of attributes on modules the `const APP` workaround is not needed. + +Change + +``` rust +#[rtic::app(/* .. */)] +const APP: () = { + [code here] +}; +``` + +into + +``` rust +#[rtic::app(/* .. */)] +mod app { + [code here] +} +``` + +Now that a regular Rust module is used it means it is possible to have custom +user code within that module. +Additionally, it means that `use`-statements for resources etc may be required. + +### Init always returns late resources + +In order to make the API more symmetric the #[init]-task always returns a late resource. + +From this: + +``` rust +#[rtic::app(device = lm3s6965)] +mod app { + #[init] + fn init(_: init::Context) { + rtic::pend(Interrupt::UART0); + } + [more code] +} +``` + +to this: + +``` rust +#[rtic::app(device = lm3s6965)] +mod app { + #[init] + fn init(_: init::Context) -> init::LateResources { + rtic::pend(Interrupt::UART0); + + init::LateResources {} + } + [more code] +} +``` + +### Resources struct - #[resources] + +Previously the RTIC resources had to be in in a struct named exactly "Resources": + +``` rust +struct Resources { + // Resources defined in here +} +``` + +With RTIC v0.6.0 the resources struct is annotated similarly like +`#[task]`, `#[init]`, `#[idle]`: with an attribute `#[resources]` + +``` rust +#[resources] +struct Resources { + // Resources defined in here +} +``` + +In fact, the name of the struct is now up to the developer: + +``` rust +#[resources] +struct whateveryouwant { + // Resources defined in here +} +``` + +would work equally well. From a091727e374dd20b1bc0cb3c0b95a92c2b09afc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Tue, 6 Oct 2020 18:04:22 +0000 Subject: [PATCH 18/20] Restore links to docs --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 3b3a471661..18f968dbb2 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,10 @@ Formerly known as Real-Time For the Masses. - Applications must be written using the 2018 edition. +## [User documentation](https://rtic.rs) + +## [API reference](https://rtic.rs/0.5/api/) + ## Chat Join us and talk about RTIC in the [Matrix room][matrix-room]. From f229d2e97fcb8444c1471d0e04e0e17abf4a7db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Tue, 6 Oct 2020 18:48:37 +0000 Subject: [PATCH 19/20] Fix MD-lints, add Matrix and meeting notes badges --- README.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 18f968dbb2..929a813c20 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,9 @@ Formerly known as Real-Time For the Masses. [![crates.io](https://img.shields.io/crates/v/cortex-m-rtic)](https://crates.io/crates/cortex-m-rtic) [![docs.rs](https://docs.rs/cortex-m-rtic/badge.svg)](https://docs.rs/cortex-m-rtic) [![book](https://img.shields.io/badge/web-rtic.rs-red.svg?style=flat&label=book&colorB=d33847)](https://rtic.rs/) -![rustc](https://img.shields.io/badge/rustc-1.36+-lightgray.svg) +[![rustc](https://img.shields.io/badge/rustc-1.36+-lightgray.svg)](https://github.com/rust-lang/rust/releases/tag/1.36.0) +[![matrix](https://img.shields.io/matrix/rtic:matrix.org)](https://matrix.to/#/#rtic:matrix.org) +[![Meeting notes](https://hackmd.io/badge.svg)](https://hackmd.io/@xmis9JvZT8Gvo9lOEKyZ4Q/SkBJKsjuH) ## Features @@ -52,23 +54,29 @@ Formerly known as Real-Time For the Masses. ## [User documentation](https://rtic.rs) -## [API reference](https://rtic.rs/0.5/api/) +## [API reference](https://rtic.rs/stable/api/) ## Chat + Join us and talk about RTIC in the [Matrix room][matrix-room]. +Weekly meeting notes can be found over at [HackMD][hackmd] + [matrix-room]: https://matrix.to/#/#rtic:matrix.org +[hackmd]: https://hackmd.io/@xmis9JvZT8Gvo9lOEKyZ4Q/SkBJKsjuH ## Contributing -New features and big changes should go through the RFC process in the [dedicated RFC repository][rfcs]. + +New features and big changes should go through the RFC process in the +[dedicated RFC repository][rfcs]. [rfcs]: https://github.com/rtic-rs/rfcs ## Acknowledgments -This crate is based on [the Real-Time For the Masses language][rtfm-lang] created by the Embedded -Systems group at [LuleƄ University of Technology][ltu], led by [Prof. Per -Lindgren][per]. +This crate is based on [the Real-Time For the Masses language][rtfm-lang] +created by the Embedded Systems group at [LuleƄ University of Technology][ltu], +led by [Prof. Per Lindgren][per]. [rtfm-lang]: http://www.rtfm-lang.org/ [ltu]: https://www.ltu.se/?l=en From 987332b831761a681ec5cdda192ead524438df77 Mon Sep 17 00:00:00 2001 From: Daniel Carosone Date: Wed, 7 Oct 2020 09:31:30 +1100 Subject: [PATCH 20/20] minor md lints and wording clarification --- book/en/src/migration/migration_v4.md | 15 ++++++++------- book/en/src/migration/migration_v5.md | 8 ++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/book/en/src/migration/migration_v4.md b/book/en/src/migration/migration_v4.md index 2c4e3ade6f..ac59d8c9fb 100644 --- a/book/en/src/migration/migration_v4.md +++ b/book/en/src/migration/migration_v4.md @@ -3,7 +3,7 @@ This section covers how to upgrade an application written against RTIC v0.4.x to the version v0.5.0 of the framework. -### `Cargo.toml` +## `Cargo.toml` First, the version of the `cortex-m-rtic` dependency needs to be updated to `"0.5.0"`. The `timer-queue` feature needs to be removed. @@ -21,7 +21,7 @@ features = ["timer-queue"] # ^^^^^^^^^^^^^ ``` -### `Context` argument +## `Context` argument All functions inside the `#[rtic::app]` item need to take as first argument a `Context` structure. This `Context` type will contain the variables that were @@ -73,7 +73,7 @@ const APP: () = { }; ``` -### Resources +## Resources The syntax used to declare resources has been changed from `static mut` variables to a `struct Resources`. @@ -97,7 +97,7 @@ const APP: () = { }; ``` -### Device peripherals +## Device peripherals If your application was accessing the device peripherals in `#[init]` through the `device` variable then you'll need to add `peripherals = true` to the @@ -135,7 +135,7 @@ const APP: () = { }; ``` -### `#[interrupt]` and `#[exception]` +## `#[interrupt]` and `#[exception]` The `#[interrupt]` and `#[exception]` attributes have been removed. To declare hardware tasks in v0.5.x use the `#[task]` attribute with the `binds` argument. @@ -181,9 +181,10 @@ const APP: () = { }; ``` -### `schedule` +## `schedule` -The `timer-queue` feature has been removed. To use the `schedule` API one must +The `schedule` API no longer requires the `timer-queue` cargo feature, which has +been removed. To use the `schedule` API one must first define the monotonic timer the runtime will use using the `monotonic` argument of the `#[rtic::app]` attribute. To continue using the cycle counter (CYCCNT) as the monotonic timer, and match the behavior of version v0.4.x, add diff --git a/book/en/src/migration/migration_v5.md b/book/en/src/migration/migration_v5.md index 749ddecdba..1d83444e09 100644 --- a/book/en/src/migration/migration_v5.md +++ b/book/en/src/migration/migration_v5.md @@ -2,11 +2,11 @@ This section describes how to upgrade from v0.5.x to v0.6.0 of the RTIC framework. -### `Cargo.toml` - version bump +## `Cargo.toml` - version bump Change the version of `cortex-m-rtic` to `"0.6.0"`. -### Module instead of Const +## Module instead of Const With the support of attributes on modules the `const APP` workaround is not needed. @@ -32,7 +32,7 @@ Now that a regular Rust module is used it means it is possible to have custom user code within that module. Additionally, it means that `use`-statements for resources etc may be required. -### Init always returns late resources +## Init always returns late resources In order to make the API more symmetric the #[init]-task always returns a late resource. @@ -64,7 +64,7 @@ mod app { } ``` -### Resources struct - #[resources] +## Resources struct - #[resources] Previously the RTIC resources had to be in in a struct named exactly "Resources":