File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -280,8 +280,11 @@ impl ADC {
280
280
pub fn to_degrees_centigrade ( & self , sample : u16 ) -> f32 {
281
281
let sample = ( u32:: from ( sample) * self . calibrated_vdda ) / VDDA_CALIB_MV ;
282
282
( VtempCal130 :: TEMP_DEGREES - VtempCal30 :: TEMP_DEGREES ) as f32
283
- / ( VtempCal130 :: get ( ) . read ( ) - VtempCal30 :: get ( ) . read ( ) ) as f32
284
- * ( sample - u32:: from ( VtempCal30 :: get ( ) . read ( ) ) ) as f32
283
+ // as signed because RM0351 doesn't specify against this being an
284
+ // inverse relation (which would result in a negative differential)
285
+ / ( VtempCal130 :: get ( ) . read ( ) as i32 - VtempCal30 :: get ( ) . read ( ) as i32 ) as f32
286
+ // this can definitely be negative so must be done as a signed value
287
+ * ( sample as i32 - VtempCal30 :: get ( ) . read ( ) as i32 ) as f32
285
288
+ 30.0
286
289
}
287
290
You can’t perform that action at this time.
0 commit comments