@@ -5,8 +5,7 @@ use stm32g4xx_hal::{
5
5
//delay::{DelayExt, SYSTDelayExt},
6
6
gpio:: { self , ExtiPin , GpioExt , Input , SignalEdge } ,
7
7
rcc:: RccExt ,
8
- stm32,
9
- stm32:: { interrupt, Interrupt } ,
8
+ stm32:: { self , interrupt, Interrupt } ,
10
9
syscfg:: SysCfgExt ,
11
10
} ;
12
11
@@ -52,7 +51,21 @@ fn main() -> ! {
52
51
utils:: logger:: init ( ) ;
53
52
54
53
let mut dp = stm32:: Peripherals :: take ( ) . expect ( "cannot take peripherals" ) ;
54
+
55
+ // Workaround for RTT when using wfi instruction
56
+ // Enable the debug sleep bits in DBGMCU,
57
+ // then enable DMA peripheral clock in AHB1ENR
58
+ dp. DBGMCU . cr ( ) . modify ( |_, w| {
59
+ w. dbg_sleep ( ) . set_bit ( ) ;
60
+ w. dbg_stop ( ) . set_bit ( ) ;
61
+ w. dbg_standby ( ) . set_bit ( )
62
+ } ) ;
63
+
55
64
let mut rcc = dp. RCC . constrain ( ) ;
65
+
66
+ // Enable an AHB peripheral clock for debug probe with wfi
67
+ rcc. ahb1enr ( ) . modify ( |_, w| w. dma1en ( ) . set_bit ( ) ) ;
68
+
56
69
let mut syscfg = dp. SYSCFG . constrain ( & mut rcc) ;
57
70
58
71
println ! ( "Led Init" ) ;
@@ -80,7 +93,7 @@ fn main() -> ! {
80
93
81
94
println ! ( "Start Loop" ) ;
82
95
loop {
83
- // wfi();
96
+ cortex_m :: asm :: wfi ( ) ;
84
97
println ! ( "Check" ) ;
85
98
86
99
if G_LED_ON . load ( Ordering :: Relaxed ) {
0 commit comments