Skip to content

Commit

Permalink
Fix more warnings related to itm or semihosting
Browse files Browse the repository at this point in the history
  • Loading branch information
usbalbin committed Nov 30, 2023
1 parent 740f344 commit 1bfa6d1
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions examples/utils/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,21 @@
cfg_if::cfg_if! {
if #[cfg(all(feature = "log-rtt", feature = "defmt"))] {
pub use defmt::{info, trace, warn, debug, error};
pub use defmt::println as println;

} else {
pub use log::{info, trace, warn, debug, error};

#[allow(unused_macros)]
macro_rules! println {
($($tt:tt)*) => {
$crate::cortex_m_semihosting::hprintln!($($tt,)*).unwrap();
};
}
}
}

cfg_if::cfg_if! {
if #[cfg(any(feature = "log-itm"))] {
if #[cfg(feature = "log-itm")] {
use panic_itm as _;

use lazy_static::lazy_static;
use log::LevelFilter;

pub use cortex_m_log::log::Logger;
pub use cortex_m_log::println;

use cortex_m_log::{
destination::Itm as ItmDest,
Expand Down Expand Up @@ -54,14 +48,15 @@ cfg_if::cfg_if! {
use defmt_rtt as _; // global logger
use panic_probe as _;
pub use defmt::Logger;
pub use defmt::println;

#[allow(dead_code)]
pub fn init() {}
}
else if #[cfg(all(feature = "log-rtt", not(feature = "defmt")))] {
// TODO
}
else if #[cfg(any(feature = "log-semihost"))] {
else if #[cfg(feature = "log-semihost")] {
use panic_semihosting as _;

use lazy_static::lazy_static;
Expand All @@ -80,6 +75,16 @@ cfg_if::cfg_if! {
};
}

#[allow(unused_macros)]
macro_rules! println {
($($tt:tt)*) => {
cortex_m_semihosting::hprintln!($($tt,)*).unwrap();
};
}

#[allow(unused_imports)]
pub(crate) use println;

#[allow(dead_code)]
pub fn init() {
cortex_m_log::log::init(&LOGGER).unwrap();
Expand Down

0 comments on commit 1bfa6d1

Please sign in to comment.