diff options
author | 2018-09-06 00:39:46 +0200 | |
---|---|---|
committer | 2018-09-06 00:39:46 +0200 | |
commit | 306c3fbb7e9f186a43c0a82c43b6a1f16b88df98 (patch) | |
tree | dd0d6b962944847a76d85d20b6ab1d41d63ab716 /cortex-m-rt | |
parent | 8ee2e58fc6eb843b9c751bc5f45e414efc325e62 (diff) | |
download | cortex-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')
-rw-r--r-- | cortex-m-rt/ci/script.sh | 3 | ||||
-rw-r--r-- | cortex-m-rt/examples/entry-static.rs | 20 |
2 files changed, 22 insertions, 1 deletions
diff --git a/cortex-m-rt/ci/script.sh b/cortex-m-rt/ci/script.sh index 0a28641..ce1aec8 100644 --- a/cortex-m-rt/ci/script.sh +++ b/cortex-m-rt/ci/script.sh @@ -13,8 +13,9 @@ main() { local examples=( alignment - minimal + entry-static main + minimal override-exception pre_init state 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; + } +} |