diff options
author | Matous Hybl <hyblmatous@gmail.com> | 2022-05-18 18:34:36 +0200 |
---|---|---|
committer | Matous Hybl <hyblmatous@gmail.com> | 2022-05-18 18:34:36 +0200 |
commit | 53f65d8b09c15fcedefd41d721f53ebd296229de (patch) | |
tree | bef37604fc723817a9f51588823a4bbfafa33f0b /examples | |
parent | b7a27113f054de558bd0649ea98462544e9129fb (diff) | |
download | embassy-53f65d8b09c15fcedefd41d721f53ebd296229de.zip |
Automatically set ADC clock prescaler on v2 ADC to respect max frequency
Diffstat (limited to 'examples')
-rw-r--r-- | examples/stm32f7/src/bin/adc.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/examples/stm32f7/src/bin/adc.rs b/examples/stm32f7/src/bin/adc.rs new file mode 100644 index 00000000..87f5d30d --- /dev/null +++ b/examples/stm32f7/src/bin/adc.rs @@ -0,0 +1,26 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use defmt_rtt as _; // global logger +use panic_probe as _; + +use defmt::*; +use embassy::executor::Spawner; +use embassy::time::{Delay, Duration, Timer}; +use embassy_stm32::adc::Adc; +use embassy_stm32::Peripherals; + +#[embassy::main] +async fn main(_spawner: Spawner, p: Peripherals) { + info!("Hello World!"); + + let mut adc = Adc::new(p.ADC1, &mut Delay); + let mut pin = p.PA3; + + loop { + let v = adc.read(&mut pin); + info!("--> {} - {} mV", v, adc.to_millivolts(v)); + Timer::after(Duration::from_millis(100)).await; + } +} |