aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt/examples
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2018-09-06 00:39:46 +0200
committerGravatar Jorge Aparicio <jorge@japaric.io> 2018-09-06 00:39:46 +0200
commit306c3fbb7e9f186a43c0a82c43b6a1f16b88df98 (patch)
treedd0d6b962944847a76d85d20b6ab1d41d63ab716 /cortex-m-rt/examples
parent8ee2e58fc6eb843b9c751bc5f45e414efc325e62 (diff)
downloadcortex-m-306c3fbb7e9f186a43c0a82c43b6a1f16b88df98.tar.gz
cortex-m-306c3fbb7e9f186a43c0a82c43b6a1f16b88df98.tar.zst
cortex-m-306c3fbb7e9f186a43c0a82c43b6a1f16b88df98.zip
add a test / example about using `static mut` vars in the entry point
Diffstat (limited to 'cortex-m-rt/examples')
-rw-r--r--cortex-m-rt/examples/entry-static.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/cortex-m-rt/examples/entry-static.rs b/cortex-m-rt/examples/entry-static.rs
new file mode 100644
index 0000000..1b2e118
--- /dev/null
+++ b/cortex-m-rt/examples/entry-static.rs
@@ -0,0 +1,20 @@
+//! `static mut` variables local to the entry point are safe to use
+
+#![deny(unsafe_code)]
+#![deny(warnings)]
+#![no_main]
+#![no_std]
+
+extern crate cortex_m_rt as rt;
+extern crate panic_semihosting;
+
+use rt::entry;
+
+#[entry]
+fn main() -> ! {
+ static mut COUNT: u32 = 0;
+
+ loop {
+ *COUNT += 1;
+ }
+}