summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMatous Hybl <hyblmatous@gmail.com>2022-05-18 18:34:36 +0200
committerMatous Hybl <hyblmatous@gmail.com>2022-05-18 18:34:36 +0200
commit53f65d8b09c15fcedefd41d721f53ebd296229de (patch)
treebef37604fc723817a9f51588823a4bbfafa33f0b /examples
parentb7a27113f054de558bd0649ea98462544e9129fb (diff)
downloadembassy-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.rs26
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;
+ }
+}