update defmt deps to v0.3 (#56)
* bump defmt to v0.3 remove Cargo features which are no longer needed * remove `timestamp!` it's no longer mandatory and a monotonic counter does not add much value given that `defmt-rtt` works by disabling interrupts so one won't see logs out of order anyways (which would the case for a lock-free multi-channel `Logger`) * use println! in most the examples so that all examples print something when `DEFMT_LOG` is unset * make overflow example terminate in less steps also include an estimate of the stack pointer to show the stack grows downwards towards the RAM boundary
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ use {{crate_name}} as _; // global logger + panicking-behavior + memory layout
|
||||
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);
|
||||
defmt::println!("FREQUENCY: {0=0..7}, MAP: {0=8..9}", frequency);
|
||||
|
||||
{{crate_name}}::exit()
|
||||
}
|
||||
|
||||
+6
-3
@@ -17,10 +17,13 @@ struct S2 {
|
||||
|
||||
#[cortex_m_rt::entry]
|
||||
fn main() -> ! {
|
||||
let s = S1 { x: 42, y: S2 { z: 43 } };
|
||||
defmt::info!("s={:?}", s);
|
||||
let s = S1 {
|
||||
x: 42,
|
||||
y: S2 { z: 43 },
|
||||
};
|
||||
defmt::println!("s={:?}", s);
|
||||
let x = 42;
|
||||
defmt::info!("x={=u8}", x);
|
||||
defmt::println!("x={=u8}", x);
|
||||
|
||||
{{crate_name}}::exit()
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ use {{crate_name}} as _; // global logger + panicking-behavior + memory layout
|
||||
|
||||
#[cortex_m_rt::entry]
|
||||
fn main() -> ! {
|
||||
defmt::info!("Hello, world!");
|
||||
defmt::println!("Hello, world!");
|
||||
|
||||
{{crate_name}}::exit()
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ use {{crate_name}} as _; // global logger + panicking-behavior + memory layout
|
||||
|
||||
#[cortex_m_rt::entry]
|
||||
fn main() -> ! {
|
||||
// try setting the DEFMT_LOG environment variable
|
||||
// e.g. `export DEFMT_LOG=info` or `DEFMT_LOG=trace cargo rb levels`
|
||||
defmt::info!("info");
|
||||
defmt::trace!("trace");
|
||||
defmt::warn!("warn");
|
||||
|
||||
+6
-3
@@ -10,12 +10,15 @@ fn main() -> ! {
|
||||
}
|
||||
|
||||
fn ack(m: u32, n: u32) -> u32 {
|
||||
defmt::info!("ack(m={=u32}, n={=u32})", m, n);
|
||||
let mut big = [2; 512];
|
||||
// waste stack space to trigger a stack overflow
|
||||
let mut buffer = [0u8; 16 * 1024];
|
||||
// estimate of the Stack Pointer register
|
||||
let sp = buffer.as_mut_ptr();
|
||||
defmt::println!("ack(m={=u32}, n={=u32}, SP={:x})", m, n, sp);
|
||||
|
||||
if m == 0 {
|
||||
n + 1
|
||||
} else {
|
||||
big[100] += 1;
|
||||
if n == 0 {
|
||||
ack(m - 1, 1)
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ use {{crate_name}} as _; // global logger + panicking-behavior + memory layout
|
||||
|
||||
#[cortex_m_rt::entry]
|
||||
fn main() -> ! {
|
||||
defmt::info!("main");
|
||||
defmt::println!("main");
|
||||
|
||||
defmt::panic!()
|
||||
}
|
||||
|
||||
+1
-10
@@ -1,8 +1,7 @@
|
||||
#![no_std]
|
||||
|
||||
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
use defmt_rtt as _; // global logger
|
||||
|
||||
// TODO(5) adjust HAL import
|
||||
// use some_hal as _; // memory layout
|
||||
|
||||
@@ -15,14 +14,6 @@ fn panic() -> ! {
|
||||
cortex_m::asm::udf()
|
||||
}
|
||||
|
||||
static COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||
defmt::timestamp!("{=usize}", {
|
||||
// NOTE(no-CAS) `timestamps` runs with interrupts disabled
|
||||
let n = COUNT.load(Ordering::Relaxed);
|
||||
COUNT.store(n + 1, Ordering::Relaxed);
|
||||
n
|
||||
});
|
||||
|
||||
/// Terminates the application and makes `probe-run` exit with exit-code = 0
|
||||
pub fn exit() -> ! {
|
||||
loop {
|
||||
|
||||
Reference in New Issue
Block a user