diff options
author | 2018-10-09 21:20:57 +0100 | |
---|---|---|
committer | 2018-10-09 21:20:57 +0100 | |
commit | 7e583e2abf261910ed1a7778b07b72c1a7d97e3b (patch) | |
tree | 1c21d49626d101f90fe9a89b48a2a0220b05d5e2 /cortex-m-rt/examples/qemu.rs | |
parent | 879ae3c6296d19888bc00a18e50668f981deb7bb (diff) | |
parent | 0423076f192a07d1aeba2721d549c4359ff283ae (diff) | |
download | cortex-m-7e583e2abf261910ed1a7778b07b72c1a7d97e3b.tar.gz cortex-m-7e583e2abf261910ed1a7778b07b72c1a7d97e3b.tar.zst cortex-m-7e583e2abf261910ed1a7778b07b72c1a7d97e3b.zip |
Merge branch 'master' into interrupt
Diffstat (limited to 'cortex-m-rt/examples/qemu.rs')
-rw-r--r-- | cortex-m-rt/examples/qemu.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/cortex-m-rt/examples/qemu.rs b/cortex-m-rt/examples/qemu.rs new file mode 100644 index 0000000..e2cd895 --- /dev/null +++ b/cortex-m-rt/examples/qemu.rs @@ -0,0 +1,29 @@ +// #![feature(stdsimd)] +#![no_main] +#![no_std] + +extern crate cortex_m; + +extern crate cortex_m_rt as rt; +extern crate cortex_m_semihosting as semihosting; +extern crate panic_halt; + +use core::fmt::Write; +use cortex_m::asm; +use rt::entry; + +#[entry] +fn main() -> ! { + let x = 42; + + loop { + asm::nop(); + + // write something through semihosting interface + let mut hstdout = semihosting::hio::hstdout().unwrap(); + write!(hstdout, "x = {}\n", x); + + // exit from qemu + semihosting::debug::exit(semihosting::debug::EXIT_SUCCESS); + } +} |