@@ -267,19 +267,21 @@ impl<'a> Adc<'a> {
267
267
sc3. set_bit ( 7 , true ) ;
268
268
sc3
269
269
} ) ;
270
- }
271
- while self . reg . sc3 . read ( ) . get_bit ( 7 ) { }
270
+ while self . reg . sc3 . read ( ) . get_bit ( 7 ) { }
272
271
273
- if self . reg . sc3 . read ( ) . get_bit ( 6 ) {
274
- return Err ( ( ) )
272
+ if self . reg . sc3 . read ( ) . get_bit ( 6 ) {
273
+ return Err ( ( ) )
274
+ }
275
275
}
276
276
277
- let mut calib = self . reg . clp0 . read ( ) +
278
- self . reg . clp1 . read ( ) +
279
- self . reg . clp2 . read ( ) +
280
- self . reg . clp3 . read ( ) +
281
- self . reg . clp4 . read ( ) +
282
- self . reg . clps . read ( ) ;
277
+ let mut calib = unsafe {
278
+ self . reg . clp0 . read ( ) +
279
+ self . reg . clp1 . read ( ) +
280
+ self . reg . clp2 . read ( ) +
281
+ self . reg . clp3 . read ( ) +
282
+ self . reg . clp4 . read ( ) +
283
+ self . reg . clps . read ( )
284
+ } ;
283
285
calib >>= 1 ;
284
286
calib |= 0x8000 ;
285
287
unsafe { self . reg . pg . write ( calib) ; }
@@ -296,11 +298,11 @@ impl<'a> Adc<'a> {
296
298
}
297
299
298
300
pub fn is_conv_done ( & mut self ) -> bool {
299
- self . reg . sc1a . read ( ) . get_bit ( 7 )
301
+ unsafe { self . reg . sc1a . read ( ) . get_bit ( 7 ) }
300
302
}
301
303
302
304
pub fn read ( & mut self ) -> u32 {
303
- self . reg . ra . read ( )
305
+ unsafe { self . reg . ra . read ( ) }
304
306
}
305
307
}
306
308
@@ -464,29 +466,33 @@ impl<'a,'b> AdcDiff<'a,'b> {
464
466
sc3. set_bit ( 7 , true ) ;
465
467
sc3
466
468
} ) ;
467
- }
468
- while self . reg . sc3 . read ( ) . get_bit ( 7 ) { }
469
+ while self . reg . sc3 . read ( ) . get_bit ( 7 ) { }
469
470
470
- if self . reg . sc3 . read ( ) . get_bit ( 6 ) {
471
- return Err ( ( ) )
471
+ if self . reg . sc3 . read ( ) . get_bit ( 6 ) {
472
+ return Err ( ( ) )
473
+ }
472
474
}
473
475
474
- let mut calib_p = self . reg . clp0 . read ( ) +
475
- self . reg . clp1 . read ( ) +
476
- self . reg . clp2 . read ( ) +
477
- self . reg . clp3 . read ( ) +
478
- self . reg . clp4 . read ( ) +
479
- self . reg . clps . read ( ) ;
476
+ let mut calib_p = unsafe {
477
+ self . reg . clp0 . read ( ) +
478
+ self . reg . clp1 . read ( ) +
479
+ self . reg . clp2 . read ( ) +
480
+ self . reg . clp3 . read ( ) +
481
+ self . reg . clp4 . read ( ) +
482
+ self . reg . clps . read ( )
483
+ } ;
480
484
calib_p >>= 1 ;
481
485
calib_p |= 0x8000 ;
482
486
unsafe { self . reg . pg . write ( calib_p) ; }
483
487
484
- let mut calib_m = self . reg . clm0 . read ( ) +
485
- self . reg . clm1 . read ( ) +
486
- self . reg . clm2 . read ( ) +
487
- self . reg . clm3 . read ( ) +
488
- self . reg . clm4 . read ( ) +
489
- self . reg . clms . read ( ) ;
488
+ let mut calib_m = unsafe {
489
+ self . reg . clm0 . read ( ) +
490
+ self . reg . clm1 . read ( ) +
491
+ self . reg . clm2 . read ( ) +
492
+ self . reg . clm3 . read ( ) +
493
+ self . reg . clm4 . read ( ) +
494
+ self . reg . clms . read ( )
495
+ } ;
490
496
calib_m >>= 1 ;
491
497
calib_m |= 0x8000 ;
492
498
unsafe { self . reg . mg . write ( calib_m) ; }
@@ -503,10 +509,10 @@ impl<'a,'b> AdcDiff<'a,'b> {
503
509
}
504
510
505
511
pub fn is_conv_done ( & mut self ) -> bool {
506
- self . reg . sc1a . read ( ) . get_bit ( 7 )
512
+ unsafe { self . reg . sc1a . read ( ) . get_bit ( 7 ) }
507
513
}
508
514
509
515
pub fn read ( & mut self ) -> i32 {
510
- self . reg . ra . read ( ) as i32
516
+ unsafe { self . reg . ra . read ( ) as i32 }
511
517
}
512
518
}
0 commit comments