aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32f4/src/bin
diff options
context:
space:
mode:
authorMathieu Dupont <[email protected]>2023-04-03 16:41:25 +0200
committerMathieu Dupont <[email protected]>2023-04-03 16:41:25 +0200
commit4ce1c5f27dbb06641abddd2b10aebae1511a894b (patch)
treee966a938f732b8aa9a0ee88aa9d6397d192183aa /examples/stm32f4/src/bin
parent0909a6cd3ff6fb953aa2d83fb5da37384ad7dae2 (diff)
Add MCO support for L4 and F4 families
Diffstat (limited to 'examples/stm32f4/src/bin')
-rw-r--r--examples/stm32f4/src/bin/mco.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/examples/stm32f4/src/bin/mco.rs b/examples/stm32f4/src/bin/mco.rs
new file mode 100644
index 000000000..5d780f94d
--- /dev/null
+++ b/examples/stm32f4/src/bin/mco.rs
@@ -0,0 +1,31 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use defmt::*;
6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_stm32::rcc::{Mco, Mco1Source, Mco2Source, McoClock};
9use embassy_time::{Duration, Timer};
10use {defmt_rtt as _, panic_probe as _};
11
12#[embassy_executor::main]
13async fn main(_spawner: Spawner) {
14 let p = embassy_stm32::init(Default::default());
15 info!("Hello World!");
16
17
18 let _mco1 = Mco::new(p.MCO1, p.PA8, Mco1Source::Hsi, McoClock::DIV1);
19 let _mco2 = Mco::new(p.MCO2, p.PC9, Mco2Source::Pll, McoClock::DIV4);
20 let mut led = Output::new(p.PB7, Level::High, Speed::Low);
21
22 loop {
23 info!("high");
24 led.set_high();
25 Timer::after(Duration::from_millis(300)).await;
26
27 info!("low");
28 led.set_low();
29 Timer::after(Duration::from_millis(300)).await;
30 }
31}