diff options
author | 2017-03-08 13:54:56 -0500 | |
---|---|---|
committer | 2017-03-08 13:54:56 -0500 | |
commit | 559da5e265d4c1ac88c8bf07f5a4d317c922b408 (patch) | |
tree | ba3324cdda1a2d664ac6235a039ebbf67f8feec6 /src/macros.rs | |
parent | 0e628b32ac27d47aa897dfd7930ddad85903bd37 (diff) | |
download | cortex-m-559da5e265d4c1ac88c8bf07f5a4d317c922b408.tar.gz cortex-m-559da5e265d4c1ac88c8bf07f5a4d317c922b408.tar.zst cortex-m-559da5e265d4c1ac88c8bf07f5a4d317c922b408.zip |
add macros for writing to an ITM port
Diffstat (limited to 'src/macros.rs')
-rw-r--r-- | src/macros.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/macros.rs b/src/macros.rs index bd31167..1c39f18 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -27,3 +27,28 @@ macro_rules! hprintln { ($fmt:expr) => (hprint!(concat!($fmt, "\n"))); ($fmt:expr, $($arg:tt)*) => (hprint!(concat!($fmt, "\n"), $($arg)*)); } + +/// Macro for sending a formatted string through an ITM channel +#[macro_export] +macro_rules! iprint { + ($channel:expr, $s:expr) => { + $crate::itm::write_str($channel, $s); + }; + ($channel:expr, $($arg:tt)*) => { + $crate::itm::write_fmt($channel, format_args!($($arg)*)); + }; +} + +/// Macro for sending a formatted string through an ITM channel, with a newline. +#[macro_export] +macro_rules! iprintln { + ($channel:expr) => { + iprint!($channel, "\n"); + }; + ($channel:expr, $fmt:expr) => { + iprint!($channel, concat!($fmt, "\n")); + }; + ($channel:expr, $fmt:expr, $($arg:tt)*) => { + iprint!($channel, concat!($fmt, "\n"), $($arg)*); + }; +} |