diff options
author | 2018-08-12 15:41:32 -0400 | |
---|---|---|
committer | 2018-08-12 15:41:32 -0400 | |
commit | 54808883deb758f698cfb1e3a7340206128dd6a7 (patch) | |
tree | 2288658f41521f9525ad844666b3e094a36d0976 /cortex-m-rt/examples/pre_init.rs | |
parent | f3fa545b978a6d5d29d0bcdc78aca03518183bdc (diff) | |
download | cortex-m-54808883deb758f698cfb1e3a7340206128dd6a7.tar.gz cortex-m-54808883deb758f698cfb1e3a7340206128dd6a7.tar.zst cortex-m-54808883deb758f698cfb1e3a7340206128dd6a7.zip |
Add example for using the pre_init macro
Signed-off-by: Gabriel Smith <ga29smith@gmail.com>
Diffstat (limited to 'cortex-m-rt/examples/pre_init.rs')
-rw-r--r-- | cortex-m-rt/examples/pre_init.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/cortex-m-rt/examples/pre_init.rs b/cortex-m-rt/examples/pre_init.rs new file mode 100644 index 0000000..d83af03 --- /dev/null +++ b/cortex-m-rt/examples/pre_init.rs @@ -0,0 +1,36 @@ +//! `cortex-m-rt` based program with a function run before RAM is initialized. + +#![deny(warnings)] +#![no_main] +#![no_std] + +#[macro_use(entry, exception, pre_init)] +extern crate cortex_m_rt as rt; +extern crate panic_semihosting; + +use rt::ExceptionFrame; + +pre_init!(disable_watchdog); + +unsafe fn disable_watchdog() { + // Do what you need to disable the watchdog. +} + +// the program entry point +entry!(main); + +fn main() -> ! { + loop {} +} + +// the hard fault handler +exception!(HardFault, hard_fault); + +fn hard_fault(_ef: &ExceptionFrame) -> ! { + loop {} +} + +// the default exception handler +exception!(*, default_handler); + +fn default_handler(_irqn: i16) {} |