Specialized for RTIC
This commit is contained in:
+5
-4
@@ -14,6 +14,7 @@ cortex-m-rt = "0.6.13"
|
|||||||
defmt = "0.2.0"
|
defmt = "0.2.0"
|
||||||
defmt-rtt = "0.2.0"
|
defmt-rtt = "0.2.0"
|
||||||
panic-probe = { version = "0.2.0", features = ["print-defmt"] }
|
panic-probe = { version = "0.2.0", features = ["print-defmt"] }
|
||||||
|
cortex-m-rtic = "0.6.0-alpha.5"
|
||||||
# TODO(4) enter your HAL here
|
# TODO(4) enter your HAL here
|
||||||
# some-hal = "1.2.3"
|
# some-hal = "1.2.3"
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ codegen-units = 1
|
|||||||
debug = 2
|
debug = 2
|
||||||
debug-assertions = true # <-
|
debug-assertions = true # <-
|
||||||
incremental = false
|
incremental = false
|
||||||
opt-level = 3 # <-
|
opt-level = "s" # <-
|
||||||
overflow-checks = true # <-
|
overflow-checks = true # <-
|
||||||
|
|
||||||
# cargo test
|
# cargo test
|
||||||
@@ -47,7 +48,7 @@ codegen-units = 1
|
|||||||
debug = 2
|
debug = 2
|
||||||
debug-assertions = true # <-
|
debug-assertions = true # <-
|
||||||
incremental = false
|
incremental = false
|
||||||
opt-level = 3 # <-
|
opt-level = "s" # <-
|
||||||
overflow-checks = true # <-
|
overflow-checks = true # <-
|
||||||
|
|
||||||
# cargo build/run --release
|
# cargo build/run --release
|
||||||
@@ -57,7 +58,7 @@ debug = 2
|
|||||||
debug-assertions = false # <-
|
debug-assertions = false # <-
|
||||||
incremental = false
|
incremental = false
|
||||||
lto = 'fat'
|
lto = 'fat'
|
||||||
opt-level = 3 # <-
|
opt-level = "s" # <-
|
||||||
overflow-checks = false # <-
|
overflow-checks = false # <-
|
||||||
|
|
||||||
# cargo test --release
|
# cargo test --release
|
||||||
@@ -67,7 +68,7 @@ debug = 2
|
|||||||
debug-assertions = false # <-
|
debug-assertions = false # <-
|
||||||
incremental = false
|
incremental = false
|
||||||
lto = 'fat'
|
lto = 'fat'
|
||||||
opt-level = 3 # <-
|
opt-level = "s" # <-
|
||||||
overflow-checks = false # <-
|
overflow-checks = false # <-
|
||||||
|
|
||||||
# uncomment this to switch from the crates.io version of defmt to its git version
|
# uncomment this to switch from the crates.io version of defmt to its git version
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
# `app-template`
|
# `app-template`
|
||||||
|
|
||||||
> Quickly set up a [`probe-run`] + [`defmt`] + [`flip-link`] embedded project
|
> Quickly set up a [`probe-run`] + [`defmt`] + [`flip-link`] embedded project
|
||||||
|
> running on the [`RTIC`] scheduler
|
||||||
|
|
||||||
[`probe-run`]: https://crates.io/crates/probe-run
|
[`probe-run`]: https://crates.io/crates/probe-run
|
||||||
[`defmt`]: https://github.com/knurling-rs/defmt
|
[`defmt`]: https://github.com/knurling-rs/defmt
|
||||||
[`flip-link`]: https://github.com/knurling-rs/flip-link
|
[`flip-link`]: https://github.com/knurling-rs/flip-link
|
||||||
|
[`RTIC`]: https://rtic.rs/
|
||||||
|
|
||||||
|
Based on https://github.com/knurling-rs/app-template
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
@@ -37,7 +41,7 @@ $ cargo install cargo-generate
|
|||||||
|
|
||||||
``` console
|
``` console
|
||||||
$ cargo generate \
|
$ cargo generate \
|
||||||
--git https://github.com/knurling-rs/app-template \
|
--git https://github.com/rtic-rs/app-template \
|
||||||
--branch main \
|
--branch main \
|
||||||
--name my-app
|
--name my-app
|
||||||
```
|
```
|
||||||
@@ -122,7 +126,7 @@ Not all HALs provide a `memory.x` file, you may need to write it yourself. Check
|
|||||||
You are now all set to `cargo-run` your first `defmt`-powered application!
|
You are now all set to `cargo-run` your first `defmt`-powered application!
|
||||||
There are some examples in the `src/bin` directory.
|
There are some examples in the `src/bin` directory.
|
||||||
|
|
||||||
Start by `cargo run`-ning `my-app/src/bin/hello.rs`:
|
Start by `cargo run`-ning `my-app/src/bin/minimal.rs`:
|
||||||
|
|
||||||
``` console
|
``` console
|
||||||
$ # `rb` is an alias for `run --bin`
|
$ # `rb` is an alias for `run --bin`
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
#![no_main]
|
|
||||||
#![no_std]
|
|
||||||
|
|
||||||
use {{crate_name}} as _; // global logger + panicking-behavior + memory layout
|
|
||||||
|
|
||||||
#[cortex_m_rt::entry]
|
|
||||||
fn main() -> ! {
|
|
||||||
// value of the FREQUENCY register (nRF52840 device; RADIO peripheral)
|
|
||||||
let frequency: u32 = 276;
|
|
||||||
defmt::debug!("FREQUENCY: {0=0..7}, MAP: {0=8..9}", frequency);
|
|
||||||
|
|
||||||
{{crate_name}}::exit()
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#![no_main]
|
|
||||||
#![no_std]
|
|
||||||
|
|
||||||
use {{crate_name}} as _; // global logger + panicking-behavior + memory layout
|
|
||||||
use defmt::Format; // <- derive attribute
|
|
||||||
|
|
||||||
#[derive(Format)]
|
|
||||||
struct S1<T> {
|
|
||||||
x: u8,
|
|
||||||
y: T,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Format)]
|
|
||||||
struct S2 {
|
|
||||||
z: u8,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cortex_m_rt::entry]
|
|
||||||
fn main() -> ! {
|
|
||||||
let s = S1 { x: 42, y: S2 { z: 43 } };
|
|
||||||
defmt::info!("s={:?}", s);
|
|
||||||
let x = 42;
|
|
||||||
defmt::info!("x={=u8}", x);
|
|
||||||
|
|
||||||
{{crate_name}}::exit()
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#![no_main]
|
|
||||||
#![no_std]
|
|
||||||
|
|
||||||
use {{crate_name}} as _; // global logger + panicking-behavior + memory layout
|
|
||||||
|
|
||||||
#[cortex_m_rt::entry]
|
|
||||||
fn main() -> ! {
|
|
||||||
defmt::info!("Hello, world!");
|
|
||||||
|
|
||||||
{{crate_name}}::exit()
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#![no_main]
|
|
||||||
#![no_std]
|
|
||||||
|
|
||||||
use {{crate_name}} as _; // global logger + panicking-behavior + memory layout
|
|
||||||
|
|
||||||
#[cortex_m_rt::entry]
|
|
||||||
fn main() -> ! {
|
|
||||||
defmt::info!("info");
|
|
||||||
defmt::trace!("trace");
|
|
||||||
defmt::warn!("warn");
|
|
||||||
defmt::debug!("debug");
|
|
||||||
defmt::error!("error");
|
|
||||||
|
|
||||||
{{crate_name}}::exit()
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
#![no_main]
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
|
use {{crate_name}} as _; // global logger + panicking-behavior + memory layout
|
||||||
|
|
||||||
|
// TODO: Replace `some_hal::pac` with the path to the PAC
|
||||||
|
#[rtic::app(device = some_hal::pac)]
|
||||||
|
mod app {
|
||||||
|
// TODO: Add a monotonic if scheduling will be used
|
||||||
|
// #[monotonic(binds = SysTick, default = true)]
|
||||||
|
// type DwtMono = DwtSystick<80_000_000>;
|
||||||
|
|
||||||
|
// Shared resources go here
|
||||||
|
#[shared]
|
||||||
|
struct Shared {
|
||||||
|
// TODO: Add resources
|
||||||
|
}
|
||||||
|
|
||||||
|
// Local resources go here
|
||||||
|
#[local]
|
||||||
|
struct Local {
|
||||||
|
// TODO: Add resources
|
||||||
|
}
|
||||||
|
|
||||||
|
#[init]
|
||||||
|
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||||
|
defmt::info!("init");
|
||||||
|
|
||||||
|
task1::spawn().ok();
|
||||||
|
|
||||||
|
// Setup the monotonic timer
|
||||||
|
(
|
||||||
|
Shared {
|
||||||
|
// Initialization of shared resources go here
|
||||||
|
},
|
||||||
|
Local {
|
||||||
|
// Initialization of local resources go here
|
||||||
|
},
|
||||||
|
init::Monotonics(
|
||||||
|
// Initialization of optional monotonic timers go here
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optional idle, can be removed if not needed.
|
||||||
|
// Note that removing this will put the MCU to sleep when no task is running, and this
|
||||||
|
// generally breaks RTT based printing.
|
||||||
|
#[idle]
|
||||||
|
fn idle(_: idle::Context) -> ! {
|
||||||
|
defmt::info!("idle");
|
||||||
|
|
||||||
|
loop {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Add tasks
|
||||||
|
#[task]
|
||||||
|
fn task1(_cx: task1::Context) {
|
||||||
|
defmt::info!("Hello from task1!");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
#![no_main]
|
|
||||||
#![no_std]
|
|
||||||
|
|
||||||
use {{crate_name}} as _; // global logger + panicking-behavior + memory layout
|
|
||||||
|
|
||||||
#[cortex_m_rt::entry]
|
|
||||||
fn main() -> ! {
|
|
||||||
ack(10, 10);
|
|
||||||
{{crate_name}}::exit()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn ack(m: u32, n: u32) -> u32 {
|
|
||||||
defmt::info!("ack(m={=u32}, n={=u32})", m, n);
|
|
||||||
let mut big = [2; 512];
|
|
||||||
if m == 0 {
|
|
||||||
n + 1
|
|
||||||
} else {
|
|
||||||
big[100] += 1;
|
|
||||||
if n == 0 {
|
|
||||||
ack(m - 1, 1)
|
|
||||||
} else {
|
|
||||||
ack(m - 1, ack(m, n - 1))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#![no_main]
|
|
||||||
#![no_std]
|
|
||||||
|
|
||||||
use {{crate_name}} as _; // global logger + panicking-behavior + memory layout
|
|
||||||
|
|
||||||
#[cortex_m_rt::entry]
|
|
||||||
fn main() -> ! {
|
|
||||||
defmt::info!("main");
|
|
||||||
|
|
||||||
defmt::panic!()
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user