aboutsummaryrefslogtreecommitdiff
path: root/src/peripheral
diff options
context:
space:
mode:
Diffstat (limited to 'src/peripheral')
-rw-r--r--src/peripheral/itm.rs6
-rw-r--r--src/peripheral/mod.rs12
2 files changed, 12 insertions, 6 deletions
diff --git a/src/peripheral/itm.rs b/src/peripheral/itm.rs
index 17cf869..fd4a2fd 100644
--- a/src/peripheral/itm.rs
+++ b/src/peripheral/itm.rs
@@ -33,17 +33,17 @@ pub struct Stim {
impl Stim {
/// Writes an `u8` payload into the stimulus port
- pub fn write_u8(&self, value: u8) {
+ pub fn write_u8(&mut self, value: u8) {
unsafe { ptr::write_volatile(self.register.get() as *mut u8, value) }
}
/// Writes an `u16` payload into the stimulus port
- pub fn write_u16(&self, value: u16) {
+ pub fn write_u16(&mut self, value: u16) {
unsafe { ptr::write_volatile(self.register.get() as *mut u16, value) }
}
/// Writes an `u32` payload into the stimulus port
- pub fn write_u32(&self, value: u32) {
+ pub fn write_u32(&mut self, value: u32) {
unsafe { ptr::write_volatile(self.register.get(), value) }
}
diff --git a/src/peripheral/mod.rs b/src/peripheral/mod.rs
index d462bdb..bd658a4 100644
--- a/src/peripheral/mod.rs
+++ b/src/peripheral/mod.rs
@@ -9,7 +9,7 @@
#![allow(private_no_mangle_statics)]
use core::marker::PhantomData;
-use core::ops::Deref;
+use core::ops::{Deref, DerefMut};
use interrupt;
@@ -262,8 +262,8 @@ pub struct ITM {
impl ITM {
/// Returns a pointer to the register block
- pub fn ptr() -> *const itm::RegisterBlock {
- 0xE000_0000 as *const _
+ pub fn ptr() -> *mut itm::RegisterBlock {
+ 0xE000_0000 as *mut _
}
}
@@ -275,6 +275,12 @@ impl Deref for ITM {
}
}
+impl DerefMut for ITM {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ unsafe { &mut *Self::ptr() }
+ }
+}
+
/// Memory Protection Unit
pub struct MPU {
_marker: PhantomData<*const ()>,