2023-08-21 04:31:47 +02:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
|
|
|
use defmt::*;
|
|
|
|
use embassy_executor::Spawner;
|
|
|
|
use embassy_stm32::adc::{Adc, SampleTime};
|
|
|
|
use embassy_stm32::rcc::{AdcClockSource, ClockSrc, Pll, PllM, PllN, PllR, PllSrc};
|
|
|
|
use embassy_stm32::Config;
|
2023-10-15 01:57:25 +02:00
|
|
|
use embassy_time::{Delay, Timer};
|
2023-08-21 04:31:47 +02:00
|
|
|
use {defmt_rtt as _, panic_probe as _};
|
|
|
|
|
|
|
|
#[embassy_executor::main]
|
|
|
|
async fn main(_spawner: Spawner) {
|
|
|
|
let mut config = Config::default();
|
|
|
|
|
|
|
|
config.rcc.pll = Some(Pll {
|
|
|
|
source: PllSrc::HSI16,
|
2023-10-09 02:48:22 +02:00
|
|
|
prediv_m: PllM::DIV4,
|
|
|
|
mul_n: PllN::MUL85,
|
2023-08-21 04:31:47 +02:00
|
|
|
div_p: None,
|
|
|
|
div_q: None,
|
|
|
|
// Main system clock at 170 MHz
|
2023-10-09 02:48:22 +02:00
|
|
|
div_r: Some(PllR::DIV2),
|
2023-08-21 04:31:47 +02:00
|
|
|
});
|
|
|
|
|
2023-10-11 00:12:33 +02:00
|
|
|
config.rcc.adc12_clock_source = AdcClockSource::SYSCLK;
|
2023-08-21 04:31:47 +02:00
|
|
|
config.rcc.mux = ClockSrc::PLL;
|
|
|
|
|
|
|
|
let mut p = embassy_stm32::init(config);
|
|
|
|
info!("Hello World!");
|
|
|
|
|
|
|
|
let mut adc = Adc::new(p.ADC2, &mut Delay);
|
|
|
|
adc.set_sample_time(SampleTime::Cycles32_5);
|
|
|
|
|
|
|
|
loop {
|
|
|
|
let measured = adc.read(&mut p.PA7);
|
|
|
|
info!("measured: {}", measured);
|
2023-10-15 01:57:25 +02:00
|
|
|
Timer::after_millis(500).await;
|
2023-08-21 04:31:47 +02:00
|
|
|
}
|
|
|
|
}
|