aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/exception.rs2
-rw-r--r--src/interrupt.rs4
-rw-r--r--src/itm.rs26
3 files changed, 14 insertions, 18 deletions
diff --git a/src/exception.rs b/src/exception.rs
index 2c4b1be..451332e 100644
--- a/src/exception.rs
+++ b/src/exception.rs
@@ -3,7 +3,7 @@
use ctxt::Context;
use Reserved;
-/// Kind of exception
+/// Enumeration of all exceptions
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Exception {
/// i.e. currently not servicing an exception
diff --git a/src/interrupt.rs b/src/interrupt.rs
index 2aff77e..6c84301 100644
--- a/src/interrupt.rs
+++ b/src/interrupt.rs
@@ -34,7 +34,7 @@ pub unsafe trait Nr {
unsafe impl<T> Sync for Mutex<T> {}
-/// Disable interrupts, globally
+/// Disables all interrupts
#[inline(always)]
pub fn disable() {
match () {
@@ -51,7 +51,7 @@ pub fn disable() {
}
}
-/// Enable interrupts, globally
+/// Enables all the interrupts
#[inline(always)]
pub fn enable() {
match () {
diff --git a/src/itm.rs b/src/itm.rs
index d4fae5d..4c49d14 100644
--- a/src/itm.rs
+++ b/src/itm.rs
@@ -43,39 +43,35 @@ unsafe fn write_words(stim: &Stim, bytes: &[u32]) {
}
}
-struct Itm {
- port: u8,
-}
+struct Port<'p>(&'p Stim);
-impl fmt::Write for Itm {
+impl<'p> fmt::Write for Port<'p> {
fn write_str(&mut self, s: &str) -> fmt::Result {
- write_all(self.port, s.as_bytes());
+ write_all(self.0, s.as_bytes());
Ok(())
}
}
/// Writes a `buffer` to the ITM `port`
-pub fn write_all(port: u8, buffer: &[u8]) {
- let stim = unsafe { &(*::peripheral::ITM.get()).stim[port as usize] };
-
+pub fn write_all(port: &Stim, buffer: &[u8]) {
if buffer.len() < 7 {
- write_bytes(stim, buffer);
+ write_bytes(port, buffer);
} else {
let (head, body, tail) = unsafe { split(buffer) };
- write_bytes(stim, head);
- unsafe { write_words(stim, body) }
- write_bytes(stim, tail);
+ write_bytes(port, head);
+ unsafe { write_words(port, body) }
+ write_bytes(port, tail);
}
}
/// Writes `fmt::Arguments` to the ITM `port`
-pub fn write_fmt(port: u8, args: fmt::Arguments) {
+pub fn write_fmt(port: &Stim, args: fmt::Arguments) {
use core::fmt::Write;
- Itm { port }.write_fmt(args).ok();
+ Port(port).write_fmt(args).ok();
}
/// Writes a string to the ITM `port`
-pub fn write_str(port: u8, string: &str) {
+pub fn write_str(port: &Stim, string: &str) {
write_all(port, string.as_bytes())
}