2022-10-20 20:57:24 +08:00
|
|
|
#[cfg(not(feature = "semihosting"))]
|
|
|
|
use super::usb;
|
2022-10-20 15:17:43 +08:00
|
|
|
|
2022-10-20 20:57:24 +08:00
|
|
|
#[cfg(not(feature = "semihosting"))]
|
|
|
|
pub fn init_log() {
|
|
|
|
static USB_LOGGER: usb::Logger = usb::Logger;
|
|
|
|
let _ = log::set_logger(&USB_LOGGER);
|
|
|
|
log::set_max_level(log::LevelFilter::Debug);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(feature = "semihosting")]
|
2022-10-20 15:17:43 +08:00
|
|
|
pub fn init_log() {
|
2022-10-22 15:49:01 +08:00
|
|
|
use cortex_m_log::log::{init, Logger};
|
|
|
|
use cortex_m_log::printer::semihosting::{hio::HStdout, InterruptOk};
|
2022-10-20 15:17:43 +08:00
|
|
|
use log::LevelFilter;
|
|
|
|
static mut LOGGER: Option<Logger<InterruptOk<HStdout>>> = None;
|
|
|
|
let logger = Logger {
|
|
|
|
inner: InterruptOk::<_>::stdout().expect("semihosting stdout"),
|
|
|
|
level: LevelFilter::Info,
|
|
|
|
};
|
2022-10-22 15:49:01 +08:00
|
|
|
let logger = unsafe { LOGGER.get_or_insert(logger) };
|
2022-10-20 15:17:43 +08:00
|
|
|
|
|
|
|
init(logger).expect("set logger");
|
|
|
|
}
|