1- //This example puts the timer in PWM mode using the specified pin with a frequency of 100Hz and a duty cycle of 50%.
2- #![ no_main]
31#![ no_std]
2+ #![ no_main]
3+
4+ /// Add description
5+
6+ #[ path = "../utils/mod.rs" ]
7+ mod utils;
48
59use cortex_m_rt:: entry;
610
11+ use defmt_rtt as _; // global logger
12+ use panic_probe as _;
13+
14+ use utils:: logger:: info;
15+
716#[ entry]
817fn main ( ) -> ! {
918 use fugit:: ExtU32 ;
@@ -16,9 +25,7 @@ fn main() -> ! {
1625 use hal:: hrtim:: output:: HrOutput ;
1726 use hal:: hrtim:: timer:: HrTimer ;
1827 use hal:: hrtim:: HrPwmAdvExt ;
19- use hal:: hrtim:: {
20- event:: TimerAResetEventSource , HrTimerMode , MasterPreloadSource , PreloadSource , Pscl4 ,
21- } ;
28+ use hal:: hrtim:: { HrTimerMode , MasterPreloadSource , PreloadSource , Pscl4 } ;
2229 use hal:: prelude:: * ;
2330 use hal:: pwr:: PwrExt ;
2431 use hal:: rcc;
@@ -89,7 +96,7 @@ fn main() -> ! {
8996 . finalize ( & mut hr_control) ;
9097
9198 // Run in sync with master timer
92- timer. enable_reset_event ( TimerAResetEventSource :: MasterPeriod ) ;
99+ timer. enable_reset_event ( & mtimer ) ;
93100
94101 out1. enable_rst_event ( & mcr1) ; // Set low on compare match with cr1
95102 out2. enable_rst_event ( & mcr1) ;
@@ -101,13 +108,13 @@ fn main() -> ! {
101108 out2. enable ( ) ;
102109
103110 let tima = unsafe { & * stm32g4xx_hal:: stm32:: HRTIM_TIMA :: ptr ( ) } ;
104- defmt :: info!( "set1r: {}" , tima. seta1r. read( ) . bits( ) ) ;
105- defmt :: info!( "rst1r: {}" , tima. rsta1r. read( ) . bits( ) ) ;
111+ info ! ( "set1r: {}" , tima. seta1r. read( ) . bits( ) ) ;
112+ info ! ( "rst1r: {}" , tima. rsta1r. read( ) . bits( ) ) ;
106113
107- defmt :: info!( "set2r: {}" , tima. seta2r. read( ) . bits( ) ) ;
108- defmt :: info!( "rst2r: {}" , tima. rsta2r. read( ) . bits( ) ) ;
114+ info ! ( "set2r: {}" , tima. seta2r. read( ) . bits( ) ) ;
115+ info ! ( "rst2r: {}" , tima. rsta2r. read( ) . bits( ) ) ;
109116
110- defmt :: info!( "Running" ) ;
117+ info ! ( "Running" ) ;
111118
112119 loop {
113120 // Step frequency from 18kHz to about 180kHz(half of that when only looking at one pin)
@@ -119,7 +126,7 @@ fn main() -> ! {
119126 mtimer. set_period ( new_period) ;
120127 timer. set_period ( new_period - 1000 ) ;
121128
122- defmt :: info!(
129+ info ! (
123130 "period: {}, duty: {}, get_duty: {}, get_period: {}" ,
124131 new_period,
125132 new_period / 3 ,
0 commit comments