diff --git a/src/lib.rs b/src/lib.rs index f0182e4f16ad90e139a377e19610e732134b3c54..94f0baa7863107194f6620d609babc4887a101ec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,9 +6,10 @@ macro_rules! ip { ($s:expr) => { { - let p = cortex_m::Peripherals::take().unwrap(); - let mut itm = p.ITM; - + extern crate cortex_m; + #[allow(unsafe_code)] + let itm = unsafe { &mut *cortex_m::peripheral::ITM::ptr() }; + cortex_m::itm::write_str( &mut itm.stim[0], $s @@ -17,10 +18,12 @@ macro_rules! ip { }; ($($arg:tt)*) => { { - extern crate cortex_m; - #[allow(unsafe_code)] + extern crate cortex_m; + #[allow(unsafe_code)] + let itm = unsafe { &mut *cortex_m::peripheral::ITM::ptr() }; + cortex_m::itm::write_fmt( - unsafe { &mut itm.stim[0] }, + &mut itm.stim[0], format_args!($($arg)*) ); } @@ -42,26 +45,27 @@ macro_rules! ipln { }; } -/// Macro for sending a formatted string over semihosting, with a newline. +/// Macro for sending a formatted string over semihosting. #[macro_export] -macro_rules! sprintln { +macro_rules! sp { ($($e:tt)*) => { { extern crate cortex_m_semihosting; use core::fmt::Write; - writeln!(cortex_m_semihosting::hio::hstdout().unwrap(), $($e)*).unwrap(); + write!(cortex_m_semihosting::hio::hstdout().unwrap(), $($e)*).unwrap(); } } } -/// Macro for sending a formatted string over semihosting. +/// Macro for sending a formatted string over semihosting, with a newline. #[macro_export] -macro_rules! sprint { +macro_rules! spln { ($($e:tt)*) => { { extern crate cortex_m_semihosting; use core::fmt::Write; - write!(cortex_m_semihosting::hio::hstdout().unwrap(), $($e)*).unwrap(); + writeln!(cortex_m_semihosting::hio::hstdout().unwrap(), $($e)*).unwrap(); } } } +