From dcf89ebf7e0a16d0ccb5b8f5f9d1aa3bbbe133d4 Mon Sep 17 00:00:00 2001 From: sheepwall <a.sve@live.se> Date: Thu, 28 Feb 2019 19:37:56 +0100 Subject: [PATCH] bare1_1 --- examples/bare1.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/examples/bare1.rs b/examples/bare1.rs index 24ed553..2bf9442 100644 --- a/examples/bare1.rs +++ b/examples/bare1.rs @@ -13,6 +13,8 @@ extern crate panic_halt; use cortex_m_rt::entry; +use cortex_m::{iprintln, Peripherals}; +use cortex_m_semihosting::hprintln; #[entry] #[inline(never)] @@ -20,10 +22,15 @@ fn main() -> ! { // Prepend by `x` by _ to avoid warning (never used). // The compiler is smart enough to figure out that // `x` is not used in any meaningful way. - let mut _x = 0; + + let mut p = Peripherals::take().unwrap(); + let stim = &mut p.ITM.stim[0]; + loop { + hprintln!("{}", _x).unwrap(); _x += 1; + iprintln!(stim, "{}", _x); // cortex_m::asm::nop(); // cortex_m::asm::bkpt(); _x -= 1; @@ -55,10 +62,16 @@ fn main() -> ! { // loop, (press pause/suspend to verify this). // what is the output in the ITM console // -// ** your answer here ** +// * 1 +// * 1 +// * 1 +// * ... // // What is the output in the semihosting (openocd) console -// ** your answer here ** +// * 0 +// * 0 +// * 0 +// * ... // // Commit your answers (bare1_1) // -- GitLab