Add ADC example for STM32F0

This commit is contained in:
Matthew W. Samsonoff 2022-09-13 23:10:29 -04:00 committed by Grant Miller
parent 5d9ae3dbdb
commit 7e9e628eb9

View File

@ -0,0 +1,24 @@
#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
use defmt::*;
use embassy_executor::Spawner;
use embassy_stm32::adc::Adc;
use embassy_time::{Delay, Duration, Timer};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
info!("Hello World!");
let mut adc = Adc::new(p.ADC, &mut Delay);
let mut pin = p.PA1;
loop {
let v = adc.read(&mut pin);
info!("--> {} - {} mV", v, adc.to_millivolts(v));
Timer::after(Duration::from_millis(100)).await;
}
}