@@ -5,8 +5,7 @@ use stm32g4xx_hal::{
55 //delay::{DelayExt, SYSTDelayExt},
66 gpio:: { self , ExtiPin , GpioExt , Input , SignalEdge } ,
77 rcc:: RccExt ,
8- stm32,
9- stm32:: { interrupt, Interrupt } ,
8+ stm32:: { self , interrupt, Interrupt } ,
109 syscfg:: SysCfgExt ,
1110} ;
1211
@@ -52,7 +51,21 @@ fn main() -> ! {
5251 utils:: logger:: init ( ) ;
5352
5453 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+
5564 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+
5669 let mut syscfg = dp. SYSCFG . constrain ( & mut rcc) ;
5770
5871 println ! ( "Led Init" ) ;
@@ -80,7 +93,7 @@ fn main() -> ! {
8093
8194 println ! ( "Start Loop" ) ;
8295 loop {
83- // wfi();
96+ cortex_m :: asm :: wfi ( ) ;
8497 println ! ( "Check" ) ;
8598
8699 if G_LED_ON . load ( Ordering :: Relaxed ) {
0 commit comments