aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMatous Hybl <[email protected]>2021-11-08 23:43:03 +0100
committerMatous Hybl <[email protected]>2021-11-11 11:34:09 +0100
commitc14642cffcd7f6171ecfb107dbbd8a29ec5e2540 (patch)
treee40d81aad3aa3abd11c74485b4b71f83e9f47555 /examples
parentdb889da0446833ff219e652bd68c397af858b999 (diff)
Add MCO peripheral.
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32h7/src/bin/mco.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/stm32h7/src/bin/mco.rs b/examples/stm32h7/src/bin/mco.rs
new file mode 100644
index 000000000..4cecd9b04
--- /dev/null
+++ b/examples/stm32h7/src/bin/mco.rs
@@ -0,0 +1,32 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5#[path = "../example_common.rs"]
6mod example_common;
7use embassy::executor::Spawner;
8use embassy::time::{Duration, Timer};
9use embassy_stm32::gpio::{Level, Output, Speed};
10use embassy_stm32::rcc::{Mco, Mco1Source, McoClock};
11use embassy_stm32::Peripherals;
12use embedded_hal::digital::v2::OutputPin;
13use example_common::*;
14
15#[embassy::main]
16async fn main(_spawner: Spawner, p: Peripherals) {
17 info!("Hello World!");
18
19 let mut led = Output::new(p.PB14, Level::High, Speed::Low);
20
21 let _mco = Mco::new(p.MCO1, p.PA8, Mco1Source::Hsi, McoClock::Divided(8));
22
23 loop {
24 info!("high");
25 unwrap!(led.set_high());
26 Timer::after(Duration::from_millis(500)).await;
27
28 info!("low");
29 unwrap!(led.set_low());
30 Timer::after(Duration::from_millis(500)).await;
31 }
32}