From 71a279f6d0a2fa4f0e51d09eda47bd422a1b0240 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Mon, 5 Oct 2020 20:38:52 +0200 Subject: Split up migration guides into its own sections --- book/en/src/migration/migration_v5.md | 96 +++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 book/en/src/migration/migration_v5.md (limited to 'book/en/src/migration/migration_v5.md') diff --git a/book/en/src/migration/migration_v5.md b/book/en/src/migration/migration_v5.md new file mode 100644 index 0000000..749ddec --- /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. -- cgit v1.2.3 From 987332b831761a681ec5cdda192ead524438df77 Mon Sep 17 00:00:00 2001 From: Daniel Carosone Date: Wed, 7 Oct 2020 09:31:30 +1100 Subject: minor md lints and wording clarification --- book/en/src/migration/migration_v5.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'book/en/src/migration/migration_v5.md') diff --git a/book/en/src/migration/migration_v5.md b/book/en/src/migration/migration_v5.md index 749ddec..1d83444 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": -- cgit v1.2.3