@@ -5,7 +5,7 @@ use core::marker::PhantomData;
55
66use super :: {
77 capture:: { self , HrCapt , HrCapture } ,
8- control:: HrPwmControl ,
8+ control:: HrPwmCtrl ,
99 HrtimPrescaler ,
1010} ;
1111
@@ -42,13 +42,13 @@ pub trait HrTimer {
4242 fn set_period ( & mut self , period : u16 ) ;
4343
4444 /// Start timer
45- fn start ( & mut self , _hr_control : & mut HrPwmControl ) ;
45+ fn start ( & mut self , _hr_control : & mut HrPwmCtrl ) ;
4646
4747 /// Stop timer
48- fn stop ( & mut self , _hr_control : & mut HrPwmControl ) ;
48+ fn stop ( & mut self , _hr_control : & mut HrPwmCtrl ) ;
4949
5050 /// Stop timer and reset counter
51- fn stop_and_reset ( & mut self , _hr_control : & mut HrPwmControl ) ;
51+ fn stop_and_reset ( & mut self , _hr_control : & mut HrPwmCtrl ) ;
5252
5353 fn clear_repetition_interrupt ( & mut self ) ;
5454
@@ -57,6 +57,21 @@ pub trait HrTimer {
5757
5858 /// Make a handle to this timers period event to use as adc trigger
5959 fn as_period_adc_trigger ( & self ) -> super :: adc_trigger:: TimerPeriod < Self :: Timer > ;
60+
61+ /// Disable register updates
62+ ///
63+ /// Calling this function temporarily disables the transfer from preload to active registers,
64+ /// whatever the selected update event. This allows to modify several registers.
65+ /// The regular update event takes place once [`Self::enable_register_updates`] is called.
66+ fn disable_register_updates ( & mut self , _hr_control : & mut HrPwmCtrl ) ;
67+
68+ /// Enable register updates
69+ ///
70+ /// See [`Self::disable_register_updates`].
71+ ///
72+ /// NOTE: Register updates are enabled by default, no need to call this
73+ /// unless [`Self::disable_register_updates`] has been called.
74+ fn enable_register_updates ( & mut self , _hr_control : & mut HrPwmCtrl ) ;
6075}
6176
6277pub trait HrSlaveTimer : HrTimer {
@@ -106,6 +121,7 @@ macro_rules! hrtim_timer {
106121 $repie: ident,
107122 $icr: ident,
108123 $repc: ident,
124+ $tXudis: ident,
109125 $( ( $rstXr: ident) ) * ,
110126 ) +) => { $(
111127 impl <PSCL : HrtimPrescaler , CPT1 , CPT2 > HrTimer for HrTim <$TIMX, PSCL , CPT1 , CPT2 > {
@@ -124,7 +140,7 @@ macro_rules! hrtim_timer {
124140 }
125141
126142 /// Start timer
127- fn start( & mut self , _hr_control: & mut HrPwmControl ) {
143+ fn start( & mut self , _hr_control: & mut HrPwmCtrl ) {
128144 // Start timer
129145
130146 // SAFETY: Since we hold _hr_control there is no risk for a race condition
@@ -133,15 +149,15 @@ macro_rules! hrtim_timer {
133149 }
134150
135151 /// Stop timer
136- fn stop( & mut self , _hr_control: & mut HrPwmControl ) {
152+ fn stop( & mut self , _hr_control: & mut HrPwmCtrl ) {
137153 // Stop counter
138154 // SAFETY: Since we hold _hr_control there is no risk for a race condition
139155 let master = unsafe { & * HRTIM_MASTER :: ptr( ) } ;
140156 master. mcr. modify( |_r, w| { w. $tXcen( ) . set_bit( ) } ) ;
141157 }
142158
143159 /// Stop timer and reset counter
144- fn stop_and_reset( & mut self , _hr_control: & mut HrPwmControl ) {
160+ fn stop_and_reset( & mut self , _hr_control: & mut HrPwmCtrl ) {
145161 self . stop( _hr_control) ;
146162
147163 // Reset counter
@@ -164,6 +180,29 @@ macro_rules! hrtim_timer {
164180
165181 tim. $icr. write( |w| w. $repc( ) . set_bit( ) ) ;
166182 }
183+
184+ /// Disable register updates
185+ ///
186+ /// Calling this function temporarily disables the transfer from preload to active registers,
187+ /// whatever the selected update event. This allows to modify several registers.
188+ /// The regular update event takes place once [`Self::enable_register_updates`] is called.
189+ fn disable_register_updates( & mut self , _hr_control: & mut HrPwmCtrl ) {
190+ use super :: HRTIM_COMMON ;
191+ let common = unsafe { & * HRTIM_COMMON :: ptr( ) } ;
192+ common. cr1. modify( |_r, w| w. $tXudis( ) . set_bit( ) ) ;
193+ }
194+
195+ /// Enable register updates
196+ ///
197+ /// See [`Self::disable_register_updates`].
198+ ///
199+ /// NOTE: Register updates are enabled by default, no need to call this
200+ /// unless [`Self::disable_register_updates`] has been called.
201+ fn enable_register_updates<' a>( & mut self , _hr_control: & mut HrPwmCtrl ) {
202+ use super :: HRTIM_COMMON ;
203+ let common = unsafe { & * HRTIM_COMMON :: ptr( ) } ;
204+ common. cr1. modify( |_r, w| w. $tXudis( ) . clear_bit( ) ) ;
205+ }
167206 }
168207
169208 impl <PSCL , CPT1 , CPT2 > HrTim <$TIMX, PSCL , CPT1 , CPT2 > {
@@ -290,14 +329,14 @@ use super::adc_trigger::Adc579Trigger as Adc579;
290329use super :: adc_trigger:: Adc6810Trigger as Adc6810 ;
291330
292331hrtim_timer ! {
293- HRTIM_MASTER : mcntr, mcnt, mper, mcen, mper, mrep, mrep, mdier, mrepie, micr, mrepc, ,
294-
295- HRTIM_TIMA : cntar, cntx, perar, tacen, perx, repar, repx, timadier, repie, timaicr, repc, ( rstar) ,
296- HRTIM_TIMB : cntr, cntx, perbr, tbcen, perx, repbr, repx, timbdier, repie, timbicr, repc, ( rstbr) ,
297- HRTIM_TIMC : cntcr, cntx, percr, tccen, perx, repcr, repx, timcdier, repie, timcicr, repc, ( rstcr) ,
298- HRTIM_TIMD : cntdr, cntx, perdr, tdcen, perx, repdr, repx, timddier, repie, timdicr, repc, ( rstdr) ,
299- HRTIM_TIME : cnter, cntx, perer, tecen, perx, reper, repx, timedier, repie, timeicr, repc, ( rster) ,
300- HRTIM_TIMF : cntfr, cntx, perfr, tfcen, perx, repfr, repx, timfdier, repie, timficr, repc, ( rstfr) ,
332+ HRTIM_MASTER : mcntr, mcnt, mper, mcen, mper, mrep, mrep, mdier, mrepie, micr, mrepc, mudis , ,
333+
334+ HRTIM_TIMA : cntar, cntx, perar, tacen, perx, repar, repx, timadier, repie, timaicr, repc, taudis , ( rstar) ,
335+ HRTIM_TIMB : cntr, cntx, perbr, tbcen, perx, repbr, repx, timbdier, repie, timbicr, repc, tbudis , ( rstbr) ,
336+ HRTIM_TIMC : cntcr, cntx, percr, tccen, perx, repcr, repx, timcdier, repie, timcicr, repc, tcudis , ( rstcr) ,
337+ HRTIM_TIMD : cntdr, cntx, perdr, tdcen, perx, repdr, repx, timddier, repie, timdicr, repc, tdudis , ( rstdr) ,
338+ HRTIM_TIME : cnter, cntx, perer, tecen, perx, reper, repx, timedier, repie, timeicr, repc, teudis , ( rster) ,
339+ HRTIM_TIMF : cntfr, cntx, perfr, tfcen, perx, repfr, repx, timfdier, repie, timficr, repc, tfudis , ( rstfr) ,
301340}
302341
303342hrtim_timer_adc_trigger ! {
0 commit comments