File tree Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change 3
3
4
4
#![ deny( missing_docs) ]
5
5
6
- /// This is the address the VREF calibration value is stored in at the factory
7
- const VREFCAL : * const u16 = 0x1FFF_7A2A as * const u16 ;
8
6
/// This is the test voltage, in millivolts of the calibration done at the factory
9
7
const VDDA_CALIB : u32 = 3300 ;
10
8
@@ -28,13 +26,9 @@ use embedded_hal::adc::{
28
26
use crate :: {
29
27
stm32,
30
28
gpio:: * ,
29
+ signature:: VrefCal ,
31
30
} ;
32
31
33
- /// Fetches the vref calibration value stored at the factory
34
- fn get_vref_cal ( ) -> u32 {
35
- unsafe { u32:: from ( ptr:: read ( VREFCAL ) ) }
36
- }
37
-
38
32
/// Vref internal signal, used for calibration
39
33
pub struct Vref ;
40
34
@@ -687,10 +681,10 @@ macro_rules! adc {
687
681
self . enable_temperature_and_vref( ) ;
688
682
}
689
683
690
- let vref_cal = get_vref_cal ( ) ;
684
+ let vref_cal = VrefCal :: get ( ) . read ( ) ;
691
685
let vref_samp = self . read( & mut Vref ) . unwrap( ) ; //This can't actually fail, it's just in a result to satisfy hal trait
692
686
693
- self . calibrated_vdda = ( VDDA_CALIB * vref_cal) / u32 :: from( vref_samp) ;
687
+ self . calibrated_vdda = ( VDDA_CALIB * u32 :: from ( vref_cal) ) / u32 :: from( vref_samp) ;
694
688
if !vref_en {
695
689
self . disable_temperature_and_vref( ) ;
696
690
}
You can’t perform that action at this time.
0 commit comments