blob: 42766a5e3d1688e145ee0d184793eab7b81c91bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#![no_std]
#![no_main]
use defmt::*;
use embassy_stm32::Config;
use embassy_stm32::adc::{Adc, AdcConfig, Resolution, SampleTime};
use {defmt_rtt as _, panic_probe as _};
#[cortex_m_rt::entry]
fn main() -> ! {
info!("Hello World!");
let mut config = Config::default();
{
use embassy_stm32::rcc::*;
config.rcc.mux.adcsel = mux::Adcsel::SYS;
}
let p = embassy_stm32::init(config);
let mut config = AdcConfig::default();
config.resolution = Some(Resolution::BITS8);
let mut adc = Adc::new_with_config(p.ADC1, config);
//adc.enable_vref();
let mut channel = p.PC0;
loop {
let v = adc.blocking_read(&mut channel, SampleTime::from_bits(0));
info!("--> {}", v);
}
}
|