diff options
Diffstat (limited to 'cortex-m-rt/examples/state.rs')
-rw-r--r-- | cortex-m-rt/examples/state.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/cortex-m-rt/examples/state.rs b/cortex-m-rt/examples/state.rs new file mode 100644 index 0000000..ee6224d --- /dev/null +++ b/cortex-m-rt/examples/state.rs @@ -0,0 +1,24 @@ +//! Preserving state across executions of an exception handler + +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] + +extern crate cortex_m_rt as rt; +extern crate panic_halt; + +use rt::{entry, exception}; + +#[entry] +fn main() -> ! { + loop {} +} + +// exception handler with state +#[exception] +fn SysTick() { + static mut STATE: u32 = 0; + + *STATE += 1; +} |