Skip to content

Commit fcf93f3

Browse files
committed
Fix more errors with different feature set
1 parent 4328c92 commit fcf93f3

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

examples/hello.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55

66
extern crate cortex_m;
77
extern crate cortex_m_rt as rt;
8-
extern crate panic_semihosting;
98
extern crate stm32g4xx_hal as hal;
109

11-
use cortex_m_semihosting::hprintln;
1210
use rt::entry;
1311

14-
use defmt_rtt as _;
12+
#[macro_use]
13+
mod utils;
14+
15+
use utils::logger::println;
1516

1617
#[entry]
1718
fn main() -> ! {
18-
hprintln!("Hello, STM32G4!").unwrap();
19+
let _ = println!("Hello, STM32G4!");
1920

2021
#[allow(clippy::empty_loop)]
2122
loop {}

examples/panic.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#![no_main]
22
#![no_std]
33

4-
use defmt_rtt as _;
5-
6-
use panic_probe as _;
7-
84
use stm32g4 as _;
95

10-
use defmt::Format;
6+
#[macro_use]
7+
mod utils;
8+
9+
use utils::logger;
1110

11+
#[cfg(feature = "defmt")]
1212
#[defmt::panic_handler]
1313
fn panic() -> ! {
1414
cortex_m::asm::udf()
@@ -22,8 +22,7 @@ pub fn exit() -> ! {
2222

2323
#[cortex_m_rt::entry]
2424
fn main() -> ! {
25-
defmt::info!("main");
25+
logger::info!("main");
2626

2727
panic!("Something bad");
28-
// defmt::panic!()
2928
}

examples/utils/logger.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ cfg_if::cfg_if! {
3838
};
3939
}
4040

41+
#[allow(dead_code)]
4142
pub fn init() {
4243
cortex_m_log::log::init(&LOGGER).unwrap();
4344
}
@@ -48,6 +49,7 @@ cfg_if::cfg_if! {
4849
use panic_probe as _;
4950
pub use defmt::Logger;
5051

52+
#[allow(dead_code)]
5153
pub fn init() {}
5254
}
5355
else if #[cfg(all(feature = "log-rtt", not(feature = "defmt")))] {
@@ -72,12 +74,15 @@ cfg_if::cfg_if! {
7274
};
7375
}
7476

77+
#[allow(dead_code)]
7578
pub fn init() {
7679
cortex_m_log::log::init(&LOGGER).unwrap();
7780
}
7881
}
7982
else {
8083
use panic_halt as _;
84+
85+
#[allow(dead_code)]
8186
pub fn init() {}
8287
}
8388
}

0 commit comments

Comments
 (0)