Initial Setup for the microbit v1

This commit is contained in:
2024-10-11 20:01:36 +02:00
commit e70e2b2104
37 changed files with 22320 additions and 0 deletions

28
examples/overflow.rs Normal file
View File

@@ -0,0 +1,28 @@
#![no_main]
#![no_std]
use template_microbit as _; // global logger + panicking-behavior + memory layout
#[cortex_m_rt::entry]
fn main() -> ! {
ack(10, 10);
template_microbit::exit()
}
fn ack(m: u32, n: u32) -> u32 {
// 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 {
if n == 0 {
ack(m - 1, 1)
} else {
ack(m - 1, ack(m, n - 1))
}
}
}