2021-06-10 21:33:43 +02:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
2022-04-02 04:35:06 +02:00
|
|
|
use defmt_rtt as _; // global logger
|
|
|
|
use panic_probe as _;
|
2021-06-10 21:33:43 +02:00
|
|
|
|
2022-04-02 04:35:06 +02:00
|
|
|
use defmt::*;
|
2021-07-24 13:57:11 +02:00
|
|
|
use embassy::time::Delay;
|
2021-06-10 21:33:43 +02:00
|
|
|
use embassy_stm32::adc::{Adc, Resolution};
|
2021-07-29 15:54:11 +02:00
|
|
|
use embassy_stm32::pac;
|
2021-06-10 21:33:43 +02:00
|
|
|
|
2021-07-29 15:54:11 +02:00
|
|
|
#[cortex_m_rt::entry]
|
|
|
|
fn main() -> ! {
|
2021-07-24 13:57:11 +02:00
|
|
|
info!("Hello World!");
|
2021-06-10 21:33:43 +02:00
|
|
|
|
2021-07-23 14:24:38 +02:00
|
|
|
unsafe {
|
|
|
|
pac::RCC.ccipr().modify(|w| {
|
|
|
|
w.set_adcsel(0b11);
|
|
|
|
});
|
2021-07-24 13:57:11 +02:00
|
|
|
pac::RCC.ahb2enr().modify(|w| w.set_adcen(true));
|
2021-07-23 14:24:38 +02:00
|
|
|
}
|
2021-06-10 21:33:43 +02:00
|
|
|
|
2021-07-29 15:54:11 +02:00
|
|
|
let p = embassy_stm32::init(Default::default());
|
|
|
|
|
2021-07-24 13:57:11 +02:00
|
|
|
let mut adc = Adc::new(p.ADC1, &mut Delay);
|
2021-06-10 21:33:43 +02:00
|
|
|
//adc.enable_vref();
|
|
|
|
adc.set_resolution(Resolution::EightBit);
|
|
|
|
let mut channel = p.PC0;
|
|
|
|
|
|
|
|
loop {
|
|
|
|
let v = adc.read(&mut channel);
|
|
|
|
info!("--> {}", v);
|
|
|
|
}
|
|
|
|
}
|