Skip to content

Commit fafa4b4

Browse files
bors[bot]newAM
andauthored
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>
2 parents bb41983 + 52b895f commit fafa4b4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1313
- Exception overhead counter
1414
- LSU counter
1515
- Folded-instruction counter
16+
- Added `DWT.set_cycle_count` (#347).
1617

1718
### Deprecated
1819

src/peripheral/dwt.rs

+7
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ impl DWT {
160160
unsafe { (*Self::ptr()).cyccnt.read() }
161161
}
162162

163+
/// Set the cycle count
164+
#[cfg(not(armv6m))]
165+
#[inline]
166+
pub fn set_cycle_count(&mut self, count: u32) {
167+
unsafe { self.cyccnt.write(count) }
168+
}
169+
163170
/// Removes the software lock on the DWT
164171
///
165172
/// Some devices, like the STM32F7, software lock the DWT after a power cycle.

0 commit comments

Comments
 (0)