From 95e38e0194e446e67c9f0bd02046da5f6eb18da0 Mon Sep 17 00:00:00 2001 From: Brandon Matthews Date: Fri, 11 May 2018 14:36:08 -0700 Subject: Add STIR register to NVIC peripheral --- src/peripheral/nvic.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/peripheral/nvic.rs b/src/peripheral/nvic.rs index c59c2c8..750565e 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,35 @@ 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], + + #[cfg(not(armv6m))] + /// Software Trigger Interrupt + pub stir: WO, } impl NVIC { + /// Request an IRQ in software + /// + /// Writing a value to the INTID field is the same as manually pending an interrupt by setting + /// the corresponding interrupt bit in an Interrupt Set Pending Register. This is similar to + /// `set_pending`. + pub fn request(&mut self, interrupt: I) + where + I: Nr, + { + let nr = interrupt.nr(); + + unsafe { + self.stir.write(nr as u32); + } + } + /// Clears `interrupt`'s pending state #[deprecated(since = "0.5.8", note = "Use `NVIC::unpend`")] pub fn clear_pending(&mut self, interrupt: I) -- cgit v1.2.3