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

@ -16,9 +16,19 @@ async fn main(_spawner: Spawner) {
let mut adc = Adc::new(p.ADC1, &mut Delay);
let mut pin = p.PA3;
let mut vref = adc.enable_vrefint();
let vref_sample = adc.read_internal(&mut vref);
let convert_to_millivolts = |sample| {
// From http://www.st.com/resource/en/datasheet/DM00273119.pdf
// 6.3.27 Reference voltage
const VREF_MV: u32 = 1210;
(u32::from(sample) * VREF_MV / u32::from(vref_sample)) as u16
};
loop {
let v = adc.read(&mut pin);
info!("--> {} - {} mV", v, adc.to_millivolts(v));
info!("--> {} - {} mV", v, convert_to_millivolts(v));
Timer::after(Duration::from_millis(100)).await;
}
}