aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32wl55/src/bin
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2021-08-17 13:14:21 +0200
committerUlf Lilleengen <[email protected]>2021-08-17 16:22:47 +0200
commit61409e2fb6798a8474d32df581e1cabfa04ec565 (patch)
tree6a9bd51971acd3fc6bb36c1f8ec9857b25cc48bb /examples/stm32wl55/src/bin
parent4b74e8fc50b3b1839f118d9b310f793a46adc416 (diff)
Add example for STM32WL55
Diffstat (limited to 'examples/stm32wl55/src/bin')
-rw-r--r--examples/stm32wl55/src/bin/blinky.rs34
-rw-r--r--examples/stm32wl55/src/bin/button.rs40
2 files changed, 74 insertions, 0 deletions
diff --git a/examples/stm32wl55/src/bin/blinky.rs b/examples/stm32wl55/src/bin/blinky.rs
new file mode 100644
index 000000000..b5e5ffcf9
--- /dev/null
+++ b/examples/stm32wl55/src/bin/blinky.rs
@@ -0,0 +1,34 @@
1#![no_std]
2#![no_main]
3#![feature(trait_alias)]
4#![feature(type_alias_impl_trait)]
5#![allow(incomplete_features)]
6
7#[path = "../example_common.rs"]
8mod example_common;
9use embassy::executor::Spawner;
10use embassy::time::{Duration, Timer};
11use embassy_stm32::dbgmcu::Dbgmcu;
12use embassy_stm32::gpio::{Level, Output, Speed};
13use embassy_stm32::Peripherals;
14use embedded_hal::digital::v2::OutputPin;
15use example_common::*;
16
17#[embassy::main]
18async fn main(_spawner: Spawner, p: Peripherals) {
19 info!("Hello World!");
20
21 unsafe { Dbgmcu::enable_all() };
22
23 let mut led = Output::new(p.PB15, Level::High, Speed::Low);
24
25 loop {
26 info!("high");
27 unwrap!(led.set_high());
28 Timer::after(Duration::from_millis(500)).await;
29
30 info!("low");
31 unwrap!(led.set_low());
32 Timer::after(Duration::from_millis(500)).await;
33 }
34}
diff --git a/examples/stm32wl55/src/bin/button.rs b/examples/stm32wl55/src/bin/button.rs
new file mode 100644
index 000000000..90212d3d7
--- /dev/null
+++ b/examples/stm32wl55/src/bin/button.rs
@@ -0,0 +1,40 @@
1#![no_std]
2#![no_main]
3#![feature(trait_alias)]
4#![feature(type_alias_impl_trait)]
5#![allow(incomplete_features)]
6
7#[path = "../example_common.rs"]
8mod example_common;
9use embassy_stm32::{
10 dbgmcu::Dbgmcu,
11 gpio::{Input, Level, Output, Pull, Speed},
12 rcc::*,
13};
14use embedded_hal::digital::v2::{InputPin, OutputPin};
15use example_common::*;
16
17use cortex_m_rt::entry;
18
19#[entry]
20fn main() -> ! {
21 info!("Hello World!");
22
23 let mut p = embassy_stm32::init(Default::default());
24
25 unsafe { Dbgmcu::enable_all() };
26
27 let button = Input::new(p.PA0, Pull::Up);
28 let mut led1 = Output::new(p.PB15, Level::High, Speed::Low);
29 let mut led2 = Output::new(p.PB9, Level::High, Speed::Low);
30
31 loop {
32 if button.is_high().unwrap() {
33 led1.set_high().unwrap();
34 led2.set_low().unwrap();
35 } else {
36 led1.set_low().unwrap();
37 led2.set_high().unwrap();
38 }
39 }
40}