diff options
author | 2021-08-14 21:55:06 +0000 | |
---|---|---|
committer | 2021-08-14 21:55:06 +0000 | |
commit | fafa4b4d204c1f88f17144da7ae228cba450275d (patch) | |
tree | c8d70eb4f366ec84195ec287215f34ee0c82bb98 | |
parent | bb41983ad51a8d6bbde70507358b792cdbdbd3be (diff) | |
parent | 52b895f715016083096363cc0059ff2e5338a603 (diff) | |
download | cortex-m-fafa4b4d204c1f88f17144da7ae228cba450275d.tar.gz cortex-m-fafa4b4d204c1f88f17144da7ae228cba450275d.tar.zst cortex-m-fafa4b4d204c1f88f17144da7ae228cba450275d.zip |
Merge #347
347: Add DWT.set_cycle_count r=adamgreig a=newAM
This method is helpful to reset the cycle count when using it as a timestamp.
Co-authored-by: Alex Martens <alexmgit@protonmail.com>
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | src/peripheral/dwt.rs | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 57d7dad..67b0a57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Exception overhead counter - LSU counter - Folded-instruction counter +- Added `DWT.set_cycle_count` (#347). ### Deprecated diff --git a/src/peripheral/dwt.rs b/src/peripheral/dwt.rs index 21af4f1..9e8e638 100644 --- a/src/peripheral/dwt.rs +++ b/src/peripheral/dwt.rs @@ -160,6 +160,13 @@ impl DWT { unsafe { (*Self::ptr()).cyccnt.read() } } + /// Set the cycle count + #[cfg(not(armv6m))] + #[inline] + pub fn set_cycle_count(&mut self, count: u32) { + unsafe { self.cyccnt.write(count) } + } + /// Removes the software lock on the DWT /// /// Some devices, like the STM32F7, software lock the DWT after a power cycle. |