From 306c3fbb7e9f186a43c0a82c43b6a1f16b88df98 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 6 Sep 2018 00:39:46 +0200 Subject: add a test / example about using `static mut` vars in the entry point --- cortex-m-rt/examples/entry-static.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cortex-m-rt/examples/entry-static.rs (limited to 'cortex-m-rt/examples/entry-static.rs') 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; + } +} -- cgit v1.2.3