2020-10-05 20:38:52 +02:00
|
|
|
# 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.
|
|
|
|
|
2020-10-07 00:31:30 +02:00
|
|
|
## `Cargo.toml` - version bump
|
2020-10-05 20:38:52 +02:00
|
|
|
|
|
|
|
Change the version of `cortex-m-rtic` to `"0.6.0"`.
|
|
|
|
|
2020-10-23 10:35:56 +02:00
|
|
|
## Move Dispatchers from `extern "C"` to app arguments.
|
|
|
|
|
|
|
|
Change
|
|
|
|
|
|
|
|
``` rust
|
|
|
|
#[rtic::app(/* .. */)]
|
|
|
|
const APP: () = {
|
|
|
|
[code here]
|
|
|
|
|
|
|
|
// RTIC requires that unused interrupts are declared in an extern block when
|
|
|
|
// using software tasks; these free interrupts will be used to dispatch the
|
|
|
|
// software tasks.
|
|
|
|
extern "C" {
|
|
|
|
fn SSI0();
|
|
|
|
fn QEI0();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
```
|
|
|
|
|
|
|
|
into
|
|
|
|
|
|
|
|
``` rust
|
|
|
|
#[rtic::app(/* .. */, dispatchers = [SSI0, QEI0])]
|
|
|
|
mod app {
|
|
|
|
[code here]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
This works also for ram functions, see examples/ramfunc.rs
|
|
|
|
|
|
|
|
|
2020-10-07 00:31:30 +02:00
|
|
|
## Module instead of Const
|
2020-10-05 20:38:52 +02:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2020-10-07 00:31:30 +02:00
|
|
|
## Init always returns late resources
|
2020-10-05 20:38:52 +02:00
|
|
|
|
|
|
|
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]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-10-07 00:31:30 +02:00
|
|
|
## Resources struct - #[resources]
|
2020-10-05 20:38:52 +02:00
|
|
|
|
|
|
|
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.
|