aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-11-11 16:20:02 +0000
committerGitHub <[email protected]>2021-11-11 16:20:02 +0000
commit8193885cb5c1e4faa3ce884ccc6922b808208804 (patch)
treee486d26b62dee3e969e9aa1dfe39dcf26247a9be /examples
parent96e2f0dfc59d2e99b10cc2dd78ea0e4c16a1e15e (diff)
parentc14642cffcd7f6171ecfb107dbbd8a29ec5e2540 (diff)
Merge #482
482: Add MCO peripheral. r=Dirbaio a=matoushybl This PR adds an abstraction over STM32 RCC feature called MCO (Microcontroller Clock Output). The clock output can bind to several clock sources and then can be scaled using a prescaler. Given that from the embassy ecosystem the RCC is generaly invisible to the user, the MCO was implemented as a separate peripheral bound to the pin where the clock should appear. Co-authored-by: Matous Hybl <[email protected]>
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}