Skip to content

Commit a931364

Browse files
committed
Fixes for DWT on Cortex-M0
1 parent db67186 commit a931364

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/peripheral/dwt.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,41 @@ pub struct RegisterBlock {
1010
/// Control
1111
pub ctrl: RW<u32>,
1212
/// Cycle Count
13+
#[cfg(not(armv6m))]
1314
pub cyccnt: RW<u32>,
1415
/// CPI Count
16+
#[cfg(not(armv6m))]
1517
pub cpicnt: RW<u32>,
1618
/// Exception Overhead Count
19+
#[cfg(not(armv6m))]
1720
pub exccnt: RW<u32>,
1821
/// Sleep Count
22+
#[cfg(not(armv6m))]
1923
pub sleepcnt: RW<u32>,
2024
/// LSU Count
25+
#[cfg(not(armv6m))]
2126
pub lsucnt: RW<u32>,
2227
/// Folded-instruction Count
28+
#[cfg(not(armv6m))]
2329
pub foldcnt: RW<u32>,
30+
/// Cortex-M0(+) does not have these parts
31+
#[cfg(armv6m)]
32+
reserved: [u32; 6],
2433
/// Program Counter Sample
2534
pub pcsr: RO<u32>,
2635
/// Comparators
36+
#[cfg(armv6m)]
37+
pub c: [Comparator; 2],
38+
#[cfg(not(armv6m))]
39+
/// Comparators
2740
pub c: [Comparator; 16],
41+
#[cfg(not(armv6m))]
2842
reserved: [u32; 932],
2943
/// Lock Access
44+
#[cfg(not(armv6m))]
3045
pub lar: WO<u32>,
3146
/// Lock Status
47+
#[cfg(not(armv6m))]
3248
pub lsr: RO<u32>,
3349
}
3450

@@ -46,11 +62,13 @@ pub struct Comparator {
4662

4763
impl DWT {
4864
/// Enables the cycle counter
65+
#[cfg(not(armv6m))]
4966
pub fn enable_cycle_counter(&mut self) {
5067
unsafe { self.ctrl.modify(|r| r | 1) }
5168
}
5269

5370
/// Returns the current clock cycle count
71+
#[cfg(not(armv6m))]
5472
pub fn get_cycle_count() -> u32 {
5573
// NOTE(unsafe) atomic read with no side effects
5674
unsafe { (*Self::ptr()).cyccnt.read() }

0 commit comments

Comments
 (0)