stm32/adc: Remove voltage and temperature conversions

This commit is contained in:
Grant Miller
2022-10-23 16:31:10 -05:00
parent ce1cba761c
commit 545cc9326b
7 changed files with 45 additions and 103 deletions

View File

@ -80,15 +80,6 @@ impl super::sealed::InternalChannel<ADC1> for Temperature {
}
impl Temperature {
/// Converts temperature sensor reading in millivolts to degrees celcius
pub fn to_celcius(sample_mv: u16) -> f32 {
// From 6.3.22 Temperature sensor characteristics
const V25: i32 = 760; // mV
const AVG_SLOPE: f32 = 2.5; // mV/C
(sample_mv as i32 - V25) as f32 / AVG_SLOPE + 25.0
}
/// Time needed for temperature sensor readings to stabilize
pub fn start_time_us() -> u32 {
10
@ -172,7 +163,6 @@ impl Prescaler {
pub struct Adc<'d, T: Instance> {
sample_time: SampleTime,
vref_mv: u32,
resolution: Resolution,
phantom: PhantomData<&'d mut T>,
}
@ -200,7 +190,6 @@ where
Self {
sample_time: Default::default(),
resolution: Resolution::default(),
vref_mv: VREF_DEFAULT_MV,
phantom: PhantomData,
}
}
@ -213,18 +202,6 @@ where
self.resolution = resolution;
}
/// Set VREF value in millivolts. This value is used for [to_millivolts()] sample conversion.
///
/// Use this if you have a known precise VREF (VDDA) pin reference voltage.
pub fn set_vref_mv(&mut self, vref_mv: u32) {
self.vref_mv = vref_mv;
}
/// Convert a measurement to millivolts
pub fn to_millivolts(&self, sample: u16) -> u16 {
((u32::from(sample) * self.vref_mv) / self.resolution.to_max_count()) as u16
}
/// Enables internal voltage reference and returns [VrefInt], which can be used in
/// [Adc::read_internal()] to perform conversion.
pub fn enable_vrefint(&self) -> VrefInt {