aboutsummaryrefslogtreecommitdiff
path: root/src/print.rs
blob: 88f39dad9e654294d72a8c4af596f26f48a08cc3 (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
//! # Printing to UART
//!
//! This module contains the macros to print formatted strings to UART.
use core::fmt;
use crate::uart::UART_WRITER;
use crate::console::interface::Write;

#[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)*));
	})
}