Skip to content

Commit 0b9da3d

Browse files
Brandon Matthewsthenewwazoo
authored andcommitted
Add support for debugger check
1 parent 95e38e0 commit 0b9da3d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/peripheral/dcb.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@ pub struct RegisterBlock {
2020
}
2121

2222
impl DCB {
23-
/// Enables TRACE. This is for example required by the
23+
/// Enables TRACE. This is for example required by the
2424
/// `peripheral::DWT` cycle counter to work properly.
2525
/// As by STM documentation, this flag is not reset on
2626
/// soft-reset, only on power reset.
2727
pub fn enable_trace(&mut self) {
2828
// set bit 24 / TRCENA
2929
unsafe { self.demcr.modify(|w| w | DCB_DEMCR_TRCENA); }
3030
}
31-
31+
3232
/// Disables TRACE. See `DCB::enable_trace()` for more details
3333
pub fn disable_trace(&mut self) {
3434
// unset bit 24 / TRCENA
3535
unsafe { self.demcr.modify(|w| w & !DCB_DEMCR_TRCENA); }
36+
37+
/// Is there a debugger attached?
38+
pub fn is_debugger_attached(&self) -> bool {
39+
self.dhcsr.read() & 0x1 == 1
3640
}
3741
}

0 commit comments

Comments
 (0)