summaryrefslogtreecommitdiff
path: root/src/serial.rs
diff options
context:
space:
mode:
authorChristian Cunningham <c@localhost>2022-08-23 22:18:04 -0700
committerChristian Cunningham <c@localhost>2022-08-23 22:18:04 -0700
commite746ab10da35e5d9ef957c72adf9a3ec7a7df225 (patch)
treedaf55ae2215e7934292f21de68727ba733c7b3af /src/serial.rs
parentec68c0209227dd371b8f1c86890575eac0277695 (diff)
Queue trait
Diffstat (limited to 'src/serial.rs')
-rw-r--r--src/serial.rs30
1 files changed, 30 insertions, 0 deletions
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)*));
+}