diff --git a/Cargo.toml b/Cargo.toml index 88e04157..5e2f8a05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["arm", "cortex-m", "register", "peripheral"] license = "MIT OR Apache-2.0" name = "cortex-m" repository = "https://github.com/japaric/cortex-m" -version = "0.5.1" +version = "0.5.2" [build-dependencies] cc = "1.0.10" @@ -20,4 +20,4 @@ volatile-register = "0.2.0" [features] cm7-r0p1 = [] const-fn = ["bare-metal/const-fn"] -inline-asm = [] \ No newline at end of file +inline-asm = [] diff --git a/src/peripheral/nvic.rs b/src/peripheral/nvic.rs index 1a6a0271..d0700de0 100644 --- a/src/peripheral/nvic.rs +++ b/src/peripheral/nvic.rs @@ -2,7 +2,7 @@ #[cfg(not(armv6m))] use volatile_register::RO; -use volatile_register::RW; +use volatile_register::{RW, WO}; use interrupt::Nr; use peripheral::NVIC; @@ -65,9 +65,30 @@ pub struct RegisterBlock { /// so convenient byte-sized representation wouldn't work on that /// architecture. pub ipr: [RW; 8], + + #[cfg(not(armv6m))] + reserved5: [u32; 208], + + #[cfg(armv6m)] + reserved5: [u32; 696], + + /// Software Trigger Interrupt + pub stir: WO, } impl NVIC { + /// Request an IRQ in software + pub fn req_irq(&mut self, interrupt: I) + where + I: Nr, + { + let nr = interrupt.nr(); + + unsafe { + self.stir.write(nr as u32); + } + } + /// Clears `interrupt`'s pending state pub fn clear_pending(&mut self, interrupt: I) where