diff --git a/Cargo.toml b/Cargo.toml index 3249b67..3b64ba8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,11 +9,13 @@ repository = "https://github.com/japaric/cortex-m-quickstart" version = "0.2.7" [dependencies] -cortex-m = "0.4.0" -cortex-m-rt = "0.4.0" -cortex-m-semihosting = "0.2.0" +# cortex-m = "0.4.0" +# cortex-m-rt = "0.4.0" +cortex-m-rt = { git = "https://github.com/japaric/cortex-m-rt", branch = "stable" } +# cortex-m-semihosting = "0.2.0" +# panic-loop = { path = "../panic-loop" } panic-abort = "0.1.1" -panic-semihosting = "0.1.0" +# panic-semihosting = "0.1.0" # Uncomment for the allocator example. #alloc-cortex-m = "0.3.3" diff --git a/examples/minimal.rs b/examples/minimal.rs new file mode 100644 index 0000000..1e0932f --- /dev/null +++ b/examples/minimal.rs @@ -0,0 +1,35 @@ +#![no_main] // <- IMPORTANT! +#![no_std] + +#[macro_use] +extern crate cortex_m_rt; +extern crate panic_abort; + +use core::ptr; + +// user entry point +main!(main); + +fn main() -> ! { + loop { + unsafe { + // NOTE side affect to avoid UB + ptr::read_volatile(0x2000_0000 as *const u32); + } + } +} + +// define the default exception handler +exception!(DefaultHandler, deh); + +fn deh(_nr: u8) -> ! { + loop { + unsafe { + // NOTE side affect to avoid UB + ptr::read_volatile(0x2000_0004 as *const u32); + } + } +} + +// bind all interrupts to the default exception handler +interrupts!(DefaultHandler); diff --git a/interrupts.x b/interrupts.x new file mode 100644 index 0000000..65ab4a4 --- /dev/null +++ b/interrupts.x @@ -0,0 +1 @@ +/* Remove this file if you are linking to a device crate that provides this file */