embassy/examples/stm32f4/src/bin/mco.rs

31 lines
886 B
Rust
Raw Normal View History

2023-04-03 16:41:25 +02:00
#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
use defmt::*;
use embassy_executor::Spawner;
use embassy_stm32::gpio::{Level, Output, Speed};
2023-10-07 01:15:24 +02:00
use embassy_stm32::rcc::{Mco, Mco1Source, Mco2Source, McoPrescaler};
2023-04-03 16:41:25 +02:00
use embassy_time::{Duration, Timer};
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
info!("Hello World!");
2023-10-07 01:15:24 +02:00
let _mco1 = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, McoPrescaler::DIV1);
let _mco2 = Mco::new(p.MCO2, p.PC9, Mco2Source::PLL, McoPrescaler::DIV4);
2023-04-03 16:41:25 +02:00
let mut led = Output::new(p.PB7, Level::High, Speed::Low);
loop {
info!("high");
led.set_high();
Timer::after(Duration::from_millis(300)).await;
info!("low");
led.set_low();
Timer::after(Duration::from_millis(300)).await;
}
}