From 43f11812a1756c3f26278886fb1725259674a157 Mon Sep 17 00:00:00 2001 From: Per Lindgren Date: Tue, 29 Sep 2020 23:07:37 +0200 Subject: [PATCH] systic example for qemu --- examples/systic.rs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 examples/systic.rs diff --git a/examples/systic.rs b/examples/systic.rs new file mode 100644 index 0000000000..de38710c42 --- /dev/null +++ b/examples/systic.rs @@ -0,0 +1,41 @@ +//! examples/systic.rs + +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] + +use cortex_m_semihosting::{debug, hprintln}; +use lm3s6965::Interrupt; +use panic_semihosting as _; + +#[rtic::app(device = lm3s6965)] +const APP: () = { + #[init] + fn init(cx: init::Context) { + let mut syst = cx.core.SYST; + syst.set_reload(1000); + syst.enable_interrupt(); + syst.enable_counter(); + + hprintln!("init").unwrap(); + } + + #[idle] + fn idle(_: idle::Context) -> ! { + hprintln!("idle").unwrap(); + loop { + cortex_m::asm::nop(); + } + } + + #[task(binds = SysTick)] + fn t(_: t::Context) { + static mut COUNTER: i32 = 0; + *COUNTER += 1; + hprintln!("SysTick #{}", COUNTER).unwrap(); + if *C == 10 { + debug::exit(debug::EXIT_SUCCESS); + } + } +};