aboutsummaryrefslogtreecommitdiff
path: root/src/print.rs
blob: 2fefd91b0240b6be1ab863b483c1b3a99123a44f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! # Printing to UART
//!
//! This module contains the macros to print formatted strings to UART.
use crate::console::interface::Write;
use crate::uart::UART_WRITER;
use core::fmt;

#[doc(hidden)]
pub fn _print(args: fmt::Arguments) {
    UART_WRITER.write_fmt(args).unwrap();
}

/// # Print without newline
///
/// Print formatted arguments without a newline
#[macro_export]
macro_rules! print {
	($($arg:tt)*) => ($crate::print::_print(format_args!($($arg)*)));
}

/// # Print with newline
///
/// Print formatted arguments with a newline
#[macro_export]
macro_rules! println {
	() => ($crate::print!("\n"));
	($($arg:tt)*) => ({
		$crate::print::_print(format_args_nl!($($arg)*));
	})
}

/// # Debug print without newline
///
/// Print formatted arguments without a newline but only with `verbose` feature
#[macro_export]
macro_rules! vprint {
	($($arg:tt)*) => ({
		#[cfg(feature="verbose")]
		$crate::print::_print(format_args!($($arg)*))
	});
}

/// # Debug print with newline
///
/// Print formatted arguments with a newline but only with `verbose` feature
#[macro_export]
macro_rules! vprintln {
	() => ({
		#[cfg(feature="verbose")]
		$crate::print!("\n")
	});
	($($arg:tt)*) => ({
		#[cfg(feature="verbose")]
		$crate::print::_print(format_args_nl!($($arg)*));
	})
}