Enum teensy4_bsp::LoggingFrontend
source · pub enum LoggingFrontend {
Log(LoggingConfig),
Defmt,
}
rt
and usb-logging
only.Expand description
The logging frontend.
LoggingFrontend
provides a convenient API for instantiating a USB1 logger.
It works with two different logging front-ends, described by the enum values.
When used for USB logging, the implementation registers the USB1 interrupt handler (USB_OTG1
).
This requires the BSP’s "rt"
feature. Registering an interrupt handler may not be appropriate
for environments where interrupts are defined and registered elsewhere. If that’s the case,
you should directly use logging
APIs.
For advanced logging configurations, see logging
.
§Example
Register a USB logger that uses the log
front-end.
use teensy4_bsp as bsp;
use bsp::board;
let board::Resources { usb, .. } = board::t40(board::instances());
bsp::LoggingFrontend::default_log().register_usb(usb);
log::info!("Hello world!");
Register a USB logger that uses the defmt
front-end.
// Same as above...
bsp::LoggingFrontend::Defmt.register_usb(usb);
defmt::info!("Hello world!");
Variants§
Log(LoggingConfig)
Use the log
crate to write textual log messages.
The logging configuration is optional; use default_log()
to select a reasonable default.
Defmt
Use the defmt
crate to write compressed messages.
defmt
requires additional setup in order to properly build your application.
Consult the defmt
documentation for specifics.
Implementations§
source§impl LoggingFrontend
impl LoggingFrontend
sourcepub const fn default_log() -> Self
pub const fn default_log() -> Self
Creates a log
front-end with a default configuration.
sourcepub fn register_usb(self, _: Instances<1>)
pub fn register_usb(self, _: Instances<1>)
Register the USB logger.
This method internally defines a USB1 interrupt handler named USB_OTG1
.
When this call returns, the interrupt is unmasked and may periodically
execute.