Skip to content

Commit c856ff7

Browse files
committed
itm: add lock function, improve unlock documentation
1 parent bb7319b commit c856ff7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/peripheral/itm.rs

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! Instrumentation Trace Macrocell
22
//!
3+
//! The documentation in this module contains references to ARM specifications, namely:
4+
//! - coresight: [*ARM CoreSight Architecture Specification*, Version 3.0](https://developer.arm.com/documentation/ihi0029/latest).
5+
//!
36
//! *NOTE* Not available on Armv6-M and Armv8-M Baseline.
47
58
use core::cell::UnsafeCell;
@@ -198,12 +201,23 @@ pub enum ITMConfigurationError {
198201

199202
impl ITM {
200203
/// Removes the software lock on the [`ITM`]. Must be called before any other [`ITM`] functions.
204+
///
205+
/// See (coresight, B2.3.10).
201206
#[inline]
202207
pub fn unlock(&mut self) {
203208
// NOTE(unsafe) atomic write to a stateless, write-only register
204209
unsafe { self.lar.write(0xC5AC_CE55) }
205210
}
206211

212+
/// Adds the software lock on the [`ITM`]. Should be called after any other [`ITM`] functions.
213+
///
214+
/// See (coresight, B2.3.10).
215+
#[inline]
216+
pub fn lock(&mut self) {
217+
// NOTE(unsafe) atomic write to a stateless, write-only register
218+
unsafe { self.lar.write(0) }
219+
}
220+
207221
/// Indicates whether the [`ITM`] is currently processing events.
208222
/// Returns `true` if [`ITM`] events are present and are being drained.
209223
#[inline]

0 commit comments

Comments
 (0)