cortex_m_log/printer/
mod.rs

1//! Contains possible printers for Cortex-M
2
3use core::fmt;
4use core::fmt::Write;
5use crate::modes::{InterruptModer};
6
7///Generic Printer trait
8pub trait Printer {
9    ///Writer type
10    type W: fmt::Write;
11    ///Interrupt type
12    type M: InterruptModer;
13
14    ///Returns destination writer.
15    ///
16    ///Used by `print` and `println` default
17    ///impls
18    fn destination(&mut self) -> &mut Self::W;
19
20    #[inline]
21    ///Prints formatted output to destination
22    fn print(&mut self, args: fmt::Arguments) {
23        let _ = Self::M::critical_section(|_| self.destination().write_fmt(args));
24    }
25
26    #[inline]
27    ///Prints formatted output to destination with newline
28    fn println(&mut self, args: fmt::Arguments) {
29        let _ = Self::M::critical_section(|_| {
30            let _ = self.destination().write_fmt(args);
31            self.destination().write_str("\n")
32        });
33    }
34}
35
36pub mod generic;
37pub use generic::GenericPrinter;
38
39pub mod dummy;
40pub use self::dummy::Dummy;
41
42#[cfg(feature = "itm")]
43pub mod itm;
44#[cfg(feature = "itm")]
45pub use self::itm::Itm;
46
47#[cfg(feature = "semihosting")]
48pub mod semihosting;
49#[cfg(feature = "semihosting")]
50pub use self::semihosting::{Semihosting};