File tree 2 files changed +29
-1
lines changed
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 1
1
//! Data Watchpoint and Trace unit
2
2
3
- use volatile_register:: { RO , RW , WO } ;
3
+ #[ cfg( not( armv6m) ) ]
4
+ use volatile_register:: WO ;
5
+ use volatile_register:: { RO , RW } ;
4
6
5
7
use peripheral:: DWT ;
6
8
@@ -10,25 +12,41 @@ pub struct RegisterBlock {
10
12
/// Control
11
13
pub ctrl : RW < u32 > ,
12
14
/// Cycle Count
15
+ #[ cfg( not( armv6m) ) ]
13
16
pub cyccnt : RW < u32 > ,
14
17
/// CPI Count
18
+ #[ cfg( not( armv6m) ) ]
15
19
pub cpicnt : RW < u32 > ,
16
20
/// Exception Overhead Count
21
+ #[ cfg( not( armv6m) ) ]
17
22
pub exccnt : RW < u32 > ,
18
23
/// Sleep Count
24
+ #[ cfg( not( armv6m) ) ]
19
25
pub sleepcnt : RW < u32 > ,
20
26
/// LSU Count
27
+ #[ cfg( not( armv6m) ) ]
21
28
pub lsucnt : RW < u32 > ,
22
29
/// Folded-instruction Count
30
+ #[ cfg( not( armv6m) ) ]
23
31
pub foldcnt : RW < u32 > ,
32
+ /// Cortex-M0(+) does not have these parts
33
+ #[ cfg( armv6m) ]
34
+ reserved : [ u32 ; 6 ] ,
24
35
/// Program Counter Sample
25
36
pub pcsr : RO < u32 > ,
26
37
/// Comparators
38
+ #[ cfg( armv6m) ]
39
+ pub c : [ Comparator ; 2 ] ,
40
+ #[ cfg( not( armv6m) ) ]
41
+ /// Comparators
27
42
pub c : [ Comparator ; 16 ] ,
43
+ #[ cfg( not( armv6m) ) ]
28
44
reserved : [ u32 ; 932 ] ,
29
45
/// Lock Access
46
+ #[ cfg( not( armv6m) ) ]
30
47
pub lar : WO < u32 > ,
31
48
/// Lock Status
49
+ #[ cfg( not( armv6m) ) ]
32
50
pub lsr : RO < u32 > ,
33
51
}
34
52
@@ -46,11 +64,13 @@ pub struct Comparator {
46
64
47
65
impl DWT {
48
66
/// Enables the cycle counter
67
+ #[ cfg( not( armv6m) ) ]
49
68
pub fn enable_cycle_counter ( & mut self ) {
50
69
unsafe { self . ctrl . modify ( |r| r | 1 ) }
51
70
}
52
71
53
72
/// Returns the current clock cycle count
73
+ #[ cfg( not( armv6m) ) ]
54
74
pub fn get_cycle_count ( ) -> u32 {
55
75
// NOTE(unsafe) atomic read with no side effects
56
76
unsafe { ( * Self :: ptr ( ) ) . cyccnt . read ( ) }
Original file line number Diff line number Diff line change @@ -29,11 +29,17 @@ fn dwt() {
29
29
let dwt = unsafe { & * :: peripheral:: DWT :: ptr ( ) } ;
30
30
31
31
assert_eq ! ( address( & dwt. ctrl) , 0xE000_1000 ) ;
32
+ #[ cfg( not( armv6m) ) ]
32
33
assert_eq ! ( address( & dwt. cyccnt) , 0xE000_1004 ) ;
34
+ #[ cfg( not( armv6m) ) ]
33
35
assert_eq ! ( address( & dwt. cpicnt) , 0xE000_1008 ) ;
36
+ #[ cfg( not( armv6m) ) ]
34
37
assert_eq ! ( address( & dwt. exccnt) , 0xE000_100C ) ;
38
+ #[ cfg( not( armv6m) ) ]
35
39
assert_eq ! ( address( & dwt. sleepcnt) , 0xE000_1010 ) ;
40
+ #[ cfg( not( armv6m) ) ]
36
41
assert_eq ! ( address( & dwt. lsucnt) , 0xE000_1014 ) ;
42
+ #[ cfg( not( armv6m) ) ]
37
43
assert_eq ! ( address( & dwt. foldcnt) , 0xE000_1018 ) ;
38
44
assert_eq ! ( address( & dwt. pcsr) , 0xE000_101C ) ;
39
45
assert_eq ! ( address( & dwt. c[ 0 ] . comp) , 0xE000_1020 ) ;
@@ -42,7 +48,9 @@ fn dwt() {
42
48
assert_eq ! ( address( & dwt. c[ 1 ] . comp) , 0xE000_1030 ) ;
43
49
assert_eq ! ( address( & dwt. c[ 1 ] . mask) , 0xE000_1034 ) ;
44
50
assert_eq ! ( address( & dwt. c[ 1 ] . function) , 0xE000_1038 ) ;
51
+ #[ cfg( not( armv6m) ) ]
45
52
assert_eq ! ( address( & dwt. lar) , 0xE000_1FB0 ) ;
53
+ #[ cfg( not( armv6m) ) ]
46
54
assert_eq ! ( address( & dwt. lsr) , 0xE000_1FB4 ) ;
47
55
}
48
56
You can’t perform that action at this time.
0 commit comments