@@ -178,7 +178,10 @@ macro_rules! make_timer {
178
178
179
179
// The above line raises an update event which will indicate that the timer is already finished.
180
180
// Since this is not the case, it should be cleared.
181
- self . tim. sr( ) . modify( |_, w| w. uif( ) . clear_bit( ) ) ;
181
+ self . tim. sr( ) . write( |w| {
182
+ unsafe { w. bits( !0 ) } ;
183
+ w. uif( ) . clear_bit( )
184
+ } ) ;
182
185
183
186
$tq. initialize( MonoTimerBackend :: <pac:: $timer> { _tim: PhantomData } ) ;
184
187
$overflow. store( 0 , Ordering :: SeqCst ) ;
@@ -231,7 +234,10 @@ macro_rules! make_timer {
231
234
}
232
235
233
236
fn clear_compare_flag( ) {
234
- Self :: tim( ) . sr( ) . modify( |_, w| w. cc2if( ) . clear_bit( ) ) ;
237
+ Self :: tim( ) . sr( ) . write( |w| {
238
+ unsafe { w. bits( !0 ) } ;
239
+ w. cc2if( ) . clear_bit( )
240
+ } ) ;
235
241
}
236
242
237
243
fn pend_interrupt( ) {
@@ -249,13 +255,19 @@ macro_rules! make_timer {
249
255
fn on_interrupt( ) {
250
256
// Full period
251
257
if Self :: tim( ) . sr( ) . read( ) . uif( ) . bit_is_set( ) {
252
- Self :: tim( ) . sr( ) . modify( |_, w| w. uif( ) . clear_bit( ) ) ;
258
+ Self :: tim( ) . sr( ) . write( |w| {
259
+ unsafe { w. bits( !0 ) } ;
260
+ w. uif( ) . clear_bit( )
261
+ } ) ;
253
262
let prev = $overflow. fetch_add( 1 , Ordering :: Relaxed ) ;
254
263
assert!( prev % 2 == 1 , "Monotonic must have missed an interrupt!" ) ;
255
264
}
256
265
// Half period
257
266
if Self :: tim( ) . sr( ) . read( ) . cc1if( ) . bit_is_set( ) {
258
- Self :: tim( ) . sr( ) . modify( |_, w| w. cc1if( ) . clear_bit( ) ) ;
267
+ Self :: tim( ) . sr( ) . write( |w| {
268
+ unsafe { w. bits( !0 ) } ;
269
+ w. cc1if( ) . clear_bit( )
270
+ } ) ;
259
271
let prev = $overflow. fetch_add( 1 , Ordering :: Relaxed ) ;
260
272
assert!( prev % 2 == 0 , "Monotonic must have missed an interrupt!" ) ;
261
273
}
0 commit comments