Skip to content

Commit 3016f72

Browse files
author
Brandon Matthews
committed
Add STIR register to NVIC peripheral
1 parent dfd0349 commit 3016f72

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ volatile-register = "0.2.0"
2020
[features]
2121
cm7-r0p1 = []
2222
const-fn = ["bare-metal/const-fn"]
23-
inline-asm = []
23+
inline-asm = []

src/peripheral/nvic.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#[cfg(not(armv6m))]
44
use volatile_register::RO;
5-
use volatile_register::RW;
5+
use volatile_register::{RW, WO};
66

77
use interrupt::Nr;
88
use peripheral::NVIC;
@@ -65,9 +65,35 @@ pub struct RegisterBlock {
6565
/// so convenient byte-sized representation wouldn't work on that
6666
/// architecture.
6767
pub ipr: [RW<u32>; 8],
68+
69+
#[cfg(not(armv6m))]
70+
reserved5: [u32; 208],
71+
72+
#[cfg(armv6m)]
73+
reserved5: [u32; 696],
74+
75+
#[cfg(not(armv6m))]
76+
/// Software Trigger Interrupt
77+
pub stir: WO<u32>,
6878
}
6979

7080
impl NVIC {
81+
/// Request an IRQ in software
82+
///
83+
/// Writing a value to the INTID field is the same as manually pending an interrupt by setting
84+
/// the corresponding interrupt bit in an Interrupt Set Pending Register. This is similar to
85+
/// `set_pending`.
86+
pub fn request<I>(&mut self, interrupt: I)
87+
where
88+
I: Nr,
89+
{
90+
let nr = interrupt.nr();
91+
92+
unsafe {
93+
self.stir.write(nr as u32);
94+
}
95+
}
96+
7197
/// Clears `interrupt`'s pending state
7298
pub fn clear_pending<I>(&mut self, interrupt: I)
7399
where

0 commit comments

Comments
 (0)