aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/peripheral/mod.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/peripheral/mod.rs b/src/peripheral/mod.rs
index c6e8faa..f47baf5 100644
--- a/src/peripheral/mod.rs
+++ b/src/peripheral/mod.rs
@@ -10,7 +10,7 @@ use core::ptr;
use volatile_register::{RO, RW, WO};
-use interrupt::Nr;
+use interrupt::{CsCtxt, Nr};
#[cfg(test)]
mod test;
@@ -69,6 +69,11 @@ impl<T> Peripheral<T> {
}
}
+ /// Borrows the peripheral for the duration of the critical section
+ pub fn borrow<'cs>(&self, _ctxt: &'cs CsCtxt) -> &'cs T {
+ unsafe { &*self.get() }
+ }
+
/// Returns a pointer to the register block
pub fn get(&self) -> *mut T {
self.address as *mut T