Skip to content

Commit b784ecf

Browse files
bors[bot]japaric
andauthored
Merge #173
173: add a safe method to software unlock the DWT r=therealprof a=japaric today the alternative is an unsafe write to the LAR register Co-authored-by: Jorge Aparicio <[email protected]>
2 parents 718cd17 + a7e62b6 commit b784ecf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/peripheral/dwt.rs

+9
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,13 @@ impl DWT {
7575
// NOTE(unsafe) atomic read with no side effects
7676
unsafe { (*Self::ptr()).cyccnt.read() }
7777
}
78+
79+
/// Removes the software lock on the DWT
80+
///
81+
/// Some devices, like the STM32F7, software lock the DWT after a power cycle.
82+
#[cfg(not(armv6m))]
83+
pub fn unlock() {
84+
// NOTE(unsafe) atomic write to a stateless, write-only register
85+
unsafe { (*Self::ptr()).lar.write(0xC5ACCE55) }
86+
}
7887
}

0 commit comments

Comments
 (0)