mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 08:12:30 +00:00
Update STM32F0 ADC example to use read_internal
This commit is contained in:
parent
511a951246
commit
28b8ac4b62
@ -4,7 +4,7 @@
|
||||
|
||||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::adc::Adc;
|
||||
use embassy_stm32::adc::{Adc, SampleTime};
|
||||
use embassy_time::{Delay, Duration, Timer};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
@ -14,11 +14,14 @@ async fn main(_spawner: Spawner) {
|
||||
info!("Hello World!");
|
||||
|
||||
let mut adc = Adc::new(p.ADC, &mut Delay);
|
||||
adc.set_sample_time(SampleTime::Cycles71_5);
|
||||
let mut pin = p.PA1;
|
||||
let mut vref = adc.enable_temperature(&mut Delay);
|
||||
|
||||
loop {
|
||||
let v = adc.read(&mut pin);
|
||||
info!("--> {} - {} mV", v, adc.to_millivolts(v));
|
||||
let r = adc.read_internal(&mut vref);
|
||||
info!("--> {} - {} mV / vref = {} - {} mV", v, adc.to_millivolts(v), r, adc.to_millivolts(r));
|
||||
Timer::after(Duration::from_millis(100)).await;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user