From e746ab10da35e5d9ef957c72adf9a3ec7a7df225 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Tue, 23 Aug 2022 22:18:04 -0700 Subject: Queue trait --- src/serial.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/serial.rs (limited to 'src/serial.rs') diff --git a/src/serial.rs b/src/serial.rs new file mode 100644 index 0000000..792ddf7 --- /dev/null +++ b/src/serial.rs @@ -0,0 +1,30 @@ +//! # Serial Writer +//! +//! Write to serial +//! +//! ```rust +//! #[doc(hidden)] +//! pub fn _serial_print(args: core::fmt::Arguments) { +//! use core::fmt::Write; +//! SERIAL1.lock(|serial| { +//! ... +//! }); +//! } +//! ``` + +/// Prints to the host through the serial interface. +#[macro_export] +macro_rules! serial_print { + ($($arg:tt)*) => { + $crate::serial::_print(format_args!($($arg)*)); + }; +} + +/// Prints to the host through the serial interface, appending a newline. +#[macro_export] +macro_rules! serial_println { + () => ($crate::serial_print!("\n")); + ($fmt:expr) => ($crate::serial_print!(concat!($fmt, "\n"))); + ($fmt:expr, $($arg:tt)*) => ($crate::serial_print!( + concat!($fmt, "\n"), $($arg)*)); +} -- cgit v1.2.1