Specialized for RTIC
This commit is contained in:
@@ -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