add a borrow method to Peripheral
@@ -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
