diff options
| author | xoviat <[email protected]> | 2025-11-12 13:14:15 -0600 |
|---|---|---|
| committer | xoviat <[email protected]> | 2025-11-12 13:14:15 -0600 |
| commit | e32f78fde6f8130f1eb3effa131e42b7ca153ba6 (patch) | |
| tree | 615ea29191266cd34dcf7bb7b259204e2a125abe /examples/stm32u0 | |
| parent | 2d73fe88935bcc42452907b42a7de5a9fa5ab1f8 (diff) | |
stm32/adc: extract into common
add common low-level interface for adc
Diffstat (limited to 'examples/stm32u0')
| -rw-r--r-- | examples/stm32u0/src/bin/adc.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/stm32u0/src/bin/adc.rs b/examples/stm32u0/src/bin/adc.rs index 4fbc6f17f..53bd37303 100644 --- a/examples/stm32u0/src/bin/adc.rs +++ b/examples/stm32u0/src/bin/adc.rs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_stm32::Config; | 5 | use embassy_stm32::Config; |
| 6 | use embassy_stm32::adc::{Adc, Resolution, SampleTime}; | 6 | use embassy_stm32::adc::{Adc, AdcConfig, Resolution, SampleTime}; |
| 7 | use embassy_time::Duration; | 7 | use embassy_time::Duration; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| @@ -18,8 +18,9 @@ fn main() -> ! { | |||
| 18 | } | 18 | } |
| 19 | let p = embassy_stm32::init(config); | 19 | let p = embassy_stm32::init(config); |
| 20 | 20 | ||
| 21 | let mut adc = Adc::new(p.ADC1); | 21 | let mut config = AdcConfig::default(); |
| 22 | adc.set_resolution(Resolution::BITS8); | 22 | config.resolution = Some(Resolution::BITS8); |
| 23 | let mut adc = Adc::new_with_config(p.ADC1, config); | ||
| 23 | let mut channel = p.PC0; | 24 | let mut channel = p.PC0; |
| 24 | 25 | ||
| 25 | loop { | 26 | loop { |
