Skip to content

Commit 1581633

Browse files
author
Brandon Matthews
committed
Add support for debugger check
1 parent 3016f72 commit 1581633

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/peripheral/dcb.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
33
use volatile_register::{RW, WO};
44

5+
use peripheral::DCB;
6+
57
/// Register block
68
#[repr(C)]
79
pub struct RegisterBlock {
@@ -14,3 +16,10 @@ pub struct RegisterBlock {
1416
/// Debug Exception and Monitor Control
1517
pub demcr: RW<u32>,
1618
}
19+
20+
impl DCB {
21+
/// Is there a debugger attached?
22+
pub fn is_debugger_attached(&self) -> bool {
23+
self.dhcsr.read() & 0x1 == 1
24+
}
25+
}

0 commit comments

Comments
 (0)