Skip to content
Snippets Groups Projects
Commit 3208194d authored by Per Lindgren's avatar Per Lindgren
Browse files

ip, ipln, sp, spln

parent 3ef41518
No related branches found
No related tags found
No related merge requests found
......@@ -6,8 +6,9 @@
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],
......@@ -19,8 +20,10 @@ macro_rules! ip {
{
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();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment