aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt/examples/qemu.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cortex-m-rt/examples/qemu.rs')
-rw-r--r--cortex-m-rt/examples/qemu.rs28
1 files changed, 28 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..e903404
--- /dev/null
+++ b/cortex-m-rt/examples/qemu.rs
@@ -0,0 +1,28 @@
+// #![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 cortex_m::asm;
+use rt::entry;
+
+#[entry]
+fn main() -> ! {
+ use core::fmt::Write;
+ let x = 42;
+
+ loop {
+ asm::nop();
+
+ // write something through semihosting interface
+ let mut hstdout = semihosting::hio::hstdout().unwrap();
+ write!(hstdout, "x = {}\n", x).unwrap();
+ // exit from qemu
+ semihosting::debug::exit(semihosting::debug::EXIT_SUCCESS);
+ }
+}