File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed 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
+
7
+ const DCB_DEMCR_TRCENA : u32 = 1 << 24 ;
8
+
5
9
/// Register block
6
10
#[ repr( C ) ]
7
11
pub struct RegisterBlock {
@@ -14,3 +18,20 @@ pub struct RegisterBlock {
14
18
/// Debug Exception and Monitor Control
15
19
pub demcr : RW < u32 > ,
16
20
}
21
+
22
+ impl DCB {
23
+ /// Enables TRACE. This is for example required by the
24
+ /// `peripheral::DWT` cycle counter to work properly.
25
+ /// As by STM documentation, this flag is not reset on
26
+ /// soft-reset, only on power reset.
27
+ pub fn enable_trace ( & mut self ) {
28
+ // set bit 24 / TRCENA
29
+ unsafe { self . demcr . modify ( |w| w | DCB_DEMCR_TRCENA ) ; }
30
+ }
31
+
32
+ /// Disables TRACE. See `DCB::enable_trace()` for more details
33
+ pub fn disable_trace ( & mut self ) {
34
+ // unset bit 24 / TRCENA
35
+ unsafe { self . demcr . modify ( |w| w & !DCB_DEMCR_TRCENA ) ; }
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments