blob: 3693b00dfd93cbfb990301d917ac2744aae9c8c6 [file] [log] [blame]
Serge Bazanski81981362021-03-06 13:08:00 +01001// Wrappers around hprint(ln) that get disabled during release builds. This prevents us from
2// getting stuck in an hprint when a debugger is detached.
3
4#[cfg(debug_assertions)]
5#[macro_export]
6macro_rules! hprint {
7 ($s:expr) => {
8 cortex_m_semihosting::export::hstdout_str($s)
9 };
10 ($($tt:tt)*) => {
11 cortex_m_semihosting::export::hstdout_fmt(format_args!($($tt)*))
12 };
13}
14#[cfg(debug_assertions)]
15#[macro_export]
16macro_rules! hprintln {
17 () => {
18 cortex_m_semihosting::export::hstdout_str("\n")
19 };
20 ($s:expr) => {
21 cortex_m_semihosting::export::hstdout_str(concat!($s, "\n"))
22 };
23 ($s:expr, $($tt:tt)*) => {
24 cortex_m_semihosting::export::hstdout_fmt(format_args!(concat!($s, "\n"), $($tt)*))
25 };
26}
27
28#[cfg(not(debug_assertions))]
29#[macro_export]
30macro_rules! hprint {
31 () => { Result::<(), ()>::Ok(()) };
32 ($s:expr, $($tt:tt)*) => { Result::<(), ()>::Ok(()) };
33}
34#[cfg(not(debug_assertions))]
35#[macro_export]
36macro_rules! hprintln {
37 () => { Result::<(), ()>::Ok(()) };
38 ($s:expr) => { Result::<(), ()>::Ok(()) };
39 ($s:expr, $($tt:tt)*) => { Result::<(), ()>::Ok(()) };
40}