File tree 4 files changed +39
-2
lines changed
4 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -20,4 +20,4 @@ volatile-register = "0.2.0"
20
20
[features ]
21
21
cm7-r0p1 = []
22
22
const-fn = [" bare-metal/const-fn" ]
23
- inline-asm = []
23
+ inline-asm = []
Original file line number Diff line number Diff line change 2
2
3
3
use volatile_register:: { RW , WO } ;
4
4
5
+ use peripheral:: DCB ;
6
+
5
7
/// Register block
6
8
#[ repr( C ) ]
7
9
pub struct RegisterBlock {
@@ -14,3 +16,10 @@ pub struct RegisterBlock {
14
16
/// Debug Exception and Monitor Control
15
17
pub demcr : RW < u32 > ,
16
18
}
19
+
20
+ impl DCB {
21
+ /// Is there a debugger attached?
22
+ pub fn is_debugger_attached ( & self ) -> bool {
23
+ self . dhcsr . read ( ) & 0x1 == 1
24
+ }
25
+ }
Original file line number Diff line number Diff line change 1
1
//! Nested Vector Interrupt Controller
2
2
3
3
#[ cfg( not( armv6m) ) ]
4
- use volatile_register:: RO ;
4
+ use volatile_register:: { RO , WO } ;
5
5
use volatile_register:: RW ;
6
6
7
7
use interrupt:: Nr ;
@@ -65,9 +65,36 @@ pub struct RegisterBlock {
65
65
/// so convenient byte-sized representation wouldn't work on that
66
66
/// architecture.
67
67
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 > ,
68
78
}
69
79
70
80
impl NVIC {
81
+ #[ cfg( not( armv6m) ) ]
82
+ /// Request an IRQ in software
83
+ ///
84
+ /// Writing a value to the INTID field is the same as manually pending an interrupt by setting
85
+ /// the corresponding interrupt bit in an Interrupt Set Pending Register. This is similar to
86
+ /// `set_pending`.
87
+ pub fn request < I > ( & mut self , interrupt : I )
88
+ where
89
+ I : Nr ,
90
+ {
91
+ let nr = interrupt. nr ( ) ;
92
+
93
+ unsafe {
94
+ self . stir . write ( nr as u32 ) ;
95
+ }
96
+ }
97
+
71
98
/// Clears `interrupt`'s pending state
72
99
pub fn clear_pending < I > ( & mut self , interrupt : I )
73
100
where
Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ fn nvic() {
109
109
assert_eq ! ( address( & nvic. icpr) , 0xE000E280 ) ;
110
110
assert_eq ! ( address( & nvic. iabr) , 0xE000E300 ) ;
111
111
assert_eq ! ( address( & nvic. ipr) , 0xE000E400 ) ;
112
+ assert_eq ! ( address( & nvic. stir) , 0xE000EF00 ) ;
112
113
}
113
114
114
115
#[ test]
You can’t perform that action at this time.
0 commit comments