aboutsummaryrefslogtreecommitdiff
path: root/src/peripheral/dcb.rs
diff options
context:
space:
mode:
authorGravatar kellerkindt <michael@kellerkindt.com> 2018-09-02 11:09:11 +0200
committerGravatar GitHub <noreply@github.com> 2018-09-02 11:09:11 +0200
commitafb4dca1abb0f81b26abdef765a7d5b7814c3c8f (patch)
tree112c7832495f67ae7112e1a1d926478bdf17f58b /src/peripheral/dcb.rs
parent278ab0d5b929dc23e6d9538faf1bc2ac633b9caa (diff)
downloadcortex-m-afb4dca1abb0f81b26abdef765a7d5b7814c3c8f.tar.gz
cortex-m-afb4dca1abb0f81b26abdef765a7d5b7814c3c8f.tar.zst
cortex-m-afb4dca1abb0f81b26abdef765a7d5b7814c3c8f.zip
Add DCB::enable_trace() and DCB::disable_trace()
Diffstat (limited to 'src/peripheral/dcb.rs')
-rw-r--r--src/peripheral/dcb.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/peripheral/dcb.rs b/src/peripheral/dcb.rs
index 02ec901..d0202db 100644
--- a/src/peripheral/dcb.rs
+++ b/src/peripheral/dcb.rs
@@ -2,6 +2,8 @@
use volatile_register::{RW, WO};
+use peripheral::DCB;
+
/// Register block
#[repr(C)]
pub struct RegisterBlock {
@@ -14,3 +16,18 @@ pub struct RegisterBlock {
/// Debug Exception and Monitor Control
pub demcr: RW<u32>,
}
+
+impl DCB {
+ /// Enables TRACE. This is for example required by the
+ /// `peripheral::DWT` cycle counter to work properly.
+ /// As by STM documentation, this flag is not reset on
+ /// soft-reset, only on power reset.
+ pub fn enable_trace(&mut self) {
+ unsafe { self.demcr.modify(|w| w | 0x01000000); }
+ }
+
+ /// Disables TRACE. See `DCB::enable_trace()` for more details
+ pub fn disable_trace(&mut self) {
+ unsafe { self.demcr.modify(|w| w & !0x01000000); }
+ }
+}