File tree Expand file tree Collapse file tree 3 files changed +16
-11
lines changed Expand file tree Collapse file tree 3 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 5
5
6
6
extern crate cortex_m;
7
7
extern crate cortex_m_rt as rt;
8
- extern crate panic_semihosting;
9
8
extern crate stm32g4xx_hal as hal;
10
9
11
- use cortex_m_semihosting:: hprintln;
12
10
use rt:: entry;
13
11
14
- use defmt_rtt as _;
12
+ #[ macro_use]
13
+ mod utils;
14
+
15
+ use utils:: logger:: println;
15
16
16
17
#[ entry]
17
18
fn main ( ) -> ! {
18
- hprintln ! ( "Hello, STM32G4!" ) . unwrap ( ) ;
19
+ let _ = println ! ( "Hello, STM32G4!" ) ;
19
20
20
21
#[ allow( clippy:: empty_loop) ]
21
22
loop { }
Original file line number Diff line number Diff line change 1
1
#![ no_main]
2
2
#![ no_std]
3
3
4
- use defmt_rtt as _;
5
-
6
- use panic_probe as _;
7
-
8
4
use stm32g4 as _;
9
5
10
- use defmt:: Format ;
6
+ #[ macro_use]
7
+ mod utils;
8
+
9
+ use utils:: logger;
11
10
11
+ #[ cfg( feature = "defmt" ) ]
12
12
#[ defmt:: panic_handler]
13
13
fn panic ( ) -> ! {
14
14
cortex_m:: asm:: udf ( )
@@ -22,8 +22,7 @@ pub fn exit() -> ! {
22
22
23
23
#[ cortex_m_rt:: entry]
24
24
fn main ( ) -> ! {
25
- defmt :: info!( "main" ) ;
25
+ logger :: info!( "main" ) ;
26
26
27
27
panic ! ( "Something bad" ) ;
28
- // defmt::panic!()
29
28
}
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ cfg_if::cfg_if! {
38
38
} ;
39
39
}
40
40
41
+ #[ allow( dead_code) ]
41
42
pub fn init( ) {
42
43
cortex_m_log:: log:: init( & LOGGER ) . unwrap( ) ;
43
44
}
@@ -48,6 +49,7 @@ cfg_if::cfg_if! {
48
49
use panic_probe as _;
49
50
pub use defmt:: Logger ;
50
51
52
+ #[ allow( dead_code) ]
51
53
pub fn init( ) { }
52
54
}
53
55
else if #[ cfg( all( feature = "log-rtt" , not( feature = "defmt" ) ) ) ] {
@@ -72,12 +74,15 @@ cfg_if::cfg_if! {
72
74
} ;
73
75
}
74
76
77
+ #[ allow( dead_code) ]
75
78
pub fn init( ) {
76
79
cortex_m_log:: log:: init( & LOGGER ) . unwrap( ) ;
77
80
}
78
81
}
79
82
else {
80
83
use panic_halt as _;
84
+
85
+ #[ allow( dead_code) ]
81
86
pub fn init( ) { }
82
87
}
83
88
}
You can’t perform that action at this time.
0 commit comments